This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: 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: Fri, 13 Dec 2013 08:00:50 -0800
- Subject: Re: PATCH: PR binutils/16318: Objcopy loses EI_OSABI
- Authentication-results: sourceware.org; auth=none
- References: <20131212224436 dot GA15572 at intel dot com> <20131212230633 dot GA15944 at intel dot com>
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
On Thu, Dec 12, 2013 at 03:06:33PM -0800, H.J. Lu wrote:
> On Thu, Dec 12, 2013 at 02:44:36PM -0800, H.J. Lu wrote:
> > 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.
> >
>
> Here is a patch to call _bfd_elf_copy_private_bfd_data. But
> there are 5 failures:
>
> build-alpha-linux/binutils/binutils.log:FAIL: strip on STB_GNU_UNIQUE
> build-crisv32-linux/binutils/binutils.log:FAIL: strip on STB_GNU_UNIQUE
> build-frv-linux/binutils/binutils.log:FAIL: strip on STB_GNU_UNIQUE
> build-ia64-linux/binutils/binutils.log:FAIL: strip on STB_GNU_UNIQUE
> build-m68k-linux/binutils/binutils.log:FAIL: strip on STB_GNU_UNIQUE
>
> since those targets don't use _bfd_elf_set_osabi. Shouldn't
> elf_backend_post_process_headers be set to _bfd_elf_set_osabi by
> default?
>
>
Here is the pdated patch.
H.J.
---
bfd/
2013-12-12 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/16318
* elf32-arm.c (elf32_arm_copy_private_bfd_data): Call
_bfd_elf_copy_private_bfd_data.
* elf32-bfin.c (bfin_elf_copy_private_bfd_data): Removed.
(elf32_bfinfdpic_copy_private_bfd_data): Likewise.
(bfd_elf32_bfd_copy_private_bfd_data): Don't define.
* elf32-frv.c (frv_elf_copy_private_bfd_data): Removed.
(elf32_frvfdpic_copy_private_bfd_data): Likewise.
(bfd_elf32_bfd_copy_private_bfd_data): Don't define.
* elf32-iq2000.c (iq2000_elf_copy_private_bfd_data): Removed.
(bfd_elf32_bfd_copy_private_bfd_data): Don't define.
* elf32-lm32.c (lm32_elf_copy_private_bfd_data): Removed.
(lm32_elf_fdpic_copy_private_bfd_data): Call
_bfd_elf_copy_private_bfd_data.
* elf32-mep.c (mep_elf_copy_private_bfd_data): Removed.
(bfd_elf32_bfd_copy_private_bfd_data): Don't define.
* elf32-msp430.c (elf32_msp430_copy_private_bfd_data): Removed.
(bfd_elf32_bfd_copy_private_bfd_data): Don't define.
* elf32-mt.c (mt_elf_copy_private_bfd_data): Removed.
(bfd_elf32_bfd_copy_private_bfd_data): Don't define.
* elf32-sh.c (sh_elf_set_private_flags): Removed.
(sh_elf_copy_private_data): Call _bfd_elf_copy_private_bfd_data
and sh_elf_set_mach_from_flags.
* elf64-sh64.c (sh_elf64_copy_private_data_internal):
Call _bfd_elf_copy_private_bfd_data and
sh_elf64_set_mach_from_flags.
* elfnn-aarch64.c (elfNN_aarch64_copy_private_bfd_data): Removed.
(bfd_elfNN_bfd_copy_private_bfd_data): Don't define.
---
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 70d6ac0..b023499 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -11158,14 +11158,7 @@ elf32_arm_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
elf_elfheader (obfd)->e_flags = in_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);
-
- return TRUE;
+ return _bfd_elf_copy_private_bfd_data (ibfd, obfd);
}
/* Values for Tag_ABI_PCS_R9_use. */
diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c
index 73d0d09..6479386 100644
--- a/bfd/elf32-bfin.c
+++ b/bfd/elf32-bfin.c
@@ -4931,45 +4931,6 @@ elf32_bfin_set_private_flags (bfd * abfd, flagword flags)
return TRUE;
}
-/* Copy backend specific data from one object module to another. */
-
-static bfd_boolean
-bfin_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
-{
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || 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);
-
- elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
- elf_flags_init (obfd) = TRUE;
-
- /* Copy object attributes. */
- _bfd_elf_copy_obj_attributes (ibfd, obfd);
-
- return TRUE;
-}
-
-static bfd_boolean
-elf32_bfinfdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
-{
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
- return TRUE;
-
- if (! bfin_elf_copy_private_bfd_data (ibfd, obfd))
- return FALSE;
-
- if (! elf_tdata (ibfd) || ! elf_tdata (ibfd)->phdr
- || ! elf_tdata (obfd) || ! elf_tdata (obfd)->phdr)
- return TRUE;
-
- return TRUE;
-}
-
-
/* Display the flags field. */
static bfd_boolean
elf32_bfin_print_private_bfd_data (bfd * abfd, void * ptr)
@@ -5749,9 +5710,6 @@ struct bfd_elf_special_section const elf32_bfin_special_sections[] =
#undef elf_backend_always_size_sections
#define elf_backend_always_size_sections \
elf32_bfinfdpic_always_size_sections
-#undef bfd_elf32_bfd_copy_private_bfd_data
-#define bfd_elf32_bfd_copy_private_bfd_data \
- elf32_bfinfdpic_copy_private_bfd_data
#undef elf_backend_create_dynamic_sections
#define elf_backend_create_dynamic_sections \
diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c
index cf187ac..159abd1 100644
--- a/bfd/elf32-frv.c
+++ b/bfd/elf32-frv.c
@@ -6313,27 +6313,6 @@ frv_elf_set_private_flags (bfd *abfd, flagword flags)
return TRUE;
}
-/* Copy backend specific data from one object module to another. */
-
-static bfd_boolean
-frv_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
-{
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || 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);
-
- elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
- elf_flags_init (obfd) = TRUE;
-
- /* Copy object attributes. */
- _bfd_elf_copy_obj_attributes (ibfd, obfd);
-
- return TRUE;
-}
-
/* Return true if the architecture described by elf header flag
EXTENSION is an extension of the architecture described by BASE. */
@@ -6361,23 +6340,6 @@ frv_elf_arch_extension_p (flagword base, flagword extension)
return FALSE;
}
-static bfd_boolean
-elf32_frvfdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
-{
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
- return TRUE;
-
- if (! frv_elf_copy_private_bfd_data (ibfd, obfd))
- return FALSE;
-
- if (! elf_tdata (ibfd) || ! elf_tdata (ibfd)->phdr
- || ! elf_tdata (obfd) || ! elf_tdata (obfd)->phdr)
- return TRUE;
-
- return TRUE;
-}
-
/* Merge backend specific data from an object file to the output
object file when linking. */
@@ -6833,7 +6795,6 @@ elf32_frv_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
#define bfd_elf32_bfd_reloc_type_lookup frv_reloc_type_lookup
#define bfd_elf32_bfd_reloc_name_lookup frv_reloc_name_lookup
#define bfd_elf32_bfd_set_private_flags frv_elf_set_private_flags
-#define bfd_elf32_bfd_copy_private_bfd_data frv_elf_copy_private_bfd_data
#define bfd_elf32_bfd_merge_private_bfd_data frv_elf_merge_private_bfd_data
#define bfd_elf32_bfd_print_private_bfd_data frv_elf_print_private_bfd_data
@@ -6871,9 +6832,6 @@ elf32_frv_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
#undef elf_backend_always_size_sections
#define elf_backend_always_size_sections \
elf32_frvfdpic_always_size_sections
-#undef bfd_elf32_bfd_copy_private_bfd_data
-#define bfd_elf32_bfd_copy_private_bfd_data \
- elf32_frvfdpic_copy_private_bfd_data
#undef elf_backend_create_dynamic_sections
#define elf_backend_create_dynamic_sections \
diff --git a/bfd/elf32-iq2000.c b/bfd/elf32-iq2000.c
index ff7ef4a..0155ec4 100644
--- a/bfd/elf32-iq2000.c
+++ b/bfd/elf32-iq2000.c
@@ -763,27 +763,6 @@ iq2000_elf_set_private_flags (bfd *abfd, flagword flags)
return TRUE;
}
-/* Copy backend specific data from one object module to another. */
-
-static bfd_boolean
-iq2000_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
-{
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || 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);
-
- elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
- elf_flags_init (obfd) = TRUE;
-
- /* Copy object attributes. */
- _bfd_elf_copy_obj_attributes (ibfd, obfd);
-
- return TRUE;
-}
-
/* Merge backend specific data from an object
file to the output object file when linking. */
@@ -931,7 +910,6 @@ iq2000_elf_object_p (bfd *abfd)
#define bfd_elf32_bfd_reloc_type_lookup iq2000_reloc_type_lookup
#define bfd_elf32_bfd_reloc_name_lookup iq2000_reloc_name_lookup
#define bfd_elf32_bfd_set_private_flags iq2000_elf_set_private_flags
-#define bfd_elf32_bfd_copy_private_bfd_data iq2000_elf_copy_private_bfd_data
#define bfd_elf32_bfd_merge_private_bfd_data iq2000_elf_merge_private_bfd_data
#define bfd_elf32_bfd_print_private_bfd_data iq2000_elf_print_private_bfd_data
diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c
index 4ebe534..99aabea 100644
--- a/bfd/elf32-lm32.c
+++ b/bfd/elf32-lm32.c
@@ -2627,26 +2627,6 @@ lm32_elf_always_size_sections (bfd *output_bfd, struct bfd_link_info *info)
}
static bfd_boolean
-lm32_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
-{
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || 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);
-
- elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
- elf_flags_init (obfd) = TRUE;
-
- /* Copy object attributes. */
- _bfd_elf_copy_obj_attributes (ibfd, obfd);
-
- return TRUE;
-}
-
-
-static bfd_boolean
lm32_elf_fdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
{
unsigned i;
@@ -2655,7 +2635,7 @@ lm32_elf_fdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour)
return TRUE;
- if (! lm32_elf_copy_private_bfd_data (ibfd, obfd))
+ if (! _bfd_elf_copy_private_bfd_data (ibfd, obfd))
return FALSE;
if (! elf_tdata (ibfd) || ! elf_tdata (ibfd)->phdr
diff --git a/bfd/elf32-mep.c b/bfd/elf32-mep.c
index 2204488..b4a193d 100644
--- a/bfd/elf32-mep.c
+++ b/bfd/elf32-mep.c
@@ -580,22 +580,6 @@ mep_elf_set_private_flags (bfd * abfd,
return TRUE;
}
-static bfd_boolean
-mep_elf_copy_private_bfd_data (bfd * ibfd, bfd * obfd)
-{
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
- return TRUE;
-
- elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
- elf_flags_init (obfd) = TRUE;
-
- /* Copy object attributes. */
- _bfd_elf_copy_obj_attributes (ibfd, obfd);
-
- return TRUE;
-}
-
/* Merge backend specific data from an object file to the output
object file when linking. */
@@ -778,7 +762,6 @@ mep_elf_fake_sections (bfd * abfd ATTRIBUTE_UNUSED,
#define bfd_elf32_bfd_reloc_type_lookup mep_reloc_type_lookup
#define bfd_elf32_bfd_reloc_name_lookup mep_reloc_name_lookup
#define bfd_elf32_bfd_set_private_flags mep_elf_set_private_flags
-#define bfd_elf32_bfd_copy_private_bfd_data mep_elf_copy_private_bfd_data
#define bfd_elf32_bfd_merge_private_bfd_data mep_elf_merge_private_bfd_data
#define bfd_elf32_bfd_print_private_bfd_data mep_elf_print_private_bfd_data
diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c
index 533eea3..3d8d22f 100644
--- a/bfd/elf32-msp430.c
+++ b/bfd/elf32-msp430.c
@@ -2392,17 +2392,6 @@ elf32_msp430_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
return elf32_msp430_merge_mspabi_attributes (ibfd, obfd);
}
-/* Copy backend specific data from one object module to another. */
-
-static bfd_boolean
-elf32_msp430_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
-{
- /* Copy object attributes. */
- _bfd_elf_copy_obj_attributes (ibfd, obfd);
-
- return TRUE;
-}
-
static bfd_boolean
msp430_elf_is_target_special_symbol (bfd *abfd, asymbol *sym)
{
@@ -2439,7 +2428,6 @@ msp430_elf_is_target_special_symbol (bfd *abfd, asymbol *sym)
#define elf_backend_obj_attrs_handle_unknown elf32_msp430_obj_attrs_handle_unknown
#undef elf_backend_obj_attrs_arg_type
#define elf_backend_obj_attrs_arg_type elf32_msp430_obj_attrs_arg_type
-#define bfd_elf32_bfd_copy_private_bfd_data elf32_msp430_copy_private_bfd_data
#define bfd_elf32_bfd_merge_private_bfd_data elf32_msp430_merge_private_bfd_data
#define ELF_ARCH bfd_arch_msp430
diff --git a/bfd/elf32-mt.c b/bfd/elf32-mt.c
index 597665c..00152a32 100644
--- a/bfd/elf32-mt.c
+++ b/bfd/elf32-mt.c
@@ -497,25 +497,6 @@ mt_elf_set_private_flags (bfd * abfd,
return TRUE;
}
-static bfd_boolean
-mt_elf_copy_private_bfd_data (bfd * ibfd, bfd * obfd)
-{
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || 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);
-
- elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
- elf_flags_init (obfd) = TRUE;
-
- /* Copy object attributes. */
- _bfd_elf_copy_obj_attributes (ibfd, obfd);
-
- return TRUE;
-}
-
/* Merge backend specific data from an object file to the output
object file when linking. */
@@ -615,7 +596,6 @@ mt_elf_print_private_bfd_data (bfd * abfd, void * ptr)
#define elf_backend_can_gc_sections 1
#define bfd_elf32_bfd_set_private_flags mt_elf_set_private_flags
-#define bfd_elf32_bfd_copy_private_bfd_data mt_elf_copy_private_bfd_data
#define bfd_elf32_bfd_merge_private_bfd_data mt_elf_merge_private_bfd_data
#define bfd_elf32_bfd_print_private_bfd_data mt_elf_print_private_bfd_data
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 7e6a18b..ac23a72 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -6582,34 +6582,19 @@ sh_elf_get_flags_from_mach (unsigned long mach)
}
#endif /* not sh_elf_set_mach_from_flags */
-#ifndef sh_elf_set_private_flags
-/* Function to keep SH specific file flags. */
-
-static bfd_boolean
-sh_elf_set_private_flags (bfd *abfd, flagword flags)
-{
- BFD_ASSERT (! elf_flags_init (abfd)
- || elf_elfheader (abfd)->e_flags == flags);
-
- elf_elfheader (abfd)->e_flags = flags;
- elf_flags_init (abfd) = TRUE;
- return sh_elf_set_mach_from_flags (abfd);
-}
-#endif /* not sh_elf_set_private_flags */
-
#ifndef sh_elf_copy_private_data
/* Copy backend specific data from one object module to another */
static bfd_boolean
sh_elf_copy_private_data (bfd * ibfd, bfd * obfd)
{
- /* Copy object attributes. */
- _bfd_elf_copy_obj_attributes (ibfd, obfd);
-
if (! is_sh_elf (ibfd) || ! is_sh_elf (obfd))
return TRUE;
- return sh_elf_set_private_flags (obfd, elf_elfheader (ibfd)->e_flags);
+ if (! _bfd_elf_copy_private_bfd_data (ibfd, obfd))
+ return FALSE;
+
+ return sh_elf_set_mach_from_flags (obfd);
}
#endif /* not sh_elf_copy_private_data */
diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c
index e70887b..4f49820 100644
--- a/bfd/elf64-sh64.c
+++ b/bfd/elf64-sh64.c
@@ -2268,6 +2268,9 @@ sh_elf64_copy_private_data_internal (bfd *ibfd, bfd *obfd)
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour)
return TRUE;
+ if (! _bfd_elf_copy_private_bfd_data (ibfd, obfd))
+ return FALSE;
+
o_shdrp = elf_elfsections (obfd);
for (osec = obfd->sections; osec; osec = osec->next)
{
@@ -2285,10 +2288,7 @@ sh_elf64_copy_private_data_internal (bfd *ibfd, bfd *obfd)
}
}
- /* Copy object attributes. */
- _bfd_elf_copy_obj_attributes (ibfd, obfd);
-
- return sh_elf64_set_private_flags (obfd, elf_elfheader (ibfd)->e_flags);
+ return sh_elf64_set_mach_from_flags (obfd);
}
static bfd_boolean
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 6a42bc5..22f95d3 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -4538,31 +4538,6 @@ elfNN_aarch64_set_private_flags (bfd *abfd, flagword flags)
return TRUE;
}
-/* Copy backend specific data from one object module to another. */
-
-static bfd_boolean
-elfNN_aarch64_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
-{
- flagword in_flags;
-
- if (!is_aarch64_elf (ibfd) || !is_aarch64_elf (obfd))
- return TRUE;
-
- in_flags = elf_elfheader (ibfd)->e_flags;
-
- elf_elfheader (obfd)->e_flags = in_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);
-
- return TRUE;
-}
-
/* Merge backend specific data from an object file to the output
object file when linking. */
@@ -7226,9 +7201,6 @@ const struct elf_size_info elfNN_aarch64_size_info =
#define bfd_elfNN_close_and_cleanup \
elfNN_aarch64_close_and_cleanup
-#define bfd_elfNN_bfd_copy_private_bfd_data \
- elfNN_aarch64_copy_private_bfd_data
-
#define bfd_elfNN_bfd_free_cached_info \
elfNN_aarch64_bfd_free_cached_info
--
1.8.3.1