From 84865015459b4e9e8ac67f9b91617fbd856d5119 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 14 Apr 2016 12:04:09 +0100 Subject: Fix copying Solaris binaries with objcopy. PR target/19938 bfd * elf-bbfd.h (struct elf_backend_data): New field: elf_strtab_flags. New field: elf_backend_set_special_section_info_and_link * elfxx-target.h (elf_backend_strtab_flags): Define if not already defined. (elf_backend_set_special_section_info_and_link): Define if not already defined. (elfNN_bed): Use elf_backend_set_special_section_info_and_link and elf_backend_strtab_flags macros to initialise fields in structure. * elf.c (_bfd_elf_make_section_from_shdr): Check for SHF_STRINGS being set even if SHF_MERGE is not set. (elf_fake_sections): Likewise. (section_match): New function. Matches two ELF sections based upon fixed characteristics. (find_link): New function. Locates a section in a BFD that matches a section in a different BFD. (_bfd_elf_copy_private_bfd_data): Copy the sh_info and sh_link fields of reserved sections. (bfd_elf_compute_section_file_positions): Set the flags for the .shstrtab section based upon the elf_strtab_flags field in the elf_backend_data structure. (swap_out_syms): Likewise for the .strtab section. * elflink.c (bfd_elf_final_link): Set the flags for the .strtab section based upon the elf_strtab_flags field in the elf_backend_data structure. * elf32-i386.c (elf32_i386_set_special_info_link): New function. (elf_backend_strtab_flags): Set to SHF_STRINGS for Solaris targets. (elf_backend_set_special_section_info_and_link): Define for Solaris targets. * elf32-sparc.c: Likewise. * elf64-x86-64.c: Likewise. binutils* testsuite/binutils-all/i386/compressed-1b.d: Allow for the string sections possibly having the SHF_STRINGS flag bit set. * testsuite/binutils-all/i386/compressed-1c.d: Likewise. * testsuite/binutils-all/readelf.s: Likewise. * testsuite/binutils-all/readelf.s-64: Likewise. * testsuite/binutils-all/x86-64/compressed-1b.d: Likewise. * testsuite/binutils-all/x86-64/compressed-1c.d: Likewise. gas * testsuite/gas/i386/ilp32/x86-64-unwind.d: Allow for the string sections possibly having the SHF_STRINGS flag bit set. * testsuite/gas/i386/x86-64-unwind.d: Likewise. --- bfd/elfxx-target.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'bfd/elfxx-target.h') diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index ca30b1d..c179721 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -123,6 +123,9 @@ #ifndef elf_backend_stack_align #define elf_backend_stack_align 16 #endif +#ifndef elf_backend_strtab_flags +#define elf_backend_strtab_flags 0 +#endif #define bfd_elfNN_bfd_debug_info_start bfd_void #define bfd_elfNN_bfd_debug_info_end bfd_void @@ -679,6 +682,10 @@ #define elf_backend_get_reloc_section _bfd_elf_get_reloc_section #endif +#ifndef elf_backend_set_special_section_info_and_link +#define elf_backend_set_special_section_info_and_link NULL +#endif + #ifndef elf_backend_compact_eh_encoding #define elf_backend_compact_eh_encoding NULL #endif @@ -786,6 +793,7 @@ static struct elf_backend_data elfNN_bed = elf_backend_is_function_type, elf_backend_maybe_function_sym, elf_backend_get_reloc_section, + elf_backend_set_special_section_info_and_link, elf_backend_link_order_error_handler, elf_backend_relplt_name, ELF_MACHINE_ALT1, @@ -804,6 +812,7 @@ static struct elf_backend_data elfNN_bed = elf_backend_cant_unwind_opcode, elf_backend_static_tls_alignment, elf_backend_stack_align, + elf_backend_strtab_flags, elf_backend_collect, elf_backend_type_change_ok, elf_backend_may_use_rel_p, -- cgit v1.1