linking binary 'hunks' into images

J.T. Conklin jtc@redback.com
Fri Oct 1 12:41:00 GMT 1999


Rather than fix the bugs we've recently encountered in the 3 year old
toolchain we're currently using, I've began a project to upgrade to a
more recent source base.  The particular bugs have already been fixed,
and it will be easier to track active development.

We have been linking in downloadable firmware images used by our
inteligent I/O cards by the linker's -b flag like this:

        powerpc-eabi-ld ... -b binary frt1.bin frt3.bin ...

Our target's firmware download routines uses the synthetic symbols
created by the linker (binary_frt1_bin_start, etc.) to locate the
firmware.

But in the current binutils source, the link fails with:

        powerpc-eabi-ld: frt1.bin: compiled for a little endian system and target is big endian
        File in wrong format: failed to merge target specific data of file frt1.bin
        powerpc-eabi-ld: frt3.bin: compiled for a little endian system and target is big endian
        File in wrong format: failed to merge target specific data of file frt3.bin

I first suspected ppc_elf_merge_private_bfd_data() in elf-ppc.c, in
particular the conditional:


  if (   ibfd->xvec->byteorder != obfd->xvec->byteorder
      && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
    {
      ...
      return false
    }


And indeed when that is #ifdef'd out the link succeeds.  But I
discovered that our old linker has the same conditional, so I'm still
a bit puzzled.

I noticed that elf32-mcore.c, elf32-mips.c, and elf32-ppc.c have
pretty much the same conditional in their *_elf_merge_private_data()
functions, but the one in elf32-arm.h the conditional is slightly 
different:


 if (   ibfd->xvec->byteorder != obfd->xvec->byteorder
     && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN
     && ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
   {
     ...
     return false;
   }

Changing ppc_elf_merge_private_bfd_data() to be like elf32_arm_...
allows the firmware to be linked successfully.

Questions:

- Is this the correct fix for the problem?

- If so, should this also be applied to elf32-mips.c and elf32-mcore.c?

        --jtc 

-- 
J.T. Conklin
RedBack Networks


More information about the Binutils mailing list