PATCH: Default elf_backend_post_process_headers to set OSABI

H.J. Lu hjl.tools@gmail.com
Fri Dec 13 13:10:00 GMT 2013


On Thu, Dec 12, 2013 at 7:29 PM, Hans-Peter Nilsson
<hans-peter.nilsson@axis.com> wrote:
>> From: "H.J. Lu" <hongjiu.lu@intel.com>
>> Date: Fri, 13 Dec 2013 00:06:33 +0100
>
>> On Thu, Dec 12, 2013 at 02:44:36PM -0800, H.J. Lu wrote:
>> 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
>
> My autotester sees failures for mipsisa32r2el-unknown-linux-gnu,
> cris-axis-linux-gnu, cris-axis-elf.  While the last two would
> see the same as your "build-crisv32-linux" the first one seems
> missing from your list.
>
>> 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?
>
> I'd guess yes?
>
> brgds, H-P

Here is a patch to do that.  OK to install?

-- 
H.J.
--
2013-12-13  H.J. Lu  <hongjiu.lu@intel.com>

    * elf-bfd.h (_bfd_elf_set_osabi): Renamed to ...
    (_bfd_elf_post_process_headers): This.
    * elf.c (_bfd_elf_compute_section_file_positions): Always
    call elf_backend_post_process_headers.
    (_bfd_elf_set_osabi): Renamed to ...
    (_bfd_elf_post_process_headers): This.
    * elf32-hppa.c (elf_backend_post_process_headers): Removed.
    * elf32-i370.c (elf_backend_post_process_headers): Likewise.
    * elf32-msp430.c (elf_backend_post_process_headers): Likewise.
    * elf32-ppc.c (elf_backend_post_process_headers): Likewise.
    * elf32-sparc.c (elf_backend_post_process_headers): Likewise.
    * elf64-hppa.c (elf_backend_post_process_headers): Likewise.
    * elf64-ppc.c (elf_backend_post_process_headers): Likewise.
    * elf64-sparc.c (elf_backend_post_process_headers): Likewise.
    * elf64-x86-64.c (elf_backend_post_process_headers): Likewise.
    *  (elf_backend_post_process_headers): Likewise.
    *  (elf_backend_post_process_headers): Likewise.
    * elf32-i386.c (elf_backend_post_process_headers): Don't
    define as _bfd_elf_set_osabi.
    (elf_i386_fbsd_post_process_headers): Updated.
    * elf32-mips.c (elf_fbsd_post_process_headers): Removed.
    (elf_backend_post_process_headers): Likewise.
    * elf32-tic6x.c (elf32_tic6x_set_osabi): Removed.
    (elf_backend_post_process_headers): Likewise.
    * elf64-mips.c (elf_fbsd_post_process_headers): Removed.
    (elf_backend_post_process_headers): Likewise.
    * elfn32-mips.c (elf_fbsd_post_process_headers): Removed.
    (elf_backend_post_process_headers): Likewise.
    * elfnn-aarch64.c (elfNN_aarch64_post_process_headers): Updated.
    * elfxx-target.h (elf_backend_post_process_headers): Default
    to _bfd_elf_post_process_headers.
-------------- next part --------------
From d20641f87131473c5533fe07079eed67b8e45492 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 13 Dec 2013 05:01:02 -0800
Subject: [PATCH] Default elf_backend_post_process_headers to
 _bfd_elf_post_process_headers

---
 ChangeLog.osabi     | 33 +++++++++++++++++++++++++++++++++
 bfd/elf-bfd.h       |  2 +-
 bfd/elf.c           |  7 +++----
 bfd/elf32-hppa.c    |  1 -
 bfd/elf32-i370.c    |  1 -
 bfd/elf32-i386.c    |  6 +-----
 bfd/elf32-mips.c    | 12 ------------
 bfd/elf32-msp430.c  |  1 -
 bfd/elf32-ppc.c     |  1 -
 bfd/elf32-sparc.c   |  1 -
 bfd/elf32-tic6x.c   | 14 --------------
 bfd/elf64-hppa.c    |  2 --
 bfd/elf64-mips.c    | 12 ------------
 bfd/elf64-ppc.c     |  1 -
 bfd/elf64-sparc.c   |  2 --
 bfd/elf64-x86-64.c  |  2 --
 bfd/elfn32-mips.c   | 12 ------------
 bfd/elfnn-aarch64.c |  2 +-
 bfd/elfxx-target.h  |  2 +-
 19 files changed, 40 insertions(+), 74 deletions(-)
 create mode 100644 ChangeLog.osabi

