This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: objcopy, binary inputs, and e_machine
Mike Frysinger wrote:
> On Tuesday 23 June 2009 19:35:36 Dave Korn wrote:
>> Mike Frysinger wrote:
>>> this behavior is because the objcopy sets the arch/mach of the output to
>>> match the input, and since this is a binary input, the arch/mach are set
>>> to none.
>> That seems obviously and blatantly wrong to me. Surely the arch/mach for
>> the input BFDs should be set one way and the arch/mach for the output BFD
>> should be set another in this case? If the "-I" option is setting the
>> parameters for the "-O" BFD, that's just a bug.
>
> hmm, it might run even deeper. the output bfd does not have anything setup in
> its arch_info field. this is because objcopy sets up the output bfd by doing
> bfd_open(file, target) (where target is the bfd name e.g. elf32-i386), and
> that uses the target name to only set up the target xvec via
> bfd_find_target().
>
> seems to me that bfd_find_target() should also initialize arch_info ? or
> perhaps bfd_open ?
Maybe objcopy should be calling bfd_set_arch_mach on the output bfd shortly
after creating it, based on it's knowledge of any -O option or failing that
using any -I option or the input bfd format as a default? I haven't had a lot
of time to look at this yet.
cheers,
DaveK