linking C to ASM

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
MattCarpenter

linking C to ASM

Post 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
carbonBased

RE:linking C to ASM

Post 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
MattCarpenter

RE:linking C to ASM

Post by MattCarpenter »

thanks, works fine now :)
Post Reply