diff --git a/ChangeLog.osabi b/ChangeLog.osabi
new file mode 100644
index 0000000..e6fc9bb
--- /dev/null
+++ b/ChangeLog.osabi
@@ -0,0 +1,33 @@
+2013-12-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* elf-bfd.h (_bfd_elf_set_osabi): Renamed to ...
+	(_bfd_elf_post_process_headers): This.
+	* elf.c (_bfd_elf_compute_section_file_positions): Always
+	call elf_backend_post_process_headers.
+	(_bfd_elf_set_osabi): Renamed to ...
+	(_bfd_elf_post_process_headers): This.
+	* elf32-hppa.c (elf_backend_post_process_headers): Removed.
+	* elf32-i370.c (elf_backend_post_process_headers): Likewise.
+	* elf32-msp430.c (elf_backend_post_process_headers): Likewise.
+	* elf32-ppc.c (elf_backend_post_process_headers): Likewise.
+	* elf32-sparc.c (elf_backend_post_process_headers): Likewise.
+	* elf64-hppa.c (elf_backend_post_process_headers): Likewise.
+	* elf64-ppc.c (elf_backend_post_process_headers): Likewise.
+	* elf64-sparc.c (elf_backend_post_process_headers): Likewise.
+	* elf64-x86-64.c (elf_backend_post_process_headers): Likewise.
+	*  (elf_backend_post_process_headers): Likewise.
+	*  (elf_backend_post_process_headers): Likewise.
+	* elf32-i386.c (elf_backend_post_process_headers): Don't
+	define as _bfd_elf_set_osabi.
+	(elf_i386_fbsd_post_process_headers): Updated.
+	* elf32-mips.c (elf_fbsd_post_process_headers): Removed.
+	(elf_backend_post_process_headers): Likewise.
+	* elf32-tic6x.c (elf32_tic6x_set_osabi): Removed.
+	(elf_backend_post_process_headers): Likewise.
+	* elf64-mips.c (elf_fbsd_post_process_headers): Removed.
+	(elf_backend_post_process_headers): Likewise.
+	* elfn32-mips.c (elf_fbsd_post_process_headers): Removed.
+	(elf_backend_post_process_headers): Likewise.
+	* elfnn-aarch64.c (elfNN_aarch64_post_process_headers): Updated.
+	* elfxx-target.h (elf_backend_post_process_headers): Default
+	to _bfd_elf_post_process_headers.
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 0446725..0aab5fa 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2041,7 +2041,7 @@ extern bfd_reloc_status_type bfd_elf_perform_complex_relocation
 extern bfd_boolean _bfd_elf_setup_sections
   (bfd *);
 
-extern void _bfd_elf_set_osabi (bfd * , struct bfd_link_info *);
+extern void _bfd_elf_post_process_headers (bfd * , struct bfd_link_info *);
 
 extern const bfd_target *bfd_elf32_object_p
   (bfd *);
diff --git a/bfd/elf.c b/bfd/elf.c
index 30d4171..b589e60 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3457,8 +3457,7 @@ _bfd_elf_compute_section_file_positions (bfd *abfd,
     return FALSE;
 
   /* Post process the headers if necessary.  */
-  if (bed->elf_backend_post_process_headers)
-    (*bed->elf_backend_post_process_headers) (abfd, link_info);
+  (*bed->elf_backend_post_process_headers) (abfd, link_info);
 
   fsargs.failed = FALSE;
   fsargs.link_info = link_info;
@@ -10016,8 +10015,8 @@ asection _bfd_elf_large_com_section
 		      SEC_IS_COMMON, NULL, "LARGE_COMMON", 0);
 
 void
