Page 1 of 1

using nasm with ld

Posted: Thu Jun 05, 2003 2:43 pm
by Ă–zdemir ASAF
Im a newbie os developer. Indeed my problem is just linking an asm and c files. I have asm-functions called from c file and c-functions called from asm file. I have following lines and following error.

nasm -f obj vole.asm -o vole.obj
gcc -ffreestanding -c main.c -o main.o
ld -i -Tlinker.ld -o mainvole.o vole.obj main.o

Linker Error:
vole.obj: file not recognized: File format not recognized

Im using djgpp for gcc and ld.

What may the correct lines be to link this two file?

Re:using nasm with ld

Posted: Thu Jun 05, 2003 2:49 pm
by Pype.Clicker
OBJ is a 16-bits format used by TLINK (from good 'ol TurboC) or similar MS-DOS compiler suite. LD is a 32bits linker and cannot deal with it.

So depending on whether you're under Linux or Windows, you should use "nasm -f elf" or "nasm -f coff" to get a linkable output of your .asm files...
This all (and more) should be explained in the documentation you get with nasm ...