Argh! Linker and NASM

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
gizmostripe

Argh! Linker and NASM

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

Re:Argh! Linker and NASM

Post by mystran »

You want to compile them into objects of some format.
You then want to link them together as binary.
gizmostripe

Re:Argh! Linker and NASM

Post 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]
Slasher

Re:Argh! Linker and NASM

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