-_bfd_elf_set_osabi (bfd * abfd,
-		    struct bfd_link_info * link_info ATTRIBUTE_UNUSED)
+_bfd_elf_post_process_headers (bfd * abfd,
+			       struct bfd_link_info * link_info ATTRIBUTE_UNUSED)
 {
   Elf_Internal_Ehdr * i_ehdrp;	/* ELF file header, internal form.  */
 
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index df25ac9..710028f 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -4643,7 +4643,6 @@ elf32_hppa_elf_get_symbol_type (Elf_Internal_Sym *elf_sym, int type)
 #define elf_backend_grok_psinfo		     elf32_hppa_grok_psinfo
 #define elf_backend_object_p		     elf32_hppa_object_p
 #define elf_backend_final_write_processing   elf_hppa_final_write_processing
-#define elf_backend_post_process_headers     _bfd_elf_set_osabi
 #define elf_backend_get_symbol_type	     elf32_hppa_elf_get_symbol_type
 #define elf_backend_reloc_type_class	     elf32_hppa_reloc_type_class
 #define elf_backend_action_discarded	     elf_hppa_action_discarded
diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c
index 48e25f2..073197b 100644
--- a/bfd/elf32-i370.c
+++ b/bfd/elf32-i370.c
@@ -1388,7 +1388,6 @@ i370_elf_relocate_section (bfd *output_bfd,
 #define elf_backend_section_from_shdr		i370_elf_section_from_shdr
 #define elf_backend_adjust_dynamic_symbol	i370_elf_adjust_dynamic_symbol
 #define elf_backend_check_relocs		i370_elf_check_relocs
-#define elf_backend_post_process_headers	_bfd_elf_set_osabi
 
 static int
 i370_noop (void)
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 4574c59..4d391e1 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -5068,8 +5068,6 @@ elf_i386_add_symbol_hook (bfd * abfd,
 #define elf_backend_plt_sym_val		      elf_i386_plt_sym_val
 #define elf_backend_hash_symbol		      elf_i386_hash_symbol
 #define elf_backend_add_symbol_hook           elf_i386_add_symbol_hook
-#undef	elf_backend_post_process_headers
-#define	elf_backend_post_process_headers	_bfd_elf_set_osabi
 
 #include "elf32-target.h"
 
@@ -5089,7 +5087,7 @@ elf_i386_add_symbol_hook (bfd * abfd,
 static void
 elf_i386_fbsd_post_process_headers (bfd *abfd, struct bfd_link_info *info)
 {
-  _bfd_elf_set_osabi (abfd, info);
+  _bfd_elf_post_process_headers (abfd, info);
 
 #ifdef OLD_FREEBSD_ABI_LABEL
   /* The ABI label supported by FreeBSD <= 4.0 is quite nonstandard.  */
@@ -5151,7 +5149,6 @@ elf_i386_fbsd_post_process_headers (bfd *abfd, struct bfd_link_info *info)
 #undef	elf_backend_want_plt_sym
 #define elf_backend_want_plt_sym	0
 #undef	elf_backend_post_process_headers
-#define	elf_backend_post_process_headers	_bfd_elf_set_osabi
 #undef	elf_backend_static_tls_alignment
 
 /* NaCl uses substantially different PLT entries for the same effects.  */
@@ -5345,7 +5342,6 @@ static const struct elf_i386_backend_data elf_i386_vxworks_arch_bed =
 #define	elf_backend_arch_data	&elf_i386_vxworks_arch_bed
 
 #undef elf_backend_relocs_compatible
-#undef elf_backend_post_process_headers
 #undef elf_backend_add_symbol_hook
 #define elf_backend_add_symbol_hook \
   elf_vxworks_add_symbol_hook
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index eec2ef7..ada66ce 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -2449,18 +2449,6 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
 #undef	ELF_OSABI
 #define	ELF_OSABI			ELFOSABI_FREEBSD
 
-/* The kernel recognizes executables as valid only if they carry a
-   "FreeBSD" label in the ELF header.  So we put this label on all
-   executables and (for simplicity) also all other object files.  */
-
-static void
-elf_fbsd_post_process_headers (bfd *abfd, struct bfd_link_info *info)
-{
-  _bfd_elf_set_osabi (abfd, info);
-}
-
-#undef	elf_backend_post_process_headers
-#define	elf_backend_post_process_headers	elf_fbsd_post_process_headers
 #undef	elf32_bed
 #define elf32_bed				elf32_fbsd_tradbed
 
diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c
index 533eea3..3d07a1a 100644
--- a/bfd/elf32-msp430.c
+++ b/bfd/elf32-msp430.c
@@ -2458,7 +2458,6 @@ msp430_elf_is_target_special_symbol (bfd *abfd, asymbol *sym)
 #define elf_backend_can_gc_sections          1
 #define elf_backend_final_write_processing   bfd_elf_msp430_final_write_processing
 #define elf_backend_object_p		     elf32_msp430_object_p
-#define elf_backend_post_process_headers     _bfd_elf_set_osabi
 #define bfd_elf32_bfd_relax_section	     msp430_elf_relax_section
 #define bfd_elf32_bfd_is_target_special_symbol	msp430_elf_is_target_special_symbol
 
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 47c92ba..b601f05 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -9922,7 +9922,6 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
 #define elf_backend_plt_sym_val			ppc_elf_plt_sym_val
 #define elf_backend_action_discarded		ppc_elf_action_discarded
 #define elf_backend_init_index_section		_bfd_elf_init_1_index_section
-#define elf_backend_post_process_headers	_bfd_elf_set_osabi
 #define elf_backend_lookup_section_flags_hook	ppc_elf_lookup_section_flags
 #define elf_backend_section_processing		ppc_elf_section_processing
 
diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
index 52abfd4..d8d90c7 100644
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -245,7 +245,6 @@ elf32_sparc_add_symbol_hook (bfd * abfd,
 #define elf_backend_got_header_size 4
 #define elf_backend_rela_normal 1
 
-#define elf_backend_post_process_headers	_bfd_elf_set_osabi
 #define elf_backend_add_symbol_hook		elf32_sparc_add_symbol_hook
 
 #include "elf32-target.h"
diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c
index 92726b2..fe82c8f 100644
--- a/bfd/elf32-tic6x.c
+++ b/bfd/elf32-tic6x.c
@@ -4345,14 +4345,6 @@ elf32_tic6x_write_section (bfd *output_bfd,
   return TRUE;
 }
 
-static void
-elf32_tic6x_set_osabi (bfd *abfd, struct bfd_link_info *link_info)
-{
-  if (link_info != NULL && link_info->relocatable)
-    return;
-  _bfd_elf_set_osabi (abfd, link_info);
-}
-
 #define TARGET_LITTLE_SYM	bfd_elf32_tic6x_le_vec
 #define TARGET_LITTLE_NAME	"elf32-tic6x-le"
 #define TARGET_BIG_SYM		bfd_elf32_tic6x_be_vec
@@ -4434,9 +4426,6 @@ elf32_tic6x_set_osabi (bfd *abfd, struct bfd_link_info *link_info)
 #undef ELF_OSABI
 #define	ELF_OSABI			ELFOSABI_C6000_LINUX
 
-#undef elf_backend_post_process_headers
-#define elf_backend_post_process_headers	elf32_tic6x_set_osabi
-
 #include "elf32-target.h"
 
 #undef elf32_bed
@@ -4453,7 +4442,4 @@ elf32_tic6x_set_osabi (bfd *abfd, struct bfd_link_info *link_info)
 #undef ELF_OSABI
 #define	ELF_OSABI			ELFOSABI_C6000_ELFABI
 
-#undef elf_backend_post_process_headers
-#define elf_backend_post_process_headers	elf32_tic6x_set_osabi
-
 #include "elf32-target.h"
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index c992563..121827b 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -4103,8 +4103,6 @@ const struct elf_size_info hppa64_elf_size_info =
 #define TARGET_BIG_NAME			"elf64-hppa-linux"
 #undef ELF_OSABI
 #define ELF_OSABI			ELFOSABI_GNU
-#undef elf_backend_post_process_headers
-#define elf_backend_post_process_headers _bfd_elf_set_osabi
 #undef elf64_bed
 #define elf64_bed			elf64_hppa_linux_bed
 
diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c
index a0c5cc5..89ccf90 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -4349,18 +4349,6 @@ extern bfd_boolean bfd_elf64_archive_write_armap
 #undef	ELF_OSABI
 #define	ELF_OSABI			ELFOSABI_FREEBSD
 
-/* The kernel recognizes executables as valid only if they carry a
-   "FreeBSD" label in the ELF header.  So we put this label on all
-   executables and (for simplicity) also all other object files.  */
-
-static void
-elf_fbsd_post_process_headers (bfd *abfd, struct bfd_link_info *info)
-{
-  _bfd_elf_set_osabi (abfd, info);
-}
-
-#undef	elf_backend_post_process_headers
-#define	elf_backend_post_process_headers	elf_fbsd_post_process_headers
 #undef	elf64_bed
 #define elf64_bed				elf64_fbsd_tradbed
 
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index f30c009..ed1afdc 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -118,7 +118,6 @@ static bfd_vma opd_entry_value
 #define elf_backend_finish_dynamic_sections   ppc64_elf_finish_dynamic_sections
 #define elf_backend_link_output_symbol_hook   ppc64_elf_output_symbol_hook
 #define elf_backend_special_sections	      ppc64_elf_special_sections
-#define elf_backend_post_process_headers      _bfd_elf_set_osabi
 #define elf_backend_merge_symbol_attribute    ppc64_elf_merge_symbol_attribute
 
 /* The name of the dynamic interpreter.  This is put in the .interp
diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c
index 65e3907..2a27bbd 100644
--- a/bfd/elf64-sparc.c
+++ b/bfd/elf64-sparc.c
@@ -922,8 +922,6 @@ const struct elf_size_info elf64_sparc_size_info =
 /* Section 5.2.4 of the ABI specifies a 256-byte boundary for the table.  */
 #define elf_backend_plt_alignment 8
 
-#define elf_backend_post_process_headers	_bfd_elf_set_osabi
-
 #include "elf64-target.h"
 
 /* FreeBSD support */
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 860546e..edee8ec 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -5319,8 +5319,6 @@ static const struct bfd_elf_special_section
 #define elf_backend_hash_symbol \
   elf_x86_64_hash_symbol
 
-#define elf_backend_post_process_headers  _bfd_elf_set_osabi
-
 #include "elf64-target.h"
 
 /* FreeBSD support.  */
diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c
index 2daf79e..290bb83 100644
--- a/bfd/elfn32-mips.c
+++ b/bfd/elfn32-mips.c
@@ -3541,18 +3541,6 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
 #undef	ELF_OSABI
 #define	ELF_OSABI			ELFOSABI_FREEBSD
 
-/* The kernel recognizes executables as valid only if they carry a
-   "FreeBSD" label in the ELF header.  So we put this label on all
-   executables and (for simplicity) also all other object files.  */
-
-static void
-elf_fbsd_post_process_headers (bfd *abfd, struct bfd_link_info *info)
-{
-  _bfd_elf_set_osabi (abfd, info);
-}
-
-#undef	elf_backend_post_process_headers
-#define	elf_backend_post_process_headers	elf_fbsd_post_process_headers
 #undef	elf32_bed
 #define elf32_bed				elf32_fbsd_tradbed
 
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 6a42bc5..8dc2fdf 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -5504,7 +5504,7 @@ elfNN_aarch64_post_process_headers (bfd *abfd,
   i_ehdrp = elf_elfheader (abfd);
   i_ehdrp->e_ident[EI_ABIVERSION] = AARCH64_ELF_ABI_VERSION;
 
-  _bfd_elf_set_osabi (abfd, link_info);
+  _bfd_elf_post_process_headers (abfd, link_info);
 }
 
 static enum elf_reloc_type_class
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index d42ce26..2e7cbca 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -498,7 +498,7 @@
 #define elf_backend_static_tls_alignment	1
 #endif
 #ifndef elf_backend_post_process_headers
-#define elf_backend_post_process_headers	NULL
+#define elf_backend_post_process_headers	_bfd_elf_post_process_headers
 #endif
 #ifndef elf_backend_print_symbol_all
 #define elf_backend_print_symbol_all		NULL
-- 
1.8.3.1



More information about the Binutils mailing list