This is the mail archive of the binutils@sourceware.org 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]

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


The --extract-symbol option for objcopy sets the e_flags field in the ELF header to zero.
This is later a problem in ARM if you want to link with this symbols-only object: the linker
ld will reject the object because of the incompatible EABI version, which is part of the e_flags field in ARM.

he attached patch uses bfd_copy_private_bfd_data when the --extract-symbol flag is used and
bfd_copy_private_header_data like it used to when it isn't.

This seems to address the described problem of EABI versions for ARM.

The patch is for the arm-none-eabi-binutils-cs-2014.05.28-3 version used in fedora 21. It may probably just apply
with some fuzz.

Refer to bugzilla bug 19090.

--- binutils/objcopy.c.orig	2015-10-12 20:55:35.789243991 +0200
+++ binutils/objcopy.c	2015-10-12 21:02:37.764968069 +0200
@@ -472,7 +472,7 @@
 
 /* Forward declarations.  */
 static void setup_section (bfd *, asection *, void *);
-static void setup_bfd_headers (bfd *, bfd *);
+static void setup_bfd_headers (bfd *, bfd *, int);
 static void copy_relocations_in_section (bfd *, asection *, void *);
 static void copy_section (bfd *, asection *, void *);
 static void get_sections (bfd *, asection *, void *);
@@ -1756,8 +1756,7 @@
      any output is done.  Thus, we traverse all sections multiple times.  */
   bfd_map_over_sections (ibfd, setup_section, obfd);
 
-  if (!extract_symbol)
-    setup_bfd_headers (ibfd, obfd);
+  setup_bfd_headers (ibfd, obfd, !extract_symbol);
 
   if (add_sections != NULL)
     {
@@ -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,

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