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
object file formats (aout)
RE:object file formats (aout)
Well, I don't know how much help I can be to your
specific problem, if only to say that it can be
done.
When I was developing my operating system, I
originally developed it withen dos using djgpp
and nasm (originally djgpp and gas but, like many,
I was trained using Intel syntax assembly, and
found it easier than AT&T).
Outputting both nasm and djgpp as a.out files, I
was able to link them properly and everything
worked perfectly. a.out really doesn't support
16-bit objects? Interesting... didn't know that.
In any event, though, that shouldn't be a problem,
'cuz nasm can simply say it's a 32-bit object and
simply put 16-bit code in the segments. Most of
the jumps will be near, and so it shouldn't
matter wether it's 16 or 32 bit.
Perhaps you need to upgrade your binutils, or
nasm?
I know in my "boot.asm" I had regular [bits 16]
code, jumped to pmode, then had [bits 32] code,
and finally, jumped to _main. In fact, in
main I also called some asm routines such as
.global _printMessage
_printMessage:
mov this, that
etc
ret
simply as printMessage();
Maybe if we could see your code..? Can we download
your .zip?
Sorry I couldn't be of more help,
Jeff
specific problem, if only to say that it can be
done.
When I was developing my operating system, I
originally developed it withen dos using djgpp
and nasm (originally djgpp and gas but, like many,
I was trained using Intel syntax assembly, and
found it easier than AT&T).
Outputting both nasm and djgpp as a.out files, I
was able to link them properly and everything
worked perfectly. a.out really doesn't support
16-bit objects? Interesting... didn't know that.
In any event, though, that shouldn't be a problem,
'cuz nasm can simply say it's a 32-bit object and
simply put 16-bit code in the segments. Most of
the jumps will be near, and so it shouldn't
matter wether it's 16 or 32 bit.
Perhaps you need to upgrade your binutils, or
nasm?
I know in my "boot.asm" I had regular [bits 16]
code, jumped to pmode, then had [bits 32] code,
and finally, jumped to _main. In fact, in
main I also called some asm routines such as
.global _printMessage
_printMessage:
mov this, that
etc
ret
simply as printMessage();
Maybe if we could see your code..? Can we download
your .zip?
Sorry I couldn't be of more help,
Jeff