Linking error between assembler and C code (MinGW)

Error: In function '_go': c.asm:(.text+0x6): undefined reference to `k_main' compilation: asm\nasm -f elf -o c.o c.asm bin\ld -oformatbinary -Ttext 0x200000 -o bin\kernel.bin c.o bin\video.o bin\inter.o bin\finter.o bin\kernel.o -I "C:\MinGW\include" -L "C:\MinGW\lib" c.asm:

section .text
global _go
extern  k_main
_go:
    mov esp, 0x200000-4`
    call  k_main

kernel.c

void k_main(){
    //iint();
    //initial();
    for(;;);
}

Help please

Answers


The actual encoding of identifiers is defined by the object-format/platform/compiler, and in this case C functions get a underscore prefixed, so the symbol is actually _k_main.

You can use macros to do the encoding if you want it to be portable, or you can force the symbol in the C source code.


Need Your Help

Link in bootstrap tab not working

javascript jquery html twitter-bootstrap

I'm trying to load pages when using the boostrap tab navigation, but it doesn't work. I tried to override the default action by creating a class names preventDefault and using jQuery, but it still ...