This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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

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

   /* 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

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?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]