[PATCH] - objcopy --extract-symbol clears e_flags ELF header field

Ronald Hoogenboom hoogenboom30@zonnet.nl
Wed Oct 14 19:44:00 GMT 2015



On 10/14/2015 02:21 AM, Alan Modra wrote:
> On Tue, Oct 13, 2015 at 07:51:56PM +0200, Ronald Hoogenboom wrote:
>> @@ -2624,11 +2623,13 @@
>>      finalization work for private section headers.  Do that here.  */
>>   
>>   static void
>> -setup_bfd_headers (bfd *ibfd, bfd *obfd)
>> +setup_bfd_headers (bfd *ibfd, bfd *obfd, int data)
>>   {
>>     /* Allow the BFD backend to copy any private data it understands
>>        from the input section to the output section.  */
>> -  if (! bfd_copy_private_header_data (ibfd, obfd))
>> +
>> +  if (! (data?bfd_copy_private_header_data (ibfd, obfd):
>> +		  bfd_copy_private_bfd_data(ibfd, obfd)))
>>       {
>>         status = 1;
>>         bfd_nonfatal_message (NULL, ibfd, NULL,
> I'll guess that you haven't tested this on targets other than ARM ELF,
> and when/if you do you'll find that it regresses other targets.  For
> binutils changes like this I test on a large number of targets to get
> some coverage for the various machine and object format combinations.
Indeed I was short-sighted and only cared about the broken 
--extract-symbol on ARM-elf. I saw in the bfd-elf32-arm that this 
function copied the EABI. I was hoping BFD would just do 'the right 
thing' for others too.
> One complication in this case is that the existing --extract-symbol
> test is in ld/testsuite/ld-elf/ meaning that it only runs for ELF
> targets, which is stupid.  So you'd need to write a test to live in
> binutils/testsuite/binutils-all/ or run tests by hand.
>
> I suspect the correct patch is to delete these lines in objcopy.c
> copy_object
>
>    /* Do not copy backend data if --extract-symbol is passed; anything
>       that needs to look at the section contents will fail.  */
>    if (extract_symbol)
>      return TRUE;
>
> and deal with the fallout in all the target bfd_copy_private_bfd_data
> functions.
>
Or move the 2 lines to after the bfd_copy_private_bfd_data. So BFD needs 
to be adapted for all kinds of targets I never even heard about. There 
the test in the testsuite will be indispensable. Can you give me some 
pointers on how to get that done?



More information about the Binutils mailing list