Discussion:
Object file format
(too old to reply)
Darius Blaszijk
2003-07-30 21:36:57 UTC
Permalink
Hi there,

Whell I guess this question rises from time to time, but I have tried the
FAQ's on gcc.gnu.org with nu success. Is it possible to select the format of
the object file that GCC produces?? I guess it's ELF on linux en COFF on
windows, but is there a chance to produce OMF format?? Alternatively, is
there a workaround for the problem?? Lets say, compile with GCC and then
link it to a file thats compiled into OMF. Perhaps some other suggestions??

Darius Blaszijk
Tauno Voipio
2003-07-31 06:34:33 UTC
Permalink
Post by Darius Blaszijk
Hi there,
Whell I guess this question rises from time to time, but I have tried the
FAQ's on gcc.gnu.org with nu success. Is it possible to select the format of
the object file that GCC produces?? I guess it's ELF on linux en COFF on
windows, but is there a chance to produce OMF format?? Alternatively, is
there a workaround for the problem?? Lets say, compile with GCC and then
link it to a file thats compiled into OMF. Perhaps some other
suggestions??

You did not tell anything about your target system (processor, O/S), or
development system. Please note that it's possible to generate a very large
number of different combinations of the above parameters.

IIRC, there are also different flavours of the OMF format.

The object file format in the GNU toolset is mainly handled by the bfd
library in the binutils package (which contains assembler, linker, librarian
and utilities). It is possible to ask these programs about the different
object fromats supported.

The objcopy utility is able to convert the object from one supported format
to another, but please understand that the conversion often causes some
information loss due to the different philosophies associated with different
object formats.

HTH

Tauno Voipio
tauno voipio @ iki fi
llewelly
2003-07-31 07:24:19 UTC
Permalink
Post by Darius Blaszijk
Hi there,
Whell I guess this question rises from time to time, but I have tried the
FAQ's on gcc.gnu.org with nu success. Is it possible to select the format of
the object file that GCC produces?? I guess it's ELF on linux en COFF on
windows, but is there a chance to produce OMF format?? Alternatively, is
there a workaround for the problem?? Lets say, compile with GCC and then
link it to a file thats compiled into OMF. Perhaps some other suggestions??
Darius Blaszijk
I can't tell if you are using gnu binutils as well, but if you are,
consider objcopy, which can do some translation of formats.

http://sources.redhat.com/binutils/docs-2.12/binutils.info/objcopy.html#objcopy
Marco Manfredini
2003-07-31 09:36:46 UTC
Permalink
Post by Darius Blaszijk
Hi there,
Whell I guess this question rises from time to time, but I have tried
the FAQ's on gcc.gnu.org with nu success. Is it possible to select the
format of the object file that GCC produces??
The object file format is selected into the compiler during build.
objcopy can convert object files between different formats.
Post by Darius Blaszijk
I guess it's ELF on
linux en COFF on windows, but is there a chance to produce OMF
format??
OMF flavours aren't supported with the binutils, so you can't.
Post by Darius Blaszijk
Alternatively, is there a workaround for the problem?? Lets
say, compile with GCC and then link it to a file thats compiled into
OMF. Perhaps some other suggestions??
Depends on your OMF File. You can try the "editbin" utility from
Micro$oft which converts OMF to COFF.

Example:
# under windows:
bcc32 -c x.c
editbin x.obj
objcopy --remove-leading-char x.obj -O elf32-i386 x.o # using cygwin
# under linux:
gcc a.c x.o -o a

Marco
--
The text above is a result of a bug in my newsreader and I take no
responsibility for this text appearing in my post.
Continue reading on narkive:
Loading...