using nasm with ld

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
Özdemir ASAF

using nasm with ld

Post 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?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:using nasm with ld

Post 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 ...
Post Reply