object file formats (aout)
Posted: Wed May 01, 2002 11:00 pm
I have a problem concerning object file formats. Because djgpp's linker
doesn't support too many formats, I'm a bit limited when I try to
interface asm with c. I use nasm v0.97 as assembler. The problem is that
I want to write a loader and stub that to a 32bit c program. Because the
loader executes from 16bit real mode (bootstrap) I can't use nasm's coff
format since that doesn't support 16bit references. So I use Linux a.out
format since djgpp seems to support that as i.386-a.out. The problem is
that no external symbol used in the asm file is resolved in the output
file. Jmps, calls etc. to c routines result in jmps and calls to
0x00000000. When I declare external nonexisting symbols, ld doens't
complain. I build some simple test files which are fully 32bit to test
the differences between the coff and aout formats. Assembled using coff,
ld outputs the correct file and complains if nonexisting symbols are
used. Assembled using aout, every symbol is resolved as null. When I use
objdump -i, I get error messages concerning an invalid header of the
a.out object file format. Is this related to my problem? The test files I
used are included in a zip file. Stub.asm is the correct stub for main.c.
Makecoff.bat builds the binary using the coff format for stub.o and
results in a correct output file, but unuseable as a loader. Makeaout.bat
builds the same binary using the aout format for stub.o and results in an
incorrect output file. Stub2.asm has a wrong symbol in it. Makec2.bat
builds this using coff, and complains. Makea2.bat builds it using aout
and doesn't complain. Objdump.out is my output for objdump -i and
version.txt displays the versions I used. I compiled all using DOS,
in fact from a DOS box of WINDOWS. I
hope you can help me out since it might be a bug in binutils. Of course,
it could be something else.
thanks in advance
doesn't support too many formats, I'm a bit limited when I try to
interface asm with c. I use nasm v0.97 as assembler. The problem is that
I want to write a loader and stub that to a 32bit c program. Because the
loader executes from 16bit real mode (bootstrap) I can't use nasm's coff
format since that doesn't support 16bit references. So I use Linux a.out
format since djgpp seems to support that as i.386-a.out. The problem is
that no external symbol used in the asm file is resolved in the output
file. Jmps, calls etc. to c routines result in jmps and calls to
0x00000000. When I declare external nonexisting symbols, ld doens't
complain. I build some simple test files which are fully 32bit to test
the differences between the coff and aout formats. Assembled using coff,
ld outputs the correct file and complains if nonexisting symbols are
used. Assembled using aout, every symbol is resolved as null. When I use
objdump -i, I get error messages concerning an invalid header of the
a.out object file format. Is this related to my problem? The test files I
used are included in a zip file. Stub.asm is the correct stub for main.c.
Makecoff.bat builds the binary using the coff format for stub.o and
results in a correct output file, but unuseable as a loader. Makeaout.bat
builds the same binary using the aout format for stub.o and results in an
incorrect output file. Stub2.asm has a wrong symbol in it. Makec2.bat
builds this using coff, and complains. Makea2.bat builds it using aout
and doesn't complain. Objdump.out is my output for objdump -i and
version.txt displays the versions I used. I compiled all using DOS,
in fact from a DOS box of WINDOWS. I
hope you can help me out since it might be a bug in binutils. Of course,
it could be something else.
thanks in advance