This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: PR binutils/16318: Objcopy loses EI_OSABI
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Thu, 12 Dec 2013 14:44:37 -0800
- Subject: PATCH: PR binutils/16318: Objcopy loses EI_OSABI
- Authentication-results: sourceware.org; auth=none
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
I checked in this patch to copy EI_OSABI field. Those Linux targets
which define copy_private_bfd_data may fail binutils-all/strip-10.d.
I will submit a separate patch for them.
H.J.
--
bfd/
2013-12-12 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/16318
* elf.c (_bfd_elf_copy_private_bfd_data): Remove BFD_ASSERT.
Set e_flags only if elf_flags_init is FALSE. Copy EI_OSABI
field.
binutils/testsuite/
2013-12-12 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/16318
* binutils-all/strip-10.d: Check OS/ABI.
diff --git a/bfd/elf.c b/bfd/elf.c
index 66d9644..30d4171 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1117,13 +1117,17 @@ _bfd_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour)
return TRUE;
- BFD_ASSERT (!elf_flags_init (obfd)
- || (elf_elfheader (obfd)->e_flags
- == elf_elfheader (ibfd)->e_flags));
+ if (!elf_flags_init (obfd))
+ {
+ elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
+ elf_flags_init (obfd) = TRUE;
+ }
elf_gp (obfd) = elf_gp (ibfd);
- elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
- elf_flags_init (obfd) = TRUE;
+
+ /* Also copy the EI_OSABI field. */
+ elf_elfheader (obfd)->e_ident[EI_OSABI] =
+ elf_elfheader (ibfd)->e_ident[EI_OSABI];
/* Copy object attributes. */
_bfd_elf_copy_obj_attributes (ibfd, obfd);
diff --git a/binutils/testsuite/binutils-all/strip-10.d b/binutils/testsuite/binutils-all/strip-10.d
index 588c7d1..f4cf76d 100644
--- a/binutils/testsuite/binutils-all/strip-10.d
+++ b/binutils/testsuite/binutils-all/strip-10.d
@@ -1,8 +1,10 @@
#PROG: strip
#source: unique.s
#strip: -g
-#readelf: -s
+#readelf: -sh
#name: strip on STB_GNU_UNIQUE
#...
+ OS/ABI:[ \t]+UNIX - GNU
+#...
+[0-9]+: +[0-9a-f]+ +[0-9]+ +OBJECT +(UNIQUE|<OS specific>: 10) +DEFAULT +[1-9] foo