objcopy in binutils doesn't work on Mac OS X

Nick Clifton nickc@redhat.com
Tue Feb 27 15:45:00 GMT 2007


Hi Axel,

   [Please keep the binutils list as one of the CC's for this email 
thread.  We would like to have this problem recorded in the binutils 
archives and there may be other people reading the list who are 
interested in the problem].

   [I a have added Eric Christopher to the TO list (hi Eric!) because I 
happen to know that he knows a lot about the OS-X binary file formats 
and he may be able to help].

>>> using binutils 2.16.1 (from MacPorts) or 2.17 (from source), doesn't work.
>> Have you also tried the sources from the mainline of the binutils CVS 
>> repository ?
> 
> No, I just tried but got:
> 
> make[2]: *** No rule to make target `../bfd/bfd.h', needed by `size.o'.
> Stop.

Hmm, how did you configure and build the sources ?


>>    * If you use the GNU version of ar to create the library, can gobjdump
>>      then recognise the file format of the blah.a file ?  If so, are you
>>      able to identify the differences between blah.a created by the OS-X
>>      tool and the blah.a created by the GNU tool ?
> 
> GNU ar doesn't work. It gives me an "Invalid operation" error and then
> creates a broken library file.

I suspect that this is related to the problem you have uncovered below. 
  ie the MACH-O code in the BFD library is not correctly handling the 
MACH-O file format that you are using.


>>    * Can you run "gobjdump -a blah.a" from inside GDB and put a
>>      breakpoint on bfd_mach_o_archive_p() (in bfd/mach-o.c) ?  Is this
>>      function called at all ?  If so, then at what point inside the
>>      function does it decide that the blah.a file is not a MACH OS
>>      library file ?
> 
> The magic value is wrong. The code:
> 
>   adata->magic = bfd_getb32 (buf);
>   adata->nfat_arch = bfd_getb32 (buf + 4);
> 
>   if ((adata->magic != 0xcafebabe))
>     goto error;
> 
> jumps to error, since the magic value of Apple's ar is 213c6172 (not a
> simple endian problem).

Eric - can you shed some light on this ?  Is 0x213c6172 another MACH-O 
magic number ?

Cheers
   Nick



More information about the Binutils mailing list