From cc364be6ff45669150077387f22723de33d5f1b1 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 24 Jul 2019 09:43:30 +0930 Subject: [PATCH] Complain about mbind, ifunc, and unique in final_write It's not as good as complaining in gas/config/obj-elf.c since you lose any reference to the source file. bfd/ * elf-bfd.h (struct elf_backend_data): Return bfd_boolean from elf_backend_final_write_processing, don't pass linker arg. (_bfd_elf_final_write_processing): Update prototype. * elf.c (_bfd_elf_write_object_contents): Adjust call. (_bfd_elf_final_write_processing): Return error on incompatible OSABI and has_gnu_osabi. Remove linker arg. * elf-nacl.h (nacl_final_write_processing): Update prototype. * elf-vxworks.h (elf_vxworks_final_write_processing): Likewise. * elfxx-mips.h (_bfd_mips_final_write_processing): Likewise. (_bfd_mips_elf_final_write_processing): Likewise. * elf-hppa.h (elf_hppa_final_write_processing): Return status and remove linker arg. * 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-arm.c (arm_final_write_processing): Likewise. (elf32_arm_final_write_processing): Likewise. (elf32_arm_nacl_final_write_processing): Likewise. (elf32_arm_vxworks_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-mips.c (mips_vxworks_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-ppc.c (ppc_final_write_processing): Likewise. (ppc_elf_final_write_processing): Likewise. (ppc_elf_vxworks_final_write_processing): Likewise. * elf32-sparc.c (sparc_final_write_processing): Likewise. (elf32_sparc_final_write_processing): Likewise. (elf32_sparc_vxworks_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. * elfxx-mips.c (_bfd_mips_final_write_processing): Likewise. (_bfd_mips_elf_final_write_processing): Likewise. gas/ * config/obj-elf.c (obj_elf_section, obj_elf_type): Set has_gnu_osabi. * testsuite/gas/elf/section12a.d: Update xfails. * testsuite/gas/elf/section12b.d: Likewise. --- bfd/ChangeLog | 49 ++++++++++++++++++++++++++++++ bfd/elf-bfd.h | 9 +++--- bfd/elf-hppa.h | 6 ++-- bfd/elf-m10300.c | 6 ++-- bfd/elf-nacl.c | 6 ++-- bfd/elf-nacl.h | 2 +- bfd/elf-vxworks.c | 6 ++-- bfd/elf-vxworks.h | 2 +- bfd/elf.c | 29 +++++++++++++----- bfd/elf32-arc.c | 6 ++-- bfd/elf32-arm.c | 26 ++++++++-------- bfd/elf32-avr.c | 6 ++-- bfd/elf32-bfin.c | 6 ++-- bfd/elf32-cr16.c | 8 ++--- bfd/elf32-cris.c | 6 ++-- bfd/elf32-h8300.c | 6 ++-- bfd/elf32-lm32.c | 6 ++-- bfd/elf32-m32r.c | 6 ++-- bfd/elf32-m68k.c | 6 ++-- bfd/elf32-mips.c | 8 ++--- bfd/elf32-msp430.c | 6 ++-- bfd/elf32-nds32.c | 6 ++-- bfd/elf32-or1k.c | 6 ++-- bfd/elf32-pj.c | 6 ++-- bfd/elf32-ppc.c | 18 +++++------ bfd/elf32-sparc.c | 18 +++++------ bfd/elf32-v850.c | 6 ++-- bfd/elf32-xc16x.c | 6 ++-- bfd/elf32-xtensa.c | 6 ++-- bfd/elf64-ia64-vms.c | 6 ++-- bfd/elfnn-ia64.c | 6 ++-- bfd/elfxx-mips.c | 11 +++---- bfd/elfxx-mips.h | 6 ++-- gas/ChangeLog | 6 ++++ gas/config/obj-elf.c | 3 ++ gas/testsuite/gas/elf/section12a.d | 2 +- gas/testsuite/gas/elf/section12b.d | 2 +- 37 files changed, 198 insertions(+), 127 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 1fe3860d9f..6d7e42510a 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,52 @@ +2019-07-24 Alan Modra + + * elf-bfd.h (struct elf_backend_data): Return bfd_boolean from + elf_backend_final_write_processing, don't pass linker arg. + (_bfd_elf_final_write_processing): Update prototype. + * elf.c (_bfd_elf_write_object_contents): Adjust call. + (_bfd_elf_final_write_processing): Return error on incompatible + OSABI and has_gnu_osabi. Remove linker arg. + * elf-nacl.h (nacl_final_write_processing): Update prototype. + * elf-vxworks.h (elf_vxworks_final_write_processing): Likewise. + * elfxx-mips.h (_bfd_mips_final_write_processing): Likewise. + (_bfd_mips_elf_final_write_processing): Likewise. + * elf-hppa.h (elf_hppa_final_write_processing): Return status + and remove linker arg. + * 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-arm.c (arm_final_write_processing): Likewise. + (elf32_arm_final_write_processing): Likewise. + (elf32_arm_nacl_final_write_processing): Likewise. + (elf32_arm_vxworks_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-mips.c (mips_vxworks_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-ppc.c (ppc_final_write_processing): Likewise. + (ppc_elf_final_write_processing): Likewise. + (ppc_elf_vxworks_final_write_processing): Likewise. + * elf32-sparc.c (sparc_final_write_processing): Likewise. + (elf32_sparc_final_write_processing): Likewise. + (elf32_sparc_vxworks_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. + * elfxx-mips.c (_bfd_mips_final_write_processing): Likewise. + (_bfd_mips_elf_final_write_processing): Likewise. + 2019-07-24 Alan Modra * elf-vxworks.c (elf_vxworks_final_write_processing): Don't return diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 01beac6757..8b87c66d4a 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -1141,10 +1141,9 @@ struct elf_backend_data (bfd *, struct bfd_link_info *); /* A function to do any final processing needed for the ELF file - before writing it out. The LINKER argument is TRUE if this BFD - was created by the ELF backend linker. */ - void (*elf_backend_final_write_processing) - (bfd *, bfd_boolean linker); + before writing it out. */ + bfd_boolean (*elf_backend_final_write_processing) + (bfd *); /* This function is called by get_program_header_size. It should return the number of additional program segments which this BFD @@ -2335,7 +2334,7 @@ extern struct bfd_link_hash_entry *bfd_elf_define_start_stop extern void _bfd_elf_post_process_headers (bfd *, struct bfd_link_info *); -extern void _bfd_elf_final_write_processing (bfd *, bfd_boolean); +extern bfd_boolean _bfd_elf_final_write_processing (bfd *); extern const bfd_target *bfd_elf32_object_p (bfd *); diff --git a/bfd/elf-hppa.h b/bfd/elf-hppa.h index 45b432ee62..cc98caeeb0 100644 --- a/bfd/elf-hppa.h +++ b/bfd/elf-hppa.h @@ -923,8 +923,8 @@ elf_hppa_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec) return TRUE; } -static void -elf_hppa_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +elf_hppa_final_write_processing (bfd *abfd) { int mach = bfd_get_mach (abfd); @@ -947,7 +947,7 @@ elf_hppa_final_write_processing (bfd *abfd, bfd_boolean linker) a step backwards with the ELF based toolchains. */ | EF_PARISC_TRAPNIL); - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } /* Comparison function for qsort to sort unwind section during a diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index e497e02b0d..acc3c54258 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -4667,8 +4667,8 @@ elf_mn10300_mach (flagword flags) file. This gets the MN10300 architecture right based on the machine number. */ -static void -_bfd_mn10300_elf_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +_bfd_mn10300_elf_final_write_processing (bfd *abfd) { unsigned long val; @@ -4690,7 +4690,7 @@ _bfd_mn10300_elf_final_write_processing (bfd *abfd, bfd_boolean linker) elf_elfheader (abfd)->e_flags &= ~ (EF_MN10300_MACH); elf_elfheader (abfd)->e_flags |= val; - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } static bfd_boolean diff --git a/bfd/elf-nacl.c b/bfd/elf-nacl.c index 5f80806691..58eebf6d75 100644 --- a/bfd/elf-nacl.c +++ b/bfd/elf-nacl.c @@ -320,8 +320,8 @@ nacl_modify_program_headers (bfd *abfd, struct bfd_link_info *info) return TRUE; } -void -nacl_final_write_processing (bfd *abfd, bfd_boolean linker) +bfd_boolean +nacl_final_write_processing (bfd *abfd) { struct elf_segment_map *seg; for (seg = elf_seg_map (abfd); seg != NULL; seg = seg->next) @@ -354,5 +354,5 @@ nacl_final_write_processing (bfd *abfd, bfd_boolean linker) free (fill); } - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } diff --git a/bfd/elf-nacl.h b/bfd/elf-nacl.h index 384e25fa24..ba28c570f9 100644 --- a/bfd/elf-nacl.h +++ b/bfd/elf-nacl.h @@ -18,4 +18,4 @@ bfd_boolean nacl_modify_segment_map (bfd *, struct bfd_link_info *); bfd_boolean nacl_modify_program_headers (bfd *, struct bfd_link_info *); -void nacl_final_write_processing (bfd *, bfd_boolean linker); +bfd_boolean nacl_final_write_processing (bfd *); diff --git a/bfd/elf-vxworks.c b/bfd/elf-vxworks.c index 4447b36511..a7f574c2ef 100644 --- a/bfd/elf-vxworks.c +++ b/bfd/elf-vxworks.c @@ -212,8 +212,8 @@ 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) +bfd_boolean +elf_vxworks_final_write_processing (bfd *abfd) { asection * sec; struct bfd_elf_section_data *d; @@ -229,7 +229,7 @@ elf_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker) if (sec) d->this_hdr.sh_info = elf_section_data (sec)->this_idx; } - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } /* Add the dynamic entries required by VxWorks. These point to the diff --git a/bfd/elf-vxworks.h b/bfd/elf-vxworks.h index c9aa490282..762dd8d135 100644 --- a/bfd/elf-vxworks.h +++ b/bfd/elf-vxworks.h @@ -28,7 +28,7 @@ bfd_boolean elf_vxworks_link_output_symbol_hook bfd_boolean elf_vxworks_emit_relocs (bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *, struct elf_link_hash_entry **); -void elf_vxworks_final_write_processing (bfd *, bfd_boolean); +bfd_boolean elf_vxworks_final_write_processing (bfd *); bfd_boolean elf_vxworks_create_dynamic_sections (bfd *, struct bfd_link_info *, asection **); bfd_boolean elf_vxworks_add_dynamic_entries (bfd *, struct bfd_link_info *); diff --git a/bfd/elf.c b/bfd/elf.c index 1c77a7917a..f47e88b2ac 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -6568,7 +6568,8 @@ _bfd_elf_write_object_contents (bfd *abfd) || !_bfd_elf_strtab_emit (abfd, elf_shstrtab (abfd)))) return FALSE; - (*bed->elf_backend_final_write_processing) (abfd, elf_linker (abfd)); + if (!(*bed->elf_backend_final_write_processing) (abfd)) + return FALSE; if (!bed->s->write_shdrs_and_ehdr (abfd)) return FALSE; @@ -12123,9 +12124,8 @@ _bfd_elf_post_process_headers (bfd *abfd ATTRIBUTE_UNUSED, { } -void -_bfd_elf_final_write_processing (bfd *abfd, - bfd_boolean linker ATTRIBUTE_UNUSED) +bfd_boolean +_bfd_elf_final_write_processing (bfd *abfd) { Elf_Internal_Ehdr *i_ehdrp; /* ELF file header, internal form. */ @@ -12137,9 +12137,24 @@ _bfd_elf_final_write_processing (bfd *abfd, /* Set the osabi field to ELFOSABI_GNU if the binary contains SHF_GNU_MBIND sections or symbols of STT_GNU_IFUNC type or STB_GNU_UNIQUE binding. */ - if (i_ehdrp->e_ident[EI_OSABI] == ELFOSABI_NONE - && elf_tdata (abfd)->has_gnu_osabi) - i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_GNU; + if (elf_tdata (abfd)->has_gnu_osabi != 0) + { + if (i_ehdrp->e_ident[EI_OSABI] == ELFOSABI_NONE) + i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_GNU; + else if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_GNU + && i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_FREEBSD) + { + if (elf_tdata (abfd)->has_gnu_osabi & elf_gnu_osabi_mbind) + _bfd_error_handler (_("GNU_MBIND section is unsupported")); + if (elf_tdata (abfd)->has_gnu_osabi & elf_gnu_osabi_ifunc) + _bfd_error_handler (_("symbol type STT_GNU_IFUNC is unsupported")); + if (elf_tdata (abfd)->has_gnu_osabi & elf_gnu_osabi_unique) + _bfd_error_handler (_("symbol binding STB_GNU_UNIQUE is unsupported")); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + } + return TRUE; } diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index fc4c3ae50a..c7ffc6a6f9 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -1016,8 +1016,8 @@ arc_elf_object_p (bfd * abfd) /* The final processing done just before writing out an ARC ELF object file. This gets the ARC architecture right based on the machine number. */ -static void -arc_elf_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +arc_elf_final_write_processing (bfd *abfd) { unsigned long emf; int osver = bfd_elf_get_obj_attr_int (abfd, OBJ_ATTR_PROC, @@ -1043,7 +1043,7 @@ arc_elf_final_write_processing (bfd *abfd, bfd_boolean linker) e_flags |= E_ARC_OSABI_V3; elf_elfheader (abfd)->e_flags |= e_flags; - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } #ifdef ARC_ENABLE_DEBUG diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 631394916b..15591bee8a 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -17915,16 +17915,16 @@ elf32_arm_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED, } static void -arm_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED) +arm_final_write_processing (bfd *abfd) { bfd_arm_update_notes (abfd, ARM_NOTE_SECTION); } -static void -elf32_arm_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +elf32_arm_final_write_processing (bfd *abfd) { - arm_final_write_processing (abfd, linker); - _bfd_elf_final_write_processing (abfd, linker); + arm_final_write_processing (abfd); + return _bfd_elf_final_write_processing (abfd); } /* Return TRUE if this is an unwinding table entry. */ @@ -20600,11 +20600,11 @@ elf32_arm_nacl_modify_segment_map (bfd *abfd, struct bfd_link_info *info) && nacl_modify_segment_map (abfd, info)); } -static void -elf32_arm_nacl_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +elf32_arm_nacl_final_write_processing (bfd *abfd) { - arm_final_write_processing (abfd, linker); - nacl_final_write_processing (abfd, linker); + arm_final_write_processing (abfd); + return nacl_final_write_processing (abfd); } static bfd_vma @@ -20755,11 +20755,11 @@ elf32_arm_vxworks_link_hash_table_create (bfd *abfd) return ret; } -static void -elf32_arm_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +elf32_arm_vxworks_final_write_processing (bfd *abfd) { - arm_final_write_processing (abfd, linker); - elf_vxworks_final_write_processing (abfd, linker); + arm_final_write_processing (abfd); + return elf_vxworks_final_write_processing (abfd); } #undef elf32_bed diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c index 135030b3aa..e75ac9fc1d 100644 --- a/bfd/elf32-avr.c +++ b/bfd/elf32-avr.c @@ -1536,8 +1536,8 @@ elf32_avr_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, file. This gets the AVR architecture right based on the machine number. */ -static void -bfd_elf_avr_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +bfd_elf_avr_final_write_processing (bfd *abfd) { unsigned long val; @@ -1620,7 +1620,7 @@ bfd_elf_avr_final_write_processing (bfd *abfd, bfd_boolean linker) 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); + return _bfd_elf_final_write_processing (abfd); } /* Set the right machine number. */ diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c index 5b8f5b9264..d73bfdaee3 100644 --- a/bfd/elf32-bfin.c +++ b/bfd/elf32-bfin.c @@ -1133,14 +1133,14 @@ bfd_boolean elf32_bfin_code_in_l1 = 0; /* Set by ld emulation if --data-in-l1. */ bfd_boolean elf32_bfin_data_in_l1 = 0; -static void -elf32_bfin_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +elf32_bfin_final_write_processing (bfd *abfd) { 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 _bfd_elf_final_write_processing (abfd); } /* Return TRUE if the name is a local label. diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c index 3569c81e0a..7d0a0e558f 100644 --- a/bfd/elf32-cr16.c +++ b/bfd/elf32-cr16.c @@ -1673,8 +1673,8 @@ elf_cr16_mach (flagword flags) file. This gets the CR16 architecture right based on the machine number. */ -static void -_bfd_cr16_elf_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +_bfd_cr16_elf_final_write_processing (bfd *abfd) { unsigned long val; switch (bfd_get_mach (abfd)) @@ -1684,8 +1684,8 @@ _bfd_cr16_elf_final_write_processing (bfd *abfd, bfd_boolean linker) val = EM_CR16; break; } - elf_elfheader (abfd)->e_flags |= val; - _bfd_elf_final_write_processing (abfd, linker); + elf_elfheader (abfd)->e_flags |= val; + return _bfd_elf_final_write_processing (abfd); } diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index 0fc1eb38ce..5d230562a5 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -3829,8 +3829,8 @@ cris_elf_object_p (bfd *abfd) /* Mark presence or absence of leading underscore. Set machine type flags from mach type. */ -static void -cris_elf_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +cris_elf_final_write_processing (bfd *abfd) { unsigned long e_flags = elf_elfheader (abfd)->e_flags; @@ -3858,7 +3858,7 @@ cris_elf_final_write_processing (bfd *abfd, bfd_boolean linker) } elf_elfheader (abfd)->e_flags = e_flags; - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } /* Set the mach type from e_flags value. */ diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c index 40680fa3f5..a2f06d5a92 100644 --- a/bfd/elf32-h8300.c +++ b/bfd/elf32-h8300.c @@ -583,8 +583,8 @@ elf32_h8_mach (flagword flags) file. We use this opportunity to encode the BFD machine type into the flags field in the object file. */ -static void -elf32_h8_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +elf32_h8_final_write_processing (bfd *abfd) { unsigned long val; @@ -622,7 +622,7 @@ elf32_h8_final_write_processing (bfd *abfd, bfd_boolean linker) elf_elfheader (abfd)->e_flags &= ~ (EF_H8_MACH); elf_elfheader (abfd)->e_flags |= val; - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } /* Return nonzero if ABFD represents a valid H8 ELF object file; also diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c index 255dc4e2c0..5233dbbb67 100644 --- a/bfd/elf32-lm32.c +++ b/bfd/elf32-lm32.c @@ -555,8 +555,8 @@ 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) +static bfd_boolean +lm32_elf_final_write_processing (bfd *abfd) { elf_elfheader (abfd)->e_machine = EM_LATTICEMICO32; elf_elfheader (abfd)->e_flags &=~ EF_LM32_MACH; @@ -568,7 +568,7 @@ lm32_elf_final_write_processing (bfd *abfd, bfd_boolean linker) default: abort (); } - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } /* 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 3fcde4a614..2f182e782d 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -3403,8 +3403,8 @@ 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) +static bfd_boolean +m32r_elf_final_write_processing (bfd *abfd) { unsigned long val; @@ -3418,7 +3418,7 @@ m32r_elf_final_write_processing (bfd *abfd, bfd_boolean linker) elf_elfheader (abfd)->e_flags &=~ EF_M32R_ARCH; elf_elfheader (abfd)->e_flags |= val; - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } /* Function to keep M32R specific file flags. */ diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 3840b136de..177be5d1d3 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -1053,8 +1053,8 @@ elf32_m68k_object_p (bfd *abfd) /* Somewhat reverse of elf32_m68k_object_p, this sets the e_flag field based on the machine number. */ -static void -elf_m68k_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +elf_m68k_final_write_processing (bfd *abfd) { int mach = bfd_get_mach (abfd); unsigned long e_flags = elf_elfheader (abfd)->e_flags; @@ -1107,7 +1107,7 @@ elf_m68k_final_write_processing (bfd *abfd, bfd_boolean linker) } elf_elfheader (abfd)->e_flags = e_flags; } - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } /* Keep m68k-specific flags in the ELF header. */ diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 370dc90914..9f8f2bdc26 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -2643,11 +2643,11 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = { #include "elf32-target.h" /* Implement elf_backend_final_write_processing for VxWorks. */ -static void -mips_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +mips_vxworks_final_write_processing (bfd *abfd) { - _bfd_mips_final_write_processing (abfd, linker); - elf_vxworks_final_write_processing (abfd, linker); + _bfd_mips_final_write_processing (abfd); + return elf_vxworks_final_write_processing (abfd); } #undef TARGET_LITTLE_SYM diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c index aecc122c00..fe5fd8ff8c 100644 --- a/bfd/elf32-msp430.c +++ b/bfd/elf32-msp430.c @@ -1385,8 +1385,8 @@ elf32_msp430_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, file. This gets the MSP430 architecture right based on the machine number. */ -static void -bfd_elf_msp430_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +bfd_elf_msp430_final_write_processing (bfd *abfd) { unsigned long val; @@ -1421,7 +1421,7 @@ bfd_elf_msp430_final_write_processing (bfd *abfd, bfd_boolean linker) 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); + return _bfd_elf_final_write_processing (abfd); } /* Set the right machine number. */ diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c index 9959cbe5e7..27ffea2e69 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -6672,8 +6672,8 @@ 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) +static bfd_boolean +nds32_elf_final_write_processing (bfd *abfd) { unsigned long val; static unsigned int cur_mach = 0; @@ -6710,7 +6710,7 @@ nds32_elf_final_write_processing (bfd *abfd, bfd_boolean linker) elf_elfheader (abfd)->e_flags &= ~EF_NDS_ARCH; elf_elfheader (abfd)->e_flags |= val; - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } /* Function to keep NDS32 specific file flags. */ diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c index 9b795fb06e..c2069a3180 100644 --- a/bfd/elf32-or1k.c +++ b/bfd/elf32-or1k.c @@ -3156,8 +3156,8 @@ 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) +static bfd_boolean +or1k_elf_final_write_processing (bfd *abfd) { switch (bfd_get_mach (abfd)) { @@ -3168,7 +3168,7 @@ or1k_elf_final_write_processing (bfd *abfd, bfd_boolean linker) elf_elfheader (abfd)->e_flags |= EF_OR1K_NODELAY; break; } - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } static bfd_boolean diff --git a/bfd/elf32-pj.c b/bfd/elf32-pj.c index d4fcebc0f2..14ccf5f726 100644 --- a/bfd/elf32-pj.c +++ b/bfd/elf32-pj.c @@ -336,12 +336,12 @@ pj_elf_info_to_howto (bfd *abfd, /* Take this moment to fill in the special picoJava bits in the e_flags field. */ -static void -pj_elf_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +pj_elf_final_write_processing (bfd *abfd) { elf_elfheader (abfd)->e_flags |= EF_PICOJAVA_ARCH; elf_elfheader (abfd)->e_flags |= EF_PICOJAVA_GNUCALLS; - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } #define TARGET_BIG_SYM pj_elf32_vec diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index b1ae0de4e5..e683590f41 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_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED) +ppc_final_write_processing (bfd *abfd) { bfd_byte *buffer; asection *asec; @@ -1757,11 +1757,11 @@ ppc_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) +static bfd_boolean +ppc_elf_final_write_processing (bfd *abfd) { - ppc_final_write_processing (abfd, linker); - _bfd_elf_final_write_processing (abfd, linker); + ppc_final_write_processing (abfd); + return _bfd_elf_final_write_processing (abfd); } static bfd_boolean @@ -10494,11 +10494,11 @@ ppc_elf_vxworks_add_symbol_hook (bfd *abfd, return ppc_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp); } -static void -ppc_elf_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +ppc_elf_vxworks_final_write_processing (bfd *abfd) { - ppc_final_write_processing (abfd, linker); - elf_vxworks_final_write_processing (abfd, linker); + ppc_final_write_processing (abfd); + return elf_vxworks_final_write_processing (abfd); } /* On VxWorks, we emit relocations against _PROCEDURE_LINKAGE_TABLE_, so diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c index e6d18d377c..3304ec9fc1 100644 --- a/bfd/elf32-sparc.c +++ b/bfd/elf32-sparc.c @@ -117,7 +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 -sparc_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED) +sparc_final_write_processing (bfd *abfd) { switch (bfd_get_mach (abfd)) { @@ -156,11 +156,11 @@ sparc_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED) } } -static void -elf32_sparc_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +elf32_sparc_final_write_processing (bfd *abfd) { - sparc_final_write_processing (abfd, linker); - _bfd_elf_final_write_processing (abfd, linker); + sparc_final_write_processing (abfd); + return _bfd_elf_final_write_processing (abfd); } /* Used to decide how to sort relocs in an optimal manner for the @@ -327,11 +327,11 @@ elf32_sparc_vxworks_link_hash_table_create (bfd *abfd) /* A final_write_processing hook that does both the SPARC- and VxWorks- specific handling. */ -static void -elf32_sparc_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +elf32_sparc_vxworks_final_write_processing (bfd *abfd) { - sparc_final_write_processing (abfd, linker); - elf_vxworks_final_write_processing (abfd, linker); + sparc_final_write_processing (abfd); + return elf_vxworks_final_write_processing (abfd); } #undef TARGET_BIG_SYM diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c index 14bffc27aa..74e1546321 100644 --- a/bfd/elf32-v850.c +++ b/bfd/elf32-v850.c @@ -2718,8 +2718,8 @@ 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) +static bfd_boolean +v850_elf_final_write_processing (bfd *abfd) { unsigned long val; @@ -2749,7 +2749,7 @@ v850_elf_final_write_processing (bfd *abfd, bfd_boolean linker) default: break; } - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } /* Function to keep V850 specific file flags. */ diff --git a/bfd/elf32-xc16x.c b/bfd/elf32-xc16x.c index ef2a5feba2..d000fd56c8 100644 --- a/bfd/elf32-xc16x.c +++ b/bfd/elf32-xc16x.c @@ -416,8 +416,8 @@ elf32_xc16x_relocate_section (bfd *output_bfd, } -static void -elf32_xc16x_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +elf32_xc16x_final_write_processing (bfd *abfd) { unsigned long val; @@ -438,7 +438,7 @@ elf32_xc16x_final_write_processing (bfd *abfd, bfd_boolean linker) } elf_elfheader (abfd)->e_flags |= val; - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } static unsigned long diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index 40edb467e5..93394547ce 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -3462,8 +3462,8 @@ elf_xtensa_object_p (bfd *abfd) file. This gets the Xtensa architecture right based on the machine number. */ -static void -elf_xtensa_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +elf_xtensa_final_write_processing (bfd *abfd) { int mach; unsigned long val = elf_elfheader (abfd)->e_flags & EF_XTENSA_MACH; @@ -3479,7 +3479,7 @@ elf_xtensa_final_write_processing (bfd *abfd, bfd_boolean linker) elf_elfheader (abfd)->e_flags &= ~EF_XTENSA_MACH; elf_elfheader (abfd)->e_flags |= val; - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c index 0c7144a6f7..0ae9f353f4 100644 --- a/bfd/elf64-ia64-vms.c +++ b/bfd/elf64-ia64-vms.c @@ -4659,8 +4659,8 @@ elf64_vms_section_processing (bfd *abfd ATTRIBUTE_UNUSED, /* The final processing done just before writing out a VMS IA-64 ELF object file. */ -static void -elf64_vms_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +elf64_vms_final_write_processing (bfd *abfd) { Elf_Internal_Shdr *hdr; asection *s; @@ -4695,7 +4695,7 @@ elf64_vms_final_write_processing (bfd *abfd, bfd_boolean linker) elf_elfheader (abfd)->e_flags = flags; elf_flags_init (abfd) = TRUE; } - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } static bfd_boolean diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c index 1c9a904207..65471dd4a4 100644 --- a/bfd/elfnn-ia64.c +++ b/bfd/elfnn-ia64.c @@ -1002,8 +1002,8 @@ elfNN_ia64_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr, /* The final processing done just before writing out an IA-64 ELF object file. */ -static void -elfNN_ia64_final_write_processing (bfd *abfd, bfd_boolean linker) +static bfd_boolean +elfNN_ia64_final_write_processing (bfd *abfd) { Elf_Internal_Shdr *hdr; asection *s; @@ -1035,7 +1035,7 @@ elfNN_ia64_final_write_processing (bfd *abfd, bfd_boolean linker) elf_elfheader(abfd)->e_flags = flags; elf_flags_init (abfd) = TRUE; } - _bfd_elf_final_write_processing (abfd, linker); + return _bfd_elf_final_write_processing (abfd); } /* 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 f0c092c0f9..29ae455926 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -12358,8 +12358,7 @@ _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_final_write_processing (bfd *abfd, - bfd_boolean linker ATTRIBUTE_UNUSED) +_bfd_mips_final_write_processing (bfd *abfd) { unsigned int i; Elf_Internal_Shdr **hdrpp; @@ -12439,11 +12438,11 @@ _bfd_mips_final_write_processing (bfd *abfd, } } -void -_bfd_mips_elf_final_write_processing (bfd *abfd, bfd_boolean linker) +bfd_boolean +_bfd_mips_elf_final_write_processing (bfd *abfd) { - _bfd_mips_final_write_processing (abfd, linker); - _bfd_elf_final_write_processing (abfd, linker); + _bfd_mips_final_write_processing (abfd); + return _bfd_elf_final_write_processing (abfd); } /* When creating an IRIX5 executable, we need REGINFO and RTPROC diff --git a/bfd/elfxx-mips.h b/bfd/elfxx-mips.h index a76680a917..0a901c6208 100644 --- a/bfd/elfxx-mips.h +++ b/bfd/elfxx-mips.h @@ -70,9 +70,9 @@ extern bfd_boolean _bfd_mips_elf_finish_dynamic_sections 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); + (bfd *); +extern bfd_boolean _bfd_mips_elf_final_write_processing + (bfd *); extern int _bfd_mips_elf_additional_program_headers (bfd *, struct bfd_link_info *); extern bfd_boolean _bfd_mips_elf_modify_segment_map diff --git a/gas/ChangeLog b/gas/ChangeLog index fcde8b080a..c08ccbc9b6 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2019-07-24 Alan Modra + + * config/obj-elf.c (obj_elf_section, obj_elf_type): Set has_gnu_osabi. + * testsuite/gas/elf/section12a.d: Update xfails. + * testsuite/gas/elf/section12b.d: Likewise. + 2019-07-24 Alan Modra * testsuite/gas/elf/section12a.d: xfail visium and cloudabi. diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index fd2c943771..bdf3da8119 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -1242,6 +1242,7 @@ done: && bed->elf_osabi != ELFOSABI_FREEBSD) as_bad (_("GNU_MBIND section is supported only by GNU " "and FreeBSD targets")); + elf_tdata (stdoutput)->has_gnu_osabi |= elf_gnu_osabi_mbind; } elf_section_flags (now_seg) |= gnu_attr; @@ -2060,6 +2061,7 @@ obj_elf_type (int ignore ATTRIBUTE_UNUSED) && bed->elf_osabi != ELFOSABI_FREEBSD) as_bad (_("symbol type \"%s\" is supported only by GNU " "and FreeBSD targets"), type_name); + elf_tdata (stdoutput)->has_gnu_osabi |= elf_gnu_osabi_ifunc; type = BSF_FUNCTION | BSF_GNU_INDIRECT_FUNCTION; } else if (strcmp (type_name, "gnu_unique_object") == 0) @@ -2072,6 +2074,7 @@ obj_elf_type (int ignore ATTRIBUTE_UNUSED) else if (bed->elf_osabi != ELFOSABI_GNU) as_bad (_("symbol type \"%s\" is supported only by GNU targets"), type_name); + elf_tdata (stdoutput)->has_gnu_osabi |= elf_gnu_osabi_unique; type = BSF_OBJECT | BSF_GNU_UNIQUE; } #ifdef md_elf_symbol_type diff --git a/gas/testsuite/gas/elf/section12a.d b/gas/testsuite/gas/elf/section12a.d index 5b764afbe2..84c032f90e 100644 --- a/gas/testsuite/gas/elf/section12a.d +++ b/gas/testsuite/gas/elf/section12a.d @@ -3,7 +3,7 @@ #readelf: -Sg --wide #name: mbind sections # A number of targets do not support SHF_GNU_MBIND -#xfail: msp430-*-* visium-*-* +#xfail: arm*-*-netbsdelf* arm*-*-nto* msp430-*-* visium-*-* #xfail: *-*-hpux* *-*-cloudabi #... diff --git a/gas/testsuite/gas/elf/section12b.d b/gas/testsuite/gas/elf/section12b.d index a8406c3057..847f9a8a18 100644 --- a/gas/testsuite/gas/elf/section12b.d +++ b/gas/testsuite/gas/elf/section12b.d @@ -6,7 +6,7 @@ # expected below. #xfail: rx-*-* # A number of targets do not support SHF_GNU_MBIND -#xfail: msp430-*-* visium-*-* +#xfail: arm*-*-netbsdelf* arm*-*-nto* msp430-*-* visium-*-* #xfail: *-*-hpux* *-*-cloudabi #... -- 2.34.1