I have this assembly file
bits 32
global _start
extern kmain
section .text
_start:
cli
call kmain
hlt
And this .cpp file
void kmain(void)
{
}
And when running these commands:
nasm -f elf32 asmfoo.asm -o asmfoo.o
gcc -m32 -c cppfoo.cpp -o cppfoo.o
ld -m elf_i386 -T ./linker.ld -o foo-output asmfoo.o cppfoo.o
I get this error:
ld: asmfoo.o: in function `_start':
asmfoo.asm:(.text+0xe): undefined reference to `kmain'
But when I change the name of the cpp file from cppfoo.cpp to cppfoo.c and run the same compile commands it works without any errors. So how would I call a c++ function from assembly as this doesent work with c++ for some reason.