Page 1 of 1

Argh! Linker and NASM

Posted: Mon Jul 28, 2003 12:41 pm
by gizmostripe
Hey there, im having some ungood things happening when compiling with NASM and then doing a link.

Basically i have 2 asm files (boot.asm, init.asm) init.asm calls the kernel.c init_os() function with EXTERN.

However when compiling with NASM i get an error saying that bin format does not support external refrences. The only other options i get are obj (dos), a linux format. And a win32 format. Not a plain OS independant option :(

Then, after compiling together (the bootsecotr compiles no problems, i use djgpp "ld.exe" to link the 2 files. Which spits it out and says. "boot.bin - unrecognised format"

can somebody please help me out here. Doing all this commandline compiling/linking is really annoying me right now.

Thanks in advance.

Re:Argh! Linker and NASM

Posted: Mon Jul 28, 2003 12:44 pm
by mystran
You want to compile them into objects of some format.
You then want to link them together as binary.

Re:Argh! Linker and NASM

Posted: Mon Jul 28, 2003 1:07 pm
by gizmostripe
Ok im not sure exactly what format though.

But heres the batch file, and the output.

Batch file:

Code: Select all

@echo off

echo Creating boot image...
..\Nasm\Nasm.exe -f bin boot.asm -o boot.o
echo done.

echo Creating kernel stepper...
..\Nasm\Nasm.exe -f bin init.asm -o init.o
echo done.

echo

echo Linking...
C:\djgpp\bin\ld.exe -T linker.lnk -o nfinity.bin boot.o init.o -oformat BIN
echo Done!!
The formats available to me are: bin, obj, as86, win32 (nasm)

and this happens:


[attachment deleted by admin]

Re:Argh! Linker and NASM

Posted: Mon Jul 28, 2003 1:17 pm
by Slasher
you can't link bin files.
try
nasm -fcoff *.asm -o *.o
that will create coff files with info need for linking
or
nasm -faout *.asm *.o
this will create aout files with info for linking
the you can link with ld or any other linker that understands
coff or aout formats.
Also what is in you linker script file?