Page 1 of 1

linking C to ASM

Posted: Thu Aug 01, 2002 11:00 pm
by MattCarpenter
I'm makign a small protected mode kernel which requires me to link a C file to my ASM file. I tried this using JLOC and a control file, but it didn't link correctly and my kernel always crashed. Could somebody post a control file for JLOC or tell me how to link C files to ASM? My c files are compiled like this: gcc -O3 -c kernel_c.c and my ASM's are compiled like this: NASM -f obj kernel.asm

Thanks

RE:linking C to ASM

Posted: Thu Aug 01, 2002 11:00 pm
by carbonBased
Check the "Developer Guides" link at the top of this page...

in short,
make sure your asm symbols are global
make sure your c symbols are global
nasm -f elf kernel.asm
gcc -c kernel_c.c
ld kernel.o kernel_c.o -o output

If this fails, then there's something wrong with your code, not the linker.

Oh, and btw, replace "elf" with "coff" if you're using djgpp.

Jeff

RE:linking C to ASM

Posted: Thu Aug 01, 2002 11:00 pm
by MattCarpenter
thanks, works fine now :)