This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Difference between --oformat binary, and objcopy -O binary of --oformat elf32-i386
- From: Nick Clifton <nickc at redhat dot com>
- To: linuxyne citadel <linuxyne at gmail dot com>, binutils at sourceware dot org
- Date: Tue, 19 Jul 2016 11:35:40 +0100
- Subject: Re: Difference between --oformat binary, and objcopy -O binary of --oformat elf32-i386
- Authentication-results: sourceware.org; auth=none
- References: <CAFGAZ1WFoOd238Nwwck1sqr2vGcwzPUC2sxOSNHQH8tpFYz=5w@mail.gmail.com>
Hi linuxyne,
> (1) --oformat binary
> (2) --oformat elf32-i386 and then objcopy -O binary,
>
> the resulting code linked and stored within each resultant binary is
> different from one another, even though both use the same .o file.
>
> An observation shows (2) creates correct binaries, but (1) does not.
>
> Do we know, beforehand, if this is an error on the part of the user
> compiling the code,
No - the compilation of the code is fine.
> or if this is a designed
It is not a designed behaviour, but...
> or even an unsupported behaviour.
... it is basically unsupported. Using the --oformat option of the
linker is known to be problematic in lots of cases. It is far better
to use method (2), as this is much more likely to achieve the correct
outcome.
Possibly the use of --oformat in the linker should be deprecated,
although there may be some situations where it does work.
Cheers
Nick