Author Topic: Obect Files...  (Read 3410 times)


  • Guest
Obect Files...
« on: December 20, 2004, 05:36:39 PM »
Im trying to link a C functions defined in a Gcc file.cpp to be called from nasm procedures, the problem is when i try to create a Flat Binary Kernel image (Micro OS Kernel), im try with:
gcc -c file.cpp
nasm noosboot.asm -o noosboot.o -f obj (also try win32, coff, rdf, ieee, etc...)
ld -X -S -r -o Noosboot.bin noosboot.o file.o

the unic message i see is this:
NoOsboot.o: file not recognized: File format not recognized

anothers formats displays another messages (no 32 bits relocations in coff format etc...)

Peter Wiehe

  • Guest
Re: Obect Files...
« Reply #1 on: January 22, 2005, 09:06:15 PM »
This topic is out of date, but since no one answered, I answer, while I'm around.

Try "nasm -f elf ...", because LD can't handle anything else (normally).
You could recompile binutils to make LD support more formats, but different object formats normally doesn't fit together very well (see the coff error message...), so use ELF, because that's what GCC produces.

BTW it seems to me that You won't create a flatbin this way.
You must tell LD something like "-oformat binary" or "--output-format=binary" or so... (type "info gcc")
And normally You have to recompile LD to make it possible.

(And if You link 16bit code together with 32bit code, You have to take care of the object file format incompatibility I mentioned above _and_ be very careful about the JMP-address. Often it's easier to
build a 16bit-flatbin and a 32bit-flatbin or -object file.)

Peter Wiehe

Peter Wiehe

  • Guest
Re: Obect Files...
« Reply #2 on: January 22, 2005, 11:43:11 PM »
Oops, better "info ld" instead of "info gcc".
So "info gcc" is intersting for linking, too.