aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog64
-rw-r--r--bfd/elf-bfd.h18
-rw-r--r--bfd/elf-hppa.h4
-rw-r--r--bfd/elf-m10300.c4
-rw-r--r--bfd/elf-nacl.c3
-rw-r--r--bfd/elf-vxworks.c4
-rw-r--r--bfd/elf.c20
-rw-r--r--bfd/elf32-arc.c4
-rw-r--r--bfd/elf32-arm.c13
-rw-r--r--bfd/elf32-avr.c4
-rw-r--r--bfd/elf32-bfin.c4
-rw-r--r--bfd/elf32-cr16.c6
-rw-r--r--bfd/elf32-cris.c4
-rw-r--r--bfd/elf32-d10v.c1
-rw-r--r--bfd/elf32-d30v.c1
-rw-r--r--bfd/elf32-h8300.c5
-rw-r--r--bfd/elf32-i386.c4
-rw-r--r--bfd/elf32-lm32.c3
-rw-r--r--bfd/elf32-m32r.c4
-rw-r--r--bfd/elf32-m68hc11.c1
-rw-r--r--bfd/elf32-m68hc12.c1
-rw-r--r--bfd/elf32-m68k.c4
-rw-r--r--bfd/elf32-mips.c2
-rw-r--r--bfd/elf32-msp430.c4
-rw-r--r--bfd/elf32-nds32.c4
-rw-r--r--bfd/elf32-or1k.c4
-rw-r--r--bfd/elf32-pj.c4
-rw-r--r--bfd/elf32-ppc.c11
-rw-r--r--bfd/elf32-s12z.c1
-rw-r--r--bfd/elf32-sparc.c12
-rw-r--r--bfd/elf32-v850.c4
-rw-r--r--bfd/elf32-xc16x.c4
-rw-r--r--bfd/elf32-xtensa.c4
-rw-r--r--bfd/elf64-ia64-vms.c4
-rw-r--r--bfd/elf64-x86-64.c4
-rw-r--r--bfd/elflink.c17
-rw-r--r--bfd/elfnn-ia64.c4
-rw-r--r--bfd/elfxx-mips.c11
-rw-r--r--bfd/elfxx-mips.h2
-rw-r--r--bfd/elfxx-target.h2
40 files changed, 175 insertions, 99 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 2beeb3d..3a19099 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,67 @@
+2019-07-23 Alan Modra <amodra@gmail.com>
+
+ * elf-bfd.h (enum elf_gnu_osabi): Rename from elf_gnu_symbols.
+ Remove none, any, all enums.
+ (struct elf_obj_tdata): Rename has_gnu_symbols field to has_gnu_osabi.
+ (_bfd_elf_final_write_processing): Declare.
+ * elf.c (_bfd_elf_write_object_contents): Unconditionally call
+ elf_backend_final_write_processing.
+ (_bfd_elf_post_process_headers): Move body of function to..
+ (_bfd_elf_final_write_processing): ..here, but set EI_OSABI byte
+ only when not already set. Adjust for rename.
+ * elfxx-target.h (elf_backend_final_write_processing): Default to
+ _bfd_elf_final_write_processing.
+ * elf-hppa.h (elf_hppa_final_write_processing): Call
+ _bfd_elf_final_write_processing.
+ * elf-m10300.c (_bfd_mn10300_elf_final_write_processing): Likewise.
+ * elf-nacl.c (nacl_final_write_processing): Likewise.
+ * elf-vxworks.c (elf_vxworks_final_write_processing): Likewise.
+ * elf32-arc.c (arc_elf_final_write_processing): Likewise.
+ * elf32-avr.c (bfd_elf_avr_final_write_processing): Likewise.
+ * elf32-bfin.c (elf32_bfin_final_write_processing): Likewise.
+ * elf32-cr16.c (_bfd_cr16_elf_final_write_processing): Likewise.
+ * elf32-cris.c (cris_elf_final_write_processing): Likewise.
+ * elf32-h8300.c (elf32_h8_final_write_processing): Likewise.
+ * elf32-lm32.c (lm32_elf_final_write_processing): Likewise.
+ * elf32-m32r.c (m32r_elf_final_write_processing): Likewise.
+ * elf32-m68k.c (elf_m68k_final_write_processing): Likewise.
+ * elf32-msp430.c (bfd_elf_msp430_final_write_processing): Likewise.
+ * elf32-nds32.c (nds32_elf_final_write_processing): Likewise.
+ * elf32-or1k.c (or1k_elf_final_write_processing): Likewise.
+ * elf32-pj.c (pj_elf_final_write_processing): Likewise.
+ * elf32-v850.c (v850_elf_final_write_processing): Likewise.
+ * elf32-xc16x.c (elf32_xc16x_final_write_processing): Likewise.
+ * elf32-xtensa.c (elf_xtensa_final_write_processing): Likewise.
+ * elf64-ia64-vms.c (elf64_vms_final_write_processing): Likewise.
+ * elfnn-ia64.c (elfNN_ia64_final_write_processing): Likewise.
+ * elf32-arm.c (arm_final_write_processing): Split out from..
+ (elf32_arm_final_write_processing): ..here. Call
+ _bfd_elf_final_write_processing.
+ (elf32_arm_nacl_final_write_processing): Adjust.
+ * elfxx-mips.c (_bfd_mips_final_write_processing): Split out from..
+ (_bfd_mips_elf_final_write_processing): ..here. Call
+ _bfd_elf_final_write_processing.
+ * elfxx-mips.h (_bfd_mips_final_write_processing): Declare.
+ * elf32-mips.c (mips_vxworks_final_write_processing): Adjust.
+ * elf32-ppc.c (ppc_final_write_processing): Split out from..
+ (ppc_elf_final_write_processing): ..here. Call
+ _bfd_elf_final_write_processing.
+ (ppc_elf_vxworks_final_write_processing): Adjust.
+ * elf32-sparc.c (sparc_final_write_processing): Split out from..
+ (elf32_sparc_final_write_processing): ..here. Call
+ _bfd_elf_final_write_processing.
+ (elf32_sparc_vxworks_final_write_processing): Adjust.
+ * elf32-d10v.c (elf_backend_final_write_processing): Don't define.
+ * elf32-d30v.c (elf_backend_final_write_processing): Don't define.
+ * elf32-m68hc11.c (elf_backend_final_write_processing): Don't define.
+ * elf32-m68hc12.c (elf_backend_final_write_processing): Don't define.
+ * elf32-s12z.c (elf_backend_final_write_processing): Don't define.
+ * elf32-i386.c (elf_i386_check_relocs): Don't set has_gnu_symbols.
+ * elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
+ * elflink.c (elf_link_add_object_symbols): Likewise.
+ (elf_link_output_symstrtab): Set has_gnu_osabi for symbols here
+ instead.
+
2019-07-23 Omar Majid <omajid@redhat.com>
* coffcode.h (coff_set_arch_mach_hook): Handle I386_APPLE_MAGIC,
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index a6a831b..134496e 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1812,13 +1812,10 @@ struct output_elf_obj_tdata
/* Indicate if the bfd contains symbols that have the STT_GNU_IFUNC
symbol type or STB_GNU_UNIQUE binding. Used to set the osabi
field in the ELF header structure. */
-enum elf_gnu_symbols
+enum elf_gnu_osabi
{
- elf_gnu_symbol_none = 0,
- elf_gnu_symbol_any = 1 << 0,
- elf_gnu_symbol_ifunc = (elf_gnu_symbol_any | 1 << 1),
- elf_gnu_symbol_unique = (elf_gnu_symbol_any | 1 << 2),
- elf_gnu_symbol_all = (elf_gnu_symbol_ifunc | elf_gnu_symbol_unique)
+ elf_gnu_osabi_ifunc = 1 << 1,
+ elf_gnu_osabi_unique = 1 << 2,
};
typedef struct elf_section_list
@@ -1939,9 +1936,8 @@ struct elf_obj_tdata
or was found via a DT_NEEDED entry. */
ENUM_BITFIELD (dynamic_lib_link_class) dyn_lib_class : 4;
- /* Whether if the bfd contains symbols that have the STT_GNU_IFUNC
- symbol type or STB_GNU_UNIQUE binding. */
- ENUM_BITFIELD (elf_gnu_symbols) has_gnu_symbols : 3;
+ /* Whether the bfd uses OS specific bits that require ELFOSABI_GNU. */
+ ENUM_BITFIELD (elf_gnu_osabi) has_gnu_osabi : 3;
/* Whether if the bfd contains the GNU_PROPERTY_NO_COPY_ON_PROTECTED
property. */
@@ -2336,7 +2332,9 @@ extern bfd_boolean _bfd_elf_setup_sections
extern struct bfd_link_hash_entry *bfd_elf_define_start_stop
(struct bfd_link_info *, const char *, asection *);
-extern void _bfd_elf_post_process_headers (bfd * , struct bfd_link_info *);
+extern void _bfd_elf_post_process_headers (bfd *, struct bfd_link_info *);
+
+extern void _bfd_elf_final_write_processing (bfd *, bfd_boolean);
extern const bfd_target *bfd_elf32_object_p
(bfd *);
diff --git a/bfd/elf-hppa.h b/bfd/elf-hppa.h
index 1013813..45b432e 100644
--- a/bfd/elf-hppa.h
+++ b/bfd/elf-hppa.h
@@ -924,8 +924,7 @@ elf_hppa_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec)
}
static void
-elf_hppa_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+elf_hppa_final_write_processing (bfd *abfd, bfd_boolean linker)
{
int mach = bfd_get_mach (abfd);
@@ -948,6 +947,7 @@ elf_hppa_final_write_processing (bfd *abfd,
a step backwards with the ELF
based toolchains. */
| EF_PARISC_TRAPNIL);
+ _bfd_elf_final_write_processing (abfd, linker);
}
/* Comparison function for qsort to sort unwind section during a
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index f0ef8eb..e497e02 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -4668,8 +4668,7 @@ elf_mn10300_mach (flagword flags)
number. */
static void
-_bfd_mn10300_elf_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+_bfd_mn10300_elf_final_write_processing (bfd *abfd, bfd_boolean linker)
{
unsigned long val;
@@ -4691,6 +4690,7 @@ _bfd_mn10300_elf_final_write_processing (bfd *abfd,
elf_elfheader (abfd)->e_flags &= ~ (EF_MN10300_MACH);
elf_elfheader (abfd)->e_flags |= val;
+ _bfd_elf_final_write_processing (abfd, linker);
}
static bfd_boolean
diff --git a/bfd/elf-nacl.c b/bfd/elf-nacl.c
index 3f0c813..5f80806 100644
--- a/bfd/elf-nacl.c
+++ b/bfd/elf-nacl.c
@@ -321,7 +321,7 @@ nacl_modify_program_headers (bfd *abfd, struct bfd_link_info *info)
}
void
-nacl_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED)
+nacl_final_write_processing (bfd *abfd, bfd_boolean linker)
{
struct elf_segment_map *seg;
for (seg = elf_seg_map (abfd); seg != NULL; seg = seg->next)
@@ -354,4 +354,5 @@ nacl_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED)
free (fill);
}
+ _bfd_elf_final_write_processing (abfd, linker);
}
diff --git a/bfd/elf-vxworks.c b/bfd/elf-vxworks.c
index 08c4b16..32eb5a9 100644
--- a/bfd/elf-vxworks.c
+++ b/bfd/elf-vxworks.c
@@ -213,8 +213,7 @@ elf_vxworks_emit_relocs (bfd *output_bfd,
/* Set the sh_link and sh_info fields on the static plt relocation secton. */
void
-elf_vxworks_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+elf_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
{
asection * sec;
struct bfd_elf_section_data *d;
@@ -229,6 +228,7 @@ elf_vxworks_final_write_processing (bfd *abfd,
sec = bfd_get_section_by_name (abfd, ".plt");
if (sec)
d->this_hdr.sh_info = elf_section_data (sec)->this_idx;
+ _bfd_elf_final_write_processing (abfd, linker);
}
/* Add the dynamic entries required by VxWorks. These point to the
diff --git a/bfd/elf.c b/bfd/elf.c
index 265150d..55bb091 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -6553,8 +6553,7 @@ _bfd_elf_write_object_contents (bfd *abfd)
|| !_bfd_elf_strtab_emit (abfd, elf_shstrtab (abfd))))
return FALSE;
- if (bed->elf_backend_final_write_processing)
- (*bed->elf_backend_final_write_processing) (abfd, elf_linker (abfd));
+ (*bed->elf_backend_final_write_processing) (abfd, elf_linker (abfd));
if (!bed->s->write_shdrs_and_ehdr (abfd))
return FALSE;
@@ -12103,20 +12102,27 @@ asection _bfd_elf_large_com_section
"LARGE_COMMON", 0, SEC_IS_COMMON);
void
-_bfd_elf_post_process_headers (bfd * abfd,
- struct bfd_link_info * link_info ATTRIBUTE_UNUSED)
+_bfd_elf_post_process_headers (bfd *abfd ATTRIBUTE_UNUSED,
+ struct bfd_link_info *info ATTRIBUTE_UNUSED)
{
- Elf_Internal_Ehdr * i_ehdrp; /* ELF file header, internal form. */
+}
+
+void
+_bfd_elf_final_write_processing (bfd *abfd,
+ bfd_boolean linker ATTRIBUTE_UNUSED)
+{
+ Elf_Internal_Ehdr *i_ehdrp; /* ELF file header, internal form. */
i_ehdrp = elf_elfheader (abfd);
- i_ehdrp->e_ident[EI_OSABI] = get_elf_backend_data (abfd)->elf_osabi;
+ if (i_ehdrp->e_ident[EI_OSABI] == ELFOSABI_NONE)
+ i_ehdrp->e_ident[EI_OSABI] = get_elf_backend_data (abfd)->elf_osabi;
/* To make things simpler for the loader on Linux systems we set the
osabi field to ELFOSABI_GNU if the binary contains symbols of
the STT_GNU_IFUNC type or STB_GNU_UNIQUE binding. */
if (i_ehdrp->e_ident[EI_OSABI] == ELFOSABI_NONE
- && elf_tdata (abfd)->has_gnu_symbols)
+ && elf_tdata (abfd)->has_gnu_osabi)
i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_GNU;
}
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index b86dd59..ad5757a 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -1017,8 +1017,7 @@ arc_elf_object_p (bfd * abfd)
This gets the ARC architecture right based on the machine number. */
static void
-arc_elf_final_write_processing (bfd * abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+arc_elf_final_write_processing (bfd *abfd, bfd_boolean linker)
{
unsigned long emf;
int osver = bfd_elf_get_obj_attr_int (abfd, OBJ_ATTR_PROC,
@@ -1052,6 +1051,7 @@ arc_elf_final_write_processing (bfd * abfd,
e_flags |= E_ARC_OSABI_V3;
elf_elfheader (abfd)->e_flags |= e_flags;
+ _bfd_elf_final_write_processing (abfd, linker);
}
#ifdef ARC_ENABLE_DEBUG
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 6b689769..6313949 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -17915,11 +17915,18 @@ elf32_arm_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
}
static void
-elf32_arm_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED)
+arm_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED)
{
bfd_arm_update_notes (abfd, ARM_NOTE_SECTION);
}
+static void
+elf32_arm_final_write_processing (bfd *abfd, bfd_boolean linker)
+{
+ arm_final_write_processing (abfd, linker);
+ _bfd_elf_final_write_processing (abfd, linker);
+}
+
/* Return TRUE if this is an unwinding table entry. */
static bfd_boolean
@@ -20596,7 +20603,7 @@ elf32_arm_nacl_modify_segment_map (bfd *abfd, struct bfd_link_info *info)
static void
elf32_arm_nacl_final_write_processing (bfd *abfd, bfd_boolean linker)
{
- elf32_arm_final_write_processing (abfd, linker);
+ arm_final_write_processing (abfd, linker);
nacl_final_write_processing (abfd, linker);
}
@@ -20751,7 +20758,7 @@ elf32_arm_vxworks_link_hash_table_create (bfd *abfd)
static void
elf32_arm_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
{
- elf32_arm_final_write_processing (abfd, linker);
+ arm_final_write_processing (abfd, linker);
elf_vxworks_final_write_processing (abfd, linker);
}
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index 34ad423..135030b 100644
--- a/bfd/elf32-avr.c
+++ b/bfd/elf32-avr.c
@@ -1537,8 +1537,7 @@ elf32_avr_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
number. */
static void
-bfd_elf_avr_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+bfd_elf_avr_final_write_processing (bfd *abfd, bfd_boolean linker)
{
unsigned long val;
@@ -1621,6 +1620,7 @@ bfd_elf_avr_final_write_processing (bfd *abfd,
elf_elfheader (abfd)->e_machine = EM_AVR;
elf_elfheader (abfd)->e_flags &= ~ EF_AVR_MACH;
elf_elfheader (abfd)->e_flags |= val;
+ _bfd_elf_final_write_processing (abfd, linker);
}
/* Set the right machine number. */
diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c
index db052a1..5b8f5b9 100644
--- a/bfd/elf32-bfin.c
+++ b/bfd/elf32-bfin.c
@@ -1134,13 +1134,13 @@ bfd_boolean elf32_bfin_code_in_l1 = 0;
bfd_boolean elf32_bfin_data_in_l1 = 0;
static void
-elf32_bfin_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+elf32_bfin_final_write_processing (bfd *abfd, bfd_boolean linker)
{
if (elf32_bfin_code_in_l1)
elf_elfheader (abfd)->e_flags |= EF_BFIN_CODE_IN_L1;
if (elf32_bfin_data_in_l1)
elf_elfheader (abfd)->e_flags |= EF_BFIN_DATA_IN_L1;
+ _bfd_elf_final_write_processing (abfd, linker);
}
/* Return TRUE if the name is a local label.
diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c
index a3fbb4f..3569c81 100644
--- a/bfd/elf32-cr16.c
+++ b/bfd/elf32-cr16.c
@@ -1674,8 +1674,7 @@ elf_cr16_mach (flagword flags)
number. */
static void
-_bfd_cr16_elf_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+_bfd_cr16_elf_final_write_processing (bfd *abfd, bfd_boolean linker)
{
unsigned long val;
switch (bfd_get_mach (abfd))
@@ -1685,9 +1684,8 @@ _bfd_cr16_elf_final_write_processing (bfd *abfd,
val = EM_CR16;
break;
}
-
-
elf_elfheader (abfd)->e_flags |= val;
+ _bfd_elf_final_write_processing (abfd, linker);
}
diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c
index 595c36b..0fc1eb38 100644
--- a/bfd/elf32-cris.c
+++ b/bfd/elf32-cris.c
@@ -3830,8 +3830,7 @@ cris_elf_object_p (bfd *abfd)
flags from mach type. */
static void
-cris_elf_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+cris_elf_final_write_processing (bfd *abfd, bfd_boolean linker)
{
unsigned long e_flags = elf_elfheader (abfd)->e_flags;
@@ -3859,6 +3858,7 @@ cris_elf_final_write_processing (bfd *abfd,
}
elf_elfheader (abfd)->e_flags = e_flags;
+ _bfd_elf_final_write_processing (abfd, linker);
}
/* Set the mach type from e_flags value. */
diff --git a/bfd/elf32-d10v.c b/bfd/elf32-d10v.c
index 4cd0aec..a03ce63 100644
--- a/bfd/elf32-d10v.c
+++ b/bfd/elf32-d10v.c
@@ -543,7 +543,6 @@ elf32_d10v_relocate_section (bfd *output_bfd,
#define elf_info_to_howto NULL
#define elf_info_to_howto_rel d10v_info_to_howto_rel
#define elf_backend_object_p 0
-#define elf_backend_final_write_processing 0
#define elf_backend_gc_mark_hook elf32_d10v_gc_mark_hook
#define elf_backend_check_relocs elf32_d10v_check_relocs
#define elf_backend_relocate_section elf32_d10v_relocate_section
diff --git a/bfd/elf32-d30v.c b/bfd/elf32-d30v.c
index 975dbc4..f006b66 100644
--- a/bfd/elf32-d30v.c
+++ b/bfd/elf32-d30v.c
@@ -561,6 +561,5 @@ d30v_info_to_howto_rela (bfd *abfd,
#define elf_info_to_howto d30v_info_to_howto_rela
#define elf_info_to_howto_rel d30v_info_to_howto_rel
#define elf_backend_object_p 0
-#define elf_backend_final_write_processing 0
#include "elf32-target.h"
diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c
index fe1de98..40680fa 100644
--- a/bfd/elf32-h8300.c
+++ b/bfd/elf32-h8300.c
@@ -31,7 +31,6 @@ static bfd_boolean elf32_h8_info_to_howto
static bfd_boolean elf32_h8_info_to_howto_rel
(bfd *, arelent *, Elf_Internal_Rela *);
static unsigned long elf32_h8_mach (flagword);
-static void elf32_h8_final_write_processing (bfd *, bfd_boolean);
static bfd_boolean elf32_h8_object_p (bfd *);
static bfd_boolean elf32_h8_merge_private_bfd_data
(bfd *, struct bfd_link_info *);
@@ -585,8 +584,7 @@ elf32_h8_mach (flagword flags)
into the flags field in the object file. */
static void
-elf32_h8_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+elf32_h8_final_write_processing (bfd *abfd, bfd_boolean linker)
{
unsigned long val;
@@ -624,6 +622,7 @@ elf32_h8_final_write_processing (bfd *abfd,
elf_elfheader (abfd)->e_flags &= ~ (EF_H8_MACH);
elf_elfheader (abfd)->e_flags |= val;
+ _bfd_elf_final_write_processing (abfd, linker);
}
/* Return nonzero if ABFD represents a valid H8 ELF object file; also
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index d2ea5a7..d7a61d7 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1575,10 +1575,6 @@ elf_i386_check_relocs (bfd *abfd,
/* It is referenced by a non-shared object. */
h->ref_regular = 1;
-
- if (h->type == STT_GNU_IFUNC)
- elf_tdata (info->output_bfd)->has_gnu_symbols
- |= elf_gnu_symbol_ifunc;
}
if (r_type == R_386_GOT32X
diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c
index 2428764..255dc4e 100644
--- a/bfd/elf32-lm32.c
+++ b/bfd/elf32-lm32.c
@@ -556,7 +556,7 @@ lm32_elf_object_p (bfd *abfd)
/* Set machine type flags just before file is written out. */
static void
-lm32_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED)
+lm32_elf_final_write_processing (bfd *abfd, bfd_boolean linker)
{
elf_elfheader (abfd)->e_machine = EM_LATTICEMICO32;
elf_elfheader (abfd)->e_flags &=~ EF_LM32_MACH;
@@ -568,6 +568,7 @@ lm32_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED)
default:
abort ();
}
+ _bfd_elf_final_write_processing (abfd, linker);
}
/* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c
index 8f05a5e..3fcde4a 100644
--- a/bfd/elf32-m32r.c
+++ b/bfd/elf32-m32r.c
@@ -3404,8 +3404,7 @@ m32r_elf_object_p (bfd *abfd)
/* Store the machine number in the flags field. */
static void
-m32r_elf_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+m32r_elf_final_write_processing (bfd *abfd, bfd_boolean linker)
{
unsigned long val;
@@ -3419,6 +3418,7 @@ m32r_elf_final_write_processing (bfd *abfd,
elf_elfheader (abfd)->e_flags &=~ EF_M32R_ARCH;
elf_elfheader (abfd)->e_flags |= val;
+ _bfd_elf_final_write_processing (abfd, linker);
}
/* Function to keep M32R specific file flags. */
diff --git a/bfd/elf32-m68hc11.c b/bfd/elf32-m68hc11.c
index fe5d8ba..828a432 100644
--- a/bfd/elf32-m68hc11.c
+++ b/bfd/elf32-m68hc11.c
@@ -1306,7 +1306,6 @@ static const struct bfd_elf_special_section elf32_m68hc11_special_sections[] =
#define elf_backend_relocate_section elf32_m68hc11_relocate_section
#define elf_backend_add_symbol_hook elf32_m68hc11_add_symbol_hook
#define elf_backend_object_p 0
-#define elf_backend_final_write_processing 0
#define elf_backend_can_gc_sections 1
#define elf_backend_special_sections elf32_m68hc11_special_sections
#define elf_backend_merge_symbol_attribute elf32_m68hc11_merge_symbol_attribute
diff --git a/bfd/elf32-m68hc12.c b/bfd/elf32-m68hc12.c
index 2247edc..97c5132 100644
--- a/bfd/elf32-m68hc12.c
+++ b/bfd/elf32-m68hc12.c
@@ -654,7 +654,6 @@ static const struct bfd_elf_special_section elf32_m68hc12_special_sections[] =
#define elf_backend_check_relocs elf32_m68hc11_check_relocs
#define elf_backend_relocate_section elf32_m68hc11_relocate_section
#define elf_backend_object_p m68hc12_elf_set_mach_from_flags
-#define elf_backend_final_write_processing 0
#define elf_backend_can_gc_sections 1
#define elf_backend_special_sections elf32_m68hc12_special_sections
#define elf_backend_post_process_headers elf32_m68hc11_post_process_headers
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index 4efac79..3840b13 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -1054,8 +1054,7 @@ elf32_m68k_object_p (bfd *abfd)
field based on the machine number. */
static void
-elf_m68k_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+elf_m68k_final_write_processing (bfd *abfd, bfd_boolean linker)
{
int mach = bfd_get_mach (abfd);
unsigned long e_flags = elf_elfheader (abfd)->e_flags;
@@ -1108,6 +1107,7 @@ elf_m68k_final_write_processing (bfd *abfd,
}
elf_elfheader (abfd)->e_flags = e_flags;
}
+ _bfd_elf_final_write_processing (abfd, linker);
}
/* Keep m68k-specific flags in the ELF header. */
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index 69268b3..370dc90 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -2646,7 +2646,7 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
static void
mips_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
{
- _bfd_mips_elf_final_write_processing (abfd, linker);
+ _bfd_mips_final_write_processing (abfd, linker);
elf_vxworks_final_write_processing (abfd, linker);
}
diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c
index c0c626e..aecc122 100644
--- a/bfd/elf32-msp430.c
+++ b/bfd/elf32-msp430.c
@@ -1386,8 +1386,7 @@ elf32_msp430_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED,
number. */
static void
-bfd_elf_msp430_final_write_processing (bfd * abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+bfd_elf_msp430_final_write_processing (bfd *abfd, bfd_boolean linker)
{
unsigned long val;
@@ -1422,6 +1421,7 @@ bfd_elf_msp430_final_write_processing (bfd * abfd,
elf_elfheader (abfd)->e_machine = EM_MSP430;
elf_elfheader (abfd)->e_flags &= ~EF_MSP430_MACH;
elf_elfheader (abfd)->e_flags |= val;
+ _bfd_elf_final_write_processing (abfd, linker);
}
/* Set the right machine number. */
diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c
index d9a429d..9959cbe 100644
--- a/bfd/elf32-nds32.c
+++ b/bfd/elf32-nds32.c
@@ -6673,8 +6673,7 @@ nds32_elf_object_p (bfd *abfd)
/* Store the machine number in the flags field. */
static void
-nds32_elf_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+nds32_elf_final_write_processing (bfd *abfd, bfd_boolean linker)
{
unsigned long val;
static unsigned int cur_mach = 0;
@@ -6711,6 +6710,7 @@ nds32_elf_final_write_processing (bfd *abfd,
elf_elfheader (abfd)->e_flags &= ~EF_NDS_ARCH;
elf_elfheader (abfd)->e_flags |= val;
+ _bfd_elf_final_write_processing (abfd, linker);
}
/* Function to keep NDS32 specific file flags. */
diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
index c1bbac9..9b795fb 100644
--- a/bfd/elf32-or1k.c
+++ b/bfd/elf32-or1k.c
@@ -3157,8 +3157,7 @@ or1k_elf_object_p (bfd *abfd)
/* Store the machine number in the flags field. */
static void
-or1k_elf_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+or1k_elf_final_write_processing (bfd *abfd, bfd_boolean linker)
{
switch (bfd_get_mach (abfd))
{
@@ -3169,6 +3168,7 @@ or1k_elf_final_write_processing (bfd *abfd,
elf_elfheader (abfd)->e_flags |= EF_OR1K_NODELAY;
break;
}
+ _bfd_elf_final_write_processing (abfd, linker);
}
static bfd_boolean
diff --git a/bfd/elf32-pj.c b/bfd/elf32-pj.c
index c97d620..d4fcebc 100644
--- a/bfd/elf32-pj.c
+++ b/bfd/elf32-pj.c
@@ -337,11 +337,11 @@ pj_elf_info_to_howto (bfd *abfd,
e_flags field. */
static void
-pj_elf_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+pj_elf_final_write_processing (bfd *abfd, bfd_boolean linker)
{
elf_elfheader (abfd)->e_flags |= EF_PICOJAVA_ARCH;
elf_elfheader (abfd)->e_flags |= EF_PICOJAVA_GNUCALLS;
+ _bfd_elf_final_write_processing (abfd, linker);
}
#define TARGET_BIG_SYM pj_elf32_vec
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 8dfeca3..b1ae0de 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -1705,7 +1705,7 @@ ppc_elf_write_section (bfd *abfd ATTRIBUTE_UNUSED,
/* Finally we can generate the output section. */
static void
-ppc_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED)
+ppc_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED)
{
bfd_byte *buffer;
asection *asec;
@@ -1756,6 +1756,13 @@ ppc_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED)
apuinfo_list_finish ();
}
+
+static void
+ppc_elf_final_write_processing (bfd *abfd, bfd_boolean linker)
+{
+ ppc_final_write_processing (abfd, linker);
+ _bfd_elf_final_write_processing (abfd, linker);
+}
static bfd_boolean
is_nonpic_glink_stub (bfd *abfd, asection *glink, bfd_vma off)
@@ -10490,7 +10497,7 @@ ppc_elf_vxworks_add_symbol_hook (bfd *abfd,
static void
ppc_elf_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
{
- ppc_elf_final_write_processing (abfd, linker);
+ ppc_final_write_processing (abfd, linker);
elf_vxworks_final_write_processing (abfd, linker);
}
diff --git a/bfd/elf32-s12z.c b/bfd/elf32-s12z.c
index 60f163b..ba64985 100644
--- a/bfd/elf32-s12z.c
+++ b/bfd/elf32-s12z.c
@@ -317,6 +317,5 @@ s12z_elf_set_mach_from_flags (bfd *abfd)
#define elf_info_to_howto NULL
#define elf_info_to_howto_rel s12z_info_to_howto_rel
#define elf_backend_object_p s12z_elf_set_mach_from_flags
-#define elf_backend_final_write_processing NULL
#include "elf32-target.h"
diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
index f5c5863..e6d18d3 100644
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -117,8 +117,7 @@ elf32_sparc_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
We need to set the e_machine field appropriately. */
static void
-elf32_sparc_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+sparc_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED)
{
switch (bfd_get_mach (abfd))
{
@@ -157,6 +156,13 @@ elf32_sparc_final_write_processing (bfd *abfd,
}
}
+static void
+elf32_sparc_final_write_processing (bfd *abfd, bfd_boolean linker)
+{
+ sparc_final_write_processing (abfd, linker);
+ _bfd_elf_final_write_processing (abfd, linker);
+}
+
/* Used to decide how to sort relocs in an optimal manner for the
dynamic linker, before writing them out. */
@@ -324,7 +330,7 @@ elf32_sparc_vxworks_link_hash_table_create (bfd *abfd)
static void
elf32_sparc_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
{
- elf32_sparc_final_write_processing (abfd, linker);
+ sparc_final_write_processing (abfd, linker);
elf_vxworks_final_write_processing (abfd, linker);
}
diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c
index 90a18d3..14bffc2 100644
--- a/bfd/elf32-v850.c
+++ b/bfd/elf32-v850.c
@@ -2719,8 +2719,7 @@ v850_elf_object_p (bfd *abfd)
/* Store the machine number in the flags field. */
static void
-v850_elf_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+v850_elf_final_write_processing (bfd *abfd, bfd_boolean linker)
{
unsigned long val;
@@ -2750,6 +2749,7 @@ v850_elf_final_write_processing (bfd *abfd,
default:
break;
}
+ _bfd_elf_final_write_processing (abfd, linker);
}
/* Function to keep V850 specific file flags. */
diff --git a/bfd/elf32-xc16x.c b/bfd/elf32-xc16x.c
index dc45c57..ef2a5fe 100644
--- a/bfd/elf32-xc16x.c
+++ b/bfd/elf32-xc16x.c
@@ -417,8 +417,7 @@ elf32_xc16x_relocate_section (bfd *output_bfd,
static void
-elf32_xc16x_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+elf32_xc16x_final_write_processing (bfd *abfd, bfd_boolean linker)
{
unsigned long val;
@@ -439,6 +438,7 @@ elf32_xc16x_final_write_processing (bfd *abfd,
}
elf_elfheader (abfd)->e_flags |= val;
+ _bfd_elf_final_write_processing (abfd, linker);
}
static unsigned long
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 09625e6..66d23a8 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -3463,8 +3463,7 @@ elf_xtensa_object_p (bfd *abfd)
number. */
static void
-elf_xtensa_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+elf_xtensa_final_write_processing (bfd *abfd, bfd_boolean linker)
{
int mach;
unsigned long val;
@@ -3480,6 +3479,7 @@ elf_xtensa_final_write_processing (bfd *abfd,
elf_elfheader (abfd)->e_flags &= (~ EF_XTENSA_MACH);
elf_elfheader (abfd)->e_flags |= val;
+ _bfd_elf_final_write_processing (abfd, linker);
}
diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c
index 792b1cc..0c7144a 100644
--- a/bfd/elf64-ia64-vms.c
+++ b/bfd/elf64-ia64-vms.c
@@ -4660,8 +4660,7 @@ elf64_vms_section_processing (bfd *abfd ATTRIBUTE_UNUSED,
object file. */
static void
-elf64_vms_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+elf64_vms_final_write_processing (bfd *abfd, bfd_boolean linker)
{
Elf_Internal_Shdr *hdr;
asection *s;
@@ -4696,6 +4695,7 @@ elf64_vms_final_write_processing (bfd *abfd,
elf_elfheader (abfd)->e_flags = flags;
elf_flags_init (abfd) = TRUE;
}
+ _bfd_elf_final_write_processing (abfd, linker);
}
static bfd_boolean
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 2f69239..34180c7 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -1951,10 +1951,6 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
{
/* It is referenced by a non-shared object. */
h->ref_regular = 1;
-
- if (h->type == STT_GNU_IFUNC)
- elf_tdata (info->output_bfd)->has_gnu_symbols
- |= elf_gnu_symbol_ifunc;
}
converted_reloc = FALSE;
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 9175d3f..2830ee3 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -4739,18 +4739,6 @@ error_free_dyn:
(struct bfd_link_hash_entry **) sym_hash)))
goto error_free_vers;
- if ((abfd->flags & DYNAMIC) == 0
- && (bfd_get_flavour (info->output_bfd)
- == bfd_target_elf_flavour))
- {
- if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
- elf_tdata (info->output_bfd)->has_gnu_symbols
- |= elf_gnu_symbol_ifunc;
- if ((flags & BSF_GNU_UNIQUE))
- elf_tdata (info->output_bfd)->has_gnu_symbols
- |= elf_gnu_symbol_unique;
- }
-
h = *sym_hash;
/* We need to make sure that indirect symbol dynamic flags are
updated. */
@@ -9411,6 +9399,11 @@ elf_link_output_symstrtab (struct elf_final_link_info *flinfo,
return ret;
}
+ if (ELF_ST_TYPE (elfsym->st_info) == STT_GNU_IFUNC)
+ elf_tdata (flinfo->output_bfd)->has_gnu_osabi |= elf_gnu_osabi_ifunc;
+ if (ELF_ST_BIND (elfsym->st_info) == STB_GNU_UNIQUE)
+ elf_tdata (flinfo->output_bfd)->has_gnu_osabi |= elf_gnu_osabi_unique;
+
if (name == NULL
|| *name == '\0'
|| (input_sec->flags & SEC_EXCLUDE))
diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c
index a80e5b8..1c9a904 100644
--- a/bfd/elfnn-ia64.c
+++ b/bfd/elfnn-ia64.c
@@ -1003,8 +1003,7 @@ elfNN_ia64_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr,
object file. */
static void
-elfNN_ia64_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+elfNN_ia64_final_write_processing (bfd *abfd, bfd_boolean linker)
{
Elf_Internal_Shdr *hdr;
asection *s;
@@ -1036,6 +1035,7 @@ elfNN_ia64_final_write_processing (bfd *abfd,
elf_elfheader(abfd)->e_flags = flags;
elf_flags_init (abfd) = TRUE;
}
+ _bfd_elf_final_write_processing (abfd, linker);
}
/* Hook called by the linker routine which adds symbols from an object
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 55f891d..f0c092c 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -12358,8 +12358,8 @@ _bfd_mips_elf_sort_relocs_p (asection *sec)
number. This is used by both the 32-bit and the 64-bit ABI. */
void
-_bfd_mips_elf_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+_bfd_mips_final_write_processing (bfd *abfd,
+ bfd_boolean linker ATTRIBUTE_UNUSED)
{
unsigned int i;
Elf_Internal_Shdr **hdrpp;
@@ -12438,6 +12438,13 @@ _bfd_mips_elf_final_write_processing (bfd *abfd,
}
}
}
+
+void
+_bfd_mips_elf_final_write_processing (bfd *abfd, bfd_boolean linker)
+{
+ _bfd_mips_final_write_processing (abfd, linker);
+ _bfd_elf_final_write_processing (abfd, linker);
+}
/* When creating an IRIX5 executable, we need REGINFO and RTPROC
segments. */
diff --git a/bfd/elfxx-mips.h b/bfd/elfxx-mips.h
index acd9d79..a76680a 100644
--- a/bfd/elfxx-mips.h
+++ b/bfd/elfxx-mips.h
@@ -69,6 +69,8 @@ extern bfd_boolean _bfd_mips_elf_finish_dynamic_sections
(bfd *, struct bfd_link_info *);
extern bfd_boolean _bfd_mips_elf_sort_relocs_p
(asection *);
+extern void _bfd_mips_final_write_processing
+ (bfd *, bfd_boolean);
extern void _bfd_mips_elf_final_write_processing
(bfd *, bfd_boolean);
extern int _bfd_mips_elf_additional_program_headers
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index e4e7546..aecc60f 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -497,7 +497,7 @@
#define elf_backend_begin_write_processing 0
#endif
#ifndef elf_backend_final_write_processing
-#define elf_backend_final_write_processing 0
+#define elf_backend_final_write_processing _bfd_elf_final_write_processing
#endif
#ifndef elf_backend_additional_program_headers
#define elf_backend_additional_program_headers 0