aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog36
-rw-r--r--bfd/elf-bfd.h11
-rw-r--r--bfd/elf.c223
-rw-r--r--bfd/elf32-i386.c87
-rw-r--r--bfd/elf32-sparc.c45
-rw-r--r--bfd/elf64-x86-64.c23
-rw-r--r--bfd/elflink.c2
-rw-r--r--bfd/elfxx-target.h9
-rw-r--r--binutils/ChangeLog13
-rw-r--r--binutils/testsuite/binutils-all/i386/compressed-1b.d2
-rw-r--r--binutils/testsuite/binutils-all/i386/compressed-1c.d2
-rw-r--r--binutils/testsuite/binutils-all/readelf.s4
-rw-r--r--binutils/testsuite/binutils-all/readelf.s-644
-rw-r--r--binutils/testsuite/binutils-all/testprog.c4
-rw-r--r--binutils/testsuite/binutils-all/x86-64/compressed-1b.d2
-rw-r--r--binutils/testsuite/binutils-all/x86-64/compressed-1c.d2
-rw-r--r--gas/ChangeLog7
-rw-r--r--gas/testsuite/gas/i386/ilp32/x86-64-unwind.d4
-rw-r--r--gas/testsuite/gas/i386/x86-64-unwind.d4
19 files changed, 396 insertions, 88 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 578fbc7..0a0dd2c 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,39 @@
+2016-04-14 Nick Clifton <nickc@redhat.com>
+
+ PR target/19938
+ * 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.
+
2016-04-11 H.J. Lu <hongjiu.lu@intel.com>
PR ld/19939
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index f820e85..5c93d78 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1300,6 +1300,14 @@ struct elf_backend_data
/* Return the section which RELOC_SEC applies to. */
asection *(*get_reloc_section) (asection *reloc_sec);
+ /* Called when setting the sh_link and sh_info fields of a section with a
+ type >= SHT_LOOS. Returns TRUE if these fields were initialised in
+ OHEADER, FALSE otherwise. IHEADER is the best guess matching section
+ from the input bfd IBFD. */
+ bfd_boolean (*elf_backend_set_special_section_info_and_link)
+ (const bfd *ibfd, bfd *obfd, const Elf_Internal_Shdr *iheader,
+ Elf_Internal_Shdr *oheader);
+
/* Used to handle bad SHF_LINK_ORDER input. */
bfd_error_handler_type link_order_error_handler;
@@ -1361,6 +1369,9 @@ struct elf_backend_data
/* Alignment for the PT_GNU_STACK segment. */
unsigned stack_align;
+ /* Flag bits to assign to a section of type SHT_STRTAB. */
+ unsigned long elf_strtab_flags;
+
/* This is TRUE if the linker should act like collect and gather
global constructors and destructors by name. This is TRUE for
MIPS ELF because the Irix 5 tools can not handle the .init
diff --git a/bfd/elf.c b/bfd/elf.c
index 90319a2..408dab7 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -970,9 +970,9 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
{
flags |= SEC_MERGE;
newsect->entsize = hdr->sh_entsize;
- if ((hdr->sh_flags & SHF_STRINGS) != 0)
- flags |= SEC_STRINGS;
}
+ if ((hdr->sh_flags & SHF_STRINGS) != 0)
+ flags |= SEC_STRINGS;
if (hdr->sh_flags & SHF_GROUP)
if (!setup_group (abfd, hdr, newsect))
return FALSE;
@@ -1175,7 +1175,8 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
return TRUE;
}
-const char *const bfd_elf_section_type_names[] = {
+const char *const bfd_elf_section_type_names[] =
+{
"SHT_NULL", "SHT_PROGBITS", "SHT_SYMTAB", "SHT_STRTAB",
"SHT_RELA", "SHT_HASH", "SHT_DYNAMIC", "SHT_NOTE",
"SHT_NOBITS", "SHT_REL", "SHT_SHLIB", "SHT_DYNSYM",
@@ -1212,14 +1213,62 @@ bfd_elf_generic_reloc (bfd *abfd ATTRIBUTE_UNUSED,
return bfd_reloc_continue;
}
+/* Returns TRUE if section A matches section B.
+ Names, addresses and links may be different, but everything else
+ should be the same. */
+
+static bfd_boolean
+section_match (Elf_Internal_Shdr * a, Elf_Internal_Shdr * b)
+{
+ return
+ a->sh_type == b->sh_type
+ && a->sh_flags == b->sh_flags
+ && a->sh_addralign == b->sh_addralign
+ && a->sh_size == b->sh_size
+ && a->sh_entsize == b->sh_entsize
+ /* FIXME: Check sh_addr ? */
+ ;
+}
+
+/* Find a section in OBFD that has the same characteristics
+ as IHEADER. Return the index of this section or SHN_UNDEF if
+ none can be found. Check's section HINT first, as this is likely
+ to be the correct section. */
+
+static unsigned int
+find_link (bfd * obfd, Elf_Internal_Shdr * iheader, unsigned int hint)
+{
+ Elf_Internal_Shdr ** oheaders = elf_elfsections (obfd);
+ unsigned int i;
+
+ if (section_match (oheaders[hint], iheader))
+ return hint;
+
+ for (i = 1; i < elf_numsections (obfd); i++)
+ {
+ Elf_Internal_Shdr * oheader = oheaders[i];
+
+ if (section_match (oheader, iheader))
+ /* FIXME: Do we care if there is a potential for
+ multiple matches ? */
+ return i;
+ }
+
+ return SHN_UNDEF;
+}
+
/* Copy the program header and other data from one object module to
another. */
bfd_boolean
_bfd_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
{
+ Elf_Internal_Shdr ** iheaders = elf_elfsections (ibfd);
+ Elf_Internal_Shdr ** oheaders = elf_elfsections (obfd);
+ unsigned int i;
+
if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
return TRUE;
if (!elf_flags_init (obfd))
@@ -1237,59 +1286,126 @@ _bfd_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
/* Copy object attributes. */
_bfd_elf_copy_obj_attributes (ibfd, obfd);
- /* This is an feature for objcopy --only-keep-debug: When a section's type
- is changed to NOBITS, we preserve the sh_link and sh_info fields so that
- they can be matched up with the original. */
- Elf_Internal_Shdr ** iheaders = elf_elfsections (ibfd);
- Elf_Internal_Shdr ** oheaders = elf_elfsections (obfd);
+ if (iheaders == NULL || oheaders == NULL)
+ return TRUE;
- if (iheaders != NULL && oheaders != NULL)
+ /* Possibly copy the sh_info and sh_link fields. */
+ for (i = 1; i < elf_numsections (obfd); i++)
{
- unsigned int i;
-
- for (i = 0; i < elf_numsections (obfd); i++)
- {
- unsigned int j;
- Elf_Internal_Shdr * oheader = oheaders[i];
+ unsigned int j;
+ Elf_Internal_Shdr * oheader = oheaders[i];
- if (oheader == NULL
- || oheader->sh_type != SHT_NOBITS
- || oheader->sh_size == 0
- || (oheader->sh_info != 0 && oheader->sh_link != 0))
- continue;
+ if (oheader == NULL
+ || (oheader->sh_type != SHT_NOBITS
+ && oheader->sh_type < SHT_LOOS)
+ || oheader->sh_size == 0
+ || (oheader->sh_info != 0 && oheader->sh_link != 0))
+ continue;
- /* Scan for the matching section in the input bfd.
- FIXME: We could use something better than a linear scan here.
- Unfortunately we cannot compare names as the output string table
- is empty, so instead we check size, address and type. */
- for (j = 0; j < elf_numsections (ibfd); j++)
+ /* Scan for the matching section in the input bfd.
+ FIXME: We could use something better than a linear scan here.
+ Unfortunately we cannot compare names as the output string table
+ is empty, so instead we check size, address and type. */
+ for (j = 1; j < elf_numsections (ibfd); j++)
+ {
+ Elf_Internal_Shdr * iheader = iheaders[j];
+
+ /* Since --only-keep-debug turns all non-debug sections into
+ SHT_NOBITS sections, the output SHT_NOBITS type matches any
+ input type. */
+ if ((oheader->sh_type == SHT_NOBITS
+ || iheader->sh_type == oheader->sh_type)
+ && iheader->sh_flags == oheader->sh_flags
+ && iheader->sh_addralign == oheader->sh_addralign
+ && iheader->sh_entsize == oheader->sh_entsize
+ && iheader->sh_size == oheader->sh_size
+ && iheader->sh_addr == oheader->sh_addr
+ && (iheader->sh_info != oheader->sh_info
+ || iheader->sh_link != oheader->sh_link))
{
- Elf_Internal_Shdr * iheader = iheaders[j];
-
- /* Since --only-keep-debug turns all non-debug sections
- into SHT_NOBITS sections, the output SHT_NOBITS type
- matches any input type. */
- if ((oheader->sh_type == SHT_NOBITS
- || iheader->sh_type == oheader->sh_type)
- && iheader->sh_flags == oheader->sh_flags
- && iheader->sh_addralign == oheader->sh_addralign
- && iheader->sh_entsize == oheader->sh_entsize
- && iheader->sh_size == oheader->sh_size
- && iheader->sh_addr == oheader->sh_addr
- && (iheader->sh_info != oheader->sh_info
- || iheader->sh_link != oheader->sh_link))
+ /* PR 19938: Attempt to preserve the sh_link and sh_info fields
+ of OS and Processor specific sections. We try harder for
+ these sections, because this is not just about matching
+ stripped binaries to their originals. */
+ if (oheader->sh_type >= SHT_LOOS)
{
- /* Note: Strictly speaking these assignments are wrong.
+ const struct elf_backend_data *bed = get_elf_backend_data (obfd);
+ bfd_boolean changed = FALSE;
+ unsigned int link;
+
+ /* Allow the target a chance to decide how these fields should
+ be set. */
+ if (bed->elf_backend_set_special_section_info_and_link != NULL
+ && bed->elf_backend_set_special_section_info_and_link
+ (ibfd, obfd, iheader, oheader))
+ break;
+
+ /* We have iheader which matches oheader, but which has
+ non-zero sh_info and/or sh_link fields. Attempt to
+ follow those links and find the section in the output
+ bfd which corresponds to the linked section in the input
+ bfd. */
+ if (iheader->sh_link != SHN_UNDEF)
+ {
+ link = find_link (obfd, iheaders[iheader->sh_link],
+ iheader->sh_link);
+ if (link != SHN_UNDEF)
+ {
+ oheader->sh_link = link;
+ changed = TRUE;
+ }
+ else
+ /* FIXME: Should we install iheader->sh_link
+ if we could not find a match ? */
+ (* _bfd_error_handler)
+ (_("%B: Failed to find link section for section %d"),
+ obfd, i);
+ }
+
+ if (iheader->sh_info)
+ {
+ /* The sh_info field can hold arbitrary information,
+ but if the SHF_LINK_INFO flag is set then it
+ should be interpreted as a section index. */
+ if (iheader->sh_flags & SHF_INFO_LINK)
+ link = find_link (obfd, iheaders[iheader->sh_info],
+ iheader->sh_info);
+ else
+ /* No idea what it means - just copy it. */
+ link = iheader->sh_info;
+
+ if (link != SHN_UNDEF)
+ {
+ oheader->sh_info = link;
+ changed = TRUE;
+ }
+ else
+ (* _bfd_error_handler)
+ (_("%B: Failed to find info section for section %d"),
+ obfd, i);
+ }
+
+ if (changed)
+ break;
+ }
+ else
+ {
+ /* This is an feature for objcopy --only-keep-debug:
+ When a section's type is changed to NOBITS, we preserve
+ the sh_link and sh_info fields so that they can be
+ matched up with the original.
+
+ Note: Strictly speaking these assignments are wrong.
The sh_link and sh_info fields should point to the
relevent sections in the output BFD, which may not be in
- the same location as they were in the input BFD. But the
- whole point of this action is to preserve the original
- values of the sh_link and sh_info fields, so that they
- can be matched up with the section headers in the
- original file. So strictly speaking we may be creating
- an invalid ELF file, but it is only for a file that just
- contains debug info and only for sections without any
- contents. */
+ the same location as they were in the input BFD. But
+ the whole point of this action is to preserve the
+ original values of the sh_link and sh_info fields, so
+ that they can be matched up with the section headers in
+ the original file. So strictly speaking we may be
+ creating an invalid ELF file, but it is only for a file
+ that just contains debug info and only for sections
+ without any contents. */
if (oheader->sh_link == 0)
oheader->sh_link = iheader->sh_link;
if (oheader->sh_info == 0)
@@ -3099,9 +3215,9 @@ elf_fake_sections (bfd *abfd, asection *asect, void *fsarg)
{
this_hdr->sh_flags |= SHF_MERGE;
this_hdr->sh_entsize = asect->entsize;
- if ((asect->flags & SEC_STRINGS) != 0)
- this_hdr->sh_flags |= SHF_STRINGS;
}
+ if ((asect->flags & SEC_STRINGS) != 0)
+ this_hdr->sh_flags |= SHF_STRINGS;
if ((asect->flags & SEC_GROUP) == 0 && elf_group_name (asect) != NULL)
this_hdr->sh_flags |= SHF_GROUP;
if ((asect->flags & SEC_THREAD_LOCAL) != 0)
@@ -3919,7 +4035,7 @@ _bfd_elf_compute_section_file_positions (bfd *abfd,
shstrtab_hdr = &elf_tdata (abfd)->shstrtab_hdr;
/* sh_name was set in prep_headers. */
shstrtab_hdr->sh_type = SHT_STRTAB;
- shstrtab_hdr->sh_flags = 0;
+ shstrtab_hdr->sh_flags = bed->elf_strtab_flags;
shstrtab_hdr->sh_addr = 0;
/* sh_size is set in _bfd_elf_assign_file_positions_for_non_load. */
shstrtab_hdr->sh_entsize = 0;
@@ -7551,8 +7667,7 @@ Unable to find equivalent output section for symbol '%s' from section '%s'"),
*sttp = stt;
symstrtab_hdr->sh_size = _bfd_elf_strtab_size (stt);
symstrtab_hdr->sh_type = SHT_STRTAB;
-
- symstrtab_hdr->sh_flags = 0;
+ symstrtab_hdr->sh_flags = bed->elf_strtab_flags;
symstrtab_hdr->sh_addr = 0;
symstrtab_hdr->sh_entsize = 0;
symstrtab_hdr->sh_link = 0;
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 376f2cc..470fcd1 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -6051,16 +6051,94 @@ elf_i386_fbsd_post_process_headers (bfd *abfd, struct bfd_link_info *info)
/* The 32-bit static TLS arena size is rounded to the nearest 8-byte
boundary. */
-#undef elf_backend_static_tls_alignment
+#undef elf_backend_static_tls_alignment
#define elf_backend_static_tls_alignment 8
/* The Solaris 2 ABI requires a plt symbol on all platforms.
Cf. Linker and Libraries Guide, Ch. 2, Link-Editor, Generating the Output
File, p.63. */
-#undef elf_backend_want_plt_sym
+#undef elf_backend_want_plt_sym
#define elf_backend_want_plt_sym 1
+#undef elf_backend_strtab_flags
+#define elf_backend_strtab_flags SHF_STRINGS
+
+static bfd_boolean
+elf32_i386_set_special_info_link (const bfd *ibfd ATTRIBUTE_UNUSED,
+ bfd *obfd ATTRIBUTE_UNUSED,
+ const Elf_Internal_Shdr *isection ATTRIBUTE_UNUSED,
+ Elf_Internal_Shdr *osection ATTRIBUTE_UNUSED)
+{
+ /* PR 19938: FIXME: Need to add code for setting the sh_info
+ and sh_link fields of Solaris specific section types.
+
+ Based upon Oracle Solaris 11.3 Linkers and Libraries Guide, Ch. 13,
+ Object File Format, Table 13-9 ELF sh_link and sh_info Interpretation:
+
+http://docs.oracle.com/cd/E53394_01/html/E54813/chapter6-94076.html#scrolltoc
+
+ The following values should be set:
+
+Type Link Info
+-----------------------------------------------------------------------------
+SHT_SUNW_ancillary The section header index of 0
+ [0x6fffffee] the associated string table.
+
+SHT_SUNW_capinfo The section header index of For a dynamic object, the
+ [0x6ffffff0] the associated symbol table. section header index of
+ the associated
+ SHT_SUNW_capchain table,
+ otherwise 0.
+
+SHT_SUNW_symsort The section header index of 0
+ [0x6ffffff1] the associated symbol table.
+
+SHT_SUNW_tlssort The section header index of 0
+ [0x6ffffff2] the associated symbol table.
+
+SHT_SUNW_LDYNSYM The section header index of One greater than the
+ [0x6ffffff3] the associated string table. symbol table index of the
+ This index is the same string last local symbol,
+ table used by the SHT_DYNSYM STB_LOCAL. Since
+ section. SHT_SUNW_LDYNSYM only
+ contains local symbols,
+ sh_info is equivalent to
+ the number of symbols in
+ the table.
+
+SHT_SUNW_cap If symbol capabilities exist, If any capabilities refer
+ [0x6ffffff5] the section header index of to named strings, the
+ the associated section header index of
+ SHT_SUNW_capinfo table, the associated string
+ otherwise 0. table, otherwise 0.
+
+SHT_SUNW_move The section header index of 0
+ [0x6ffffffa] the associated symbol table.
+
+SHT_SUNW_COMDAT 0 0
+ [0x6ffffffb]
+
+SHT_SUNW_syminfo The section header index of The section header index
+ [0x6ffffffc] the associated symbol table. of the associated
+ .dynamic section.
+
+SHT_SUNW_verdef The section header index of The number of version
+ [0x6ffffffd] the associated string table. definitions within the
+ section.
+
+SHT_SUNW_verneed The section header index of The number of version
+ [0x6ffffffe] the associated string table. dependencies within the
+ section.
+
+SHT_SUNW_versym The section header index of 0
+ [0x6fffffff] the associated symbol table. */
+ return FALSE;
+}
+
+#undef elf_backend_set_special_section_info_and_link
+#define elf_backend_set_special_section_info_and_link elf32_i386_set_special_info_link
+
#include "elf32-target.h"
/* Intel MCU support. */
@@ -6077,7 +6155,7 @@ elf32_iamcu_elf_object_p (bfd *abfd)
#define TARGET_LITTLE_SYM iamcu_elf32_vec
#undef TARGET_LITTLE_NAME
#define TARGET_LITTLE_NAME "elf32-iamcu"
-#undef ELF_ARCH
+#undef ELF_ARCH
#define ELF_ARCH bfd_arch_iamcu
#undef ELF_MACHINE_CODE
@@ -6096,6 +6174,9 @@ elf32_iamcu_elf_object_p (bfd *abfd)
#undef elf_backend_want_plt_sym
#define elf_backend_want_plt_sym 0
+#undef elf_backend_strtab_flags
+#undef elf_backend_set_special_section_info_and_link
+
#include "elf32-target.h"
/* Restore defaults. */
diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
index 213d20a..c045854 100644
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -258,9 +258,26 @@ elf32_sparc_add_symbol_hook (bfd * abfd,
/* The 32-bit static TLS arena size is rounded to the nearest 8-byte
boundary. */
-#undef elf_backend_static_tls_alignment
+#undef elf_backend_static_tls_alignment
#define elf_backend_static_tls_alignment 8
+#undef elf_backend_strtab_flags
+#define elf_backend_strtab_flags SHF_STRINGS
+
+static bfd_boolean
+elf32_sparc_set_special_info_link (const bfd *ibfd ATTRIBUTE_UNUSED,
+ bfd *obfd ATTRIBUTE_UNUSED,
+ const Elf_Internal_Shdr *isection ATTRIBUTE_UNUSED,
+ Elf_Internal_Shdr *osection ATTRIBUTE_UNUSED)
+{
+ /* PR 19938: FIXME: Need to add code for setting the sh_info
+ and sh_link fields of Solaris specific section types. */
+ return FALSE;
+}
+
+#undef elf_backend_set_special_section_info_and_link
+#define elf_backend_set_special_section_info_and_link elf32_sparc_set_special_info_link
+
#include "elf32-target.h"
/* A wrapper around _bfd_sparc_elf_link_hash_table_create that identifies
@@ -292,39 +309,41 @@ elf32_sparc_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
elf_vxworks_final_write_processing (abfd, linker);
}
-#undef TARGET_BIG_SYM
+#undef TARGET_BIG_SYM
#define TARGET_BIG_SYM sparc_elf32_vxworks_vec
-#undef TARGET_BIG_NAME
+#undef TARGET_BIG_NAME
#define TARGET_BIG_NAME "elf32-sparc-vxworks"
-#undef ELF_MINPAGESIZE
+#undef ELF_MINPAGESIZE
#define ELF_MINPAGESIZE 0x1000
#undef bfd_elf32_bfd_link_hash_table_create
#define bfd_elf32_bfd_link_hash_table_create \
elf32_sparc_vxworks_link_hash_table_create
-#undef elf_backend_want_got_plt
+#undef elf_backend_want_got_plt
#define elf_backend_want_got_plt 1
-#undef elf_backend_plt_readonly
+#undef elf_backend_plt_readonly
#define elf_backend_plt_readonly 1
-#undef elf_backend_got_header_size
+#undef elf_backend_got_header_size
#define elf_backend_got_header_size 12
-#undef elf_backend_add_symbol_hook
+#undef elf_backend_add_symbol_hook
#define elf_backend_add_symbol_hook \
elf_vxworks_add_symbol_hook
-#undef elf_backend_link_output_symbol_hook
+#undef elf_backend_link_output_symbol_hook
#define elf_backend_link_output_symbol_hook \
elf_vxworks_link_output_symbol_hook
-#undef elf_backend_emit_relocs
+#undef elf_backend_emit_relocs
#define elf_backend_emit_relocs \
elf_vxworks_emit_relocs
-#undef elf_backend_final_write_processing
+#undef elf_backend_final_write_processing
#define elf_backend_final_write_processing \
elf32_sparc_vxworks_final_write_processing
-#undef elf_backend_static_tls_alignment
+#undef elf_backend_static_tls_alignment
+#undef elf_backend_strtab_flags
+#undef elf_backend_set_special_section_info_and_link
-#undef elf32_bed
+#undef elf32_bed
#define elf32_bed sparc_elf_vxworks_bed
#include "elf32-target.h"
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index b58a699..5533b4a 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -6708,16 +6708,33 @@ static const struct bfd_elf_special_section
/* The 64-bit static TLS arena size is rounded to the nearest 16-byte
boundary. */
-#undef elf_backend_static_tls_alignment
+#undef elf_backend_static_tls_alignment
#define elf_backend_static_tls_alignment 16
/* The Solaris 2 ABI requires a plt symbol on all platforms.
Cf. Linker and Libraries Guide, Ch. 2, Link-Editor, Generating the Output
File, p.63. */
-#undef elf_backend_want_plt_sym
+#undef elf_backend_want_plt_sym
#define elf_backend_want_plt_sym 1
+#undef elf_backend_strtab_flags
+#define elf_backend_strtab_flags SHF_STRINGS
+
+static bfd_boolean
+elf64_x86_64_set_special_info_link (const bfd *ibfd ATTRIBUTE_UNUSED,
+ bfd *obfd ATTRIBUTE_UNUSED,
+ const Elf_Internal_Shdr *isection ATTRIBUTE_UNUSED,
+ Elf_Internal_Shdr *osection ATTRIBUTE_UNUSED)
+{
+ /* PR 19938: FIXME: Need to add code for setting the sh_info
+ and sh_link fields of Solaris specific section types. */
+ return FALSE;
+}
+
+#undef elf_backend_set_special_section_info_and_link
+#define elf_backend_set_special_section_info_and_link elf64_x86_64_set_special_info_link
+
#include "elf64-target.h"
/* Native Client support. */
@@ -6749,6 +6766,8 @@ elf64_x86_64_nacl_elf_object_p (bfd *abfd)
#undef elf_backend_static_tls_alignment
#undef elf_backend_want_plt_sym
#define elf_backend_want_plt_sym 0
+#undef elf_backend_strtab_flags
+#undef elf_backend_set_special_section_info_and_link
/* NaCl uses substantially different PLT entries for the same effects. */
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 42b3689..37638b2 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -11705,7 +11705,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
/* sh_name was set in prep_headers. */
symstrtab_hdr->sh_type = SHT_STRTAB;
- symstrtab_hdr->sh_flags = 0;
+ symstrtab_hdr->sh_flags = bed->elf_strtab_flags;
symstrtab_hdr->sh_addr = 0;
symstrtab_hdr->sh_size = _bfd_elf_strtab_size (flinfo.symstrtab);
symstrtab_hdr->sh_entsize = 0;
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,
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 07b6d13..6edcaa5 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,6 +1,17 @@
+2016-04-14 Nick Clifton <nickc@redhat.com>
+
+ PR target/19938
+ * 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.
+
2016-04-13 Nick Clifton <nickc@redhat.com>
- PR target/19983
+ PR target/19938
* readelf.c (get_solaris_section_type): New function: Returns the
name of Solaris specific section types.
(get_solaris_dynamic_type): New function: Return the name of
diff --git a/binutils/testsuite/binutils-all/i386/compressed-1b.d b/binutils/testsuite/binutils-all/i386/compressed-1b.d
index 40bd5e6..d74af4d 100644
--- a/binutils/testsuite/binutils-all/i386/compressed-1b.d
+++ b/binutils/testsuite/binutils-all/i386/compressed-1b.d
@@ -13,6 +13,6 @@ Section Headers:
\[ 1\] .text PROGBITS 00000000 000040 00001b 00 AX 0 0 16
\[ 2\] .data PROGBITS 00000000 00005b 000000 00 WA 0 0 1
\[ 3\] .bss NOBITS 00000000 00005b 000000 00 WA 0 0 1
- \[ 4\] .shstrtab STRTAB 00000000 [0-9a-f]+ 00001c 00 0 0 1
+ \[ 4\] .shstrtab STRTAB 00000000 [0-9a-f]+ 00001c 00 . 0 0 1
Key to Flags:
#...
diff --git a/binutils/testsuite/binutils-all/i386/compressed-1c.d b/binutils/testsuite/binutils-all/i386/compressed-1c.d
index 1f46e3c..3a0cba5 100644
--- a/binutils/testsuite/binutils-all/i386/compressed-1c.d
+++ b/binutils/testsuite/binutils-all/i386/compressed-1c.d
@@ -13,6 +13,6 @@ Section Headers:
\[ 1\] .text PROGBITS 00000000 000040 00001b 00 AX 0 0 16
\[ 2\] .data PROGBITS 00000000 00005b 000000 00 WA 0 0 1
\[ 3\] .bss NOBITS 00000000 00005b 000000 00 WA 0 0 1
- \[ 4\] .shstrtab STRTAB 00000000 [0-9a-f]+ 00001c 00 0 0 1
+ \[ 4\] .shstrtab STRTAB 00000000 [0-9a-f]+ 00001c 00 .* 0 0 1
Key to Flags:
#...
diff --git a/binutils/testsuite/binutils-all/readelf.s b/binutils/testsuite/binutils-all/readelf.s
index 3b044b1..22b3843 100644
--- a/binutils/testsuite/binutils-all/readelf.s
+++ b/binutils/testsuite/binutils-all/readelf.s
@@ -14,8 +14,8 @@ Section Headers:
# MIPS targets put .reginfo, .mdebug, .MIPS.abiflags and .gnu.attributes here.
# v850 targets put .call_table_data and .call_table_text here.
#...
- +\[ .\] .shstrtab +STRTAB +00000000 0+.* 0+.* 00 +0 +0 +.
+ +\[ .\] .shstrtab +STRTAB +00000000 0+.* 0+.* 00 .* +0 +0 +.
+\[..\] .symtab +SYMTAB +00000000 0+.* 0+.* 10 +.. +.+ +4
- +\[..\] .strtab +STRTAB +00000000 0+.* 0+.* 00 +0 +0 +1
+ +\[..\] .strtab +STRTAB +00000000 0+.* 0+.* 00 .* +0 +0 +1
Key to Flags:
#...
diff --git a/binutils/testsuite/binutils-all/readelf.s-64 b/binutils/testsuite/binutils-all/readelf.s-64
index 40b1f5a..d198300 100644
--- a/binutils/testsuite/binutils-all/readelf.s-64
+++ b/binutils/testsuite/binutils-all/readelf.s-64
@@ -14,11 +14,11 @@ Section Headers:
+\[ 4\] .bss +NOBITS +0000000000000000 +000000(4c|50|54|58)
+0000000000000000 +0000000000000000 +WA +0 +0 +.*
+\[ 5\] .shstrtab +STRTAB +0000000000000000 +[0-9a-f]+
- +00000000000000.. +0000000000000000 +0 +0 +.*
+ +00000000000000.. +0000000000000000 .* +0 +0 +.*
+\[ 6\] .symtab +SYMTAB +0000000000000000 +0+.*
# aarch64-elf targets have one more data symbol.
+0+.* +0000000000000018 +7 +(6|7) +8
+\[ 7\] .strtab +STRTAB +0000000000000000 +0+.*
- +0+.* +0000000000000000 +0 +0 +1
+ +0+.* +0000000000000000 .* +0 +0 +1
Key to Flags:
#...
diff --git a/binutils/testsuite/binutils-all/testprog.c b/binutils/testsuite/binutils-all/testprog.c
index 6ead98e..b8531e2 100644
--- a/binutils/testsuite/binutils-all/testprog.c
+++ b/binutils/testsuite/binutils-all/testprog.c
@@ -1,12 +1,12 @@
/* This program is used to test objcopy, readelf and strip. */
-extern int strcmp (char *, const char *);
+extern int strcmp (const char *, const char *);
extern int printf (const char *, ...);
int common;
int global = 1;
static int local = 2;
-static char string[] = "string";
+static const char string[] = "string";
int
fn (void)
diff --git a/binutils/testsuite/binutils-all/x86-64/compressed-1b.d b/binutils/testsuite/binutils-all/x86-64/compressed-1b.d
index f55efac..040bdd3 100644
--- a/binutils/testsuite/binutils-all/x86-64/compressed-1b.d
+++ b/binutils/testsuite/binutils-all/x86-64/compressed-1b.d
@@ -13,6 +13,6 @@ Section Headers:
\[ 1\] .text PROGBITS 0000000000000000 000040 000015 00 AX 0 0 16
\[ 2\] .data PROGBITS 0000000000000000 000055 000000 00 WA 0 0 1
\[ 3\] .bss NOBITS 0000000000000000 000055 000000 00 WA 0 0 1
- \[ 4\] .shstrtab STRTAB 0000000000000000 [0-9a-f]+ 00001c 00 0 0 1
+ \[ 4\] .shstrtab STRTAB 0000000000000000 [0-9a-f]+ 00001c 00 .* 0 0 1
Key to Flags:
#...
diff --git a/binutils/testsuite/binutils-all/x86-64/compressed-1c.d b/binutils/testsuite/binutils-all/x86-64/compressed-1c.d
index bb8f6e3..96eb6d4 100644
--- a/binutils/testsuite/binutils-all/x86-64/compressed-1c.d
+++ b/binutils/testsuite/binutils-all/x86-64/compressed-1c.d
@@ -13,6 +13,6 @@ Section Headers:
\[ 1\] .text PROGBITS 0000000000000000 000040 000015 00 AX 0 0 16
\[ 2\] .data PROGBITS 0000000000000000 000055 000000 00 WA 0 0 1
\[ 3\] .bss NOBITS 0000000000000000 000055 000000 00 WA 0 0 1
- \[ 4\] .shstrtab STRTAB 0000000000000000 [0-9a-f]+ 00001c 00 0 0 1
+ \[ 4\] .shstrtab STRTAB 0000000000000000 [0-9a-f]+ 00001c 00 .* 0 0 1
Key to Flags:
#...
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 92f3286..d1e95c5 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,10 @@
+2016-04-14 Nick Clifton <nickc@redhat.com>
+
+ PR target/19938
+ * 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.
+
2016-04-12 Claudiu Zissulescu <claziss@synopsys.com>
* config/tc-arc.c (mach_type_specified_p): Change type to
diff --git a/gas/testsuite/gas/i386/ilp32/x86-64-unwind.d b/gas/testsuite/gas/i386/ilp32/x86-64-unwind.d
index 0bac7a2..5cea05e 100644
--- a/gas/testsuite/gas/i386/ilp32/x86-64-unwind.d
+++ b/gas/testsuite/gas/i386/ilp32/x86-64-unwind.d
@@ -11,8 +11,8 @@ Section Headers:
\[ 2\] .data PROGBITS 00000000 000034 000000 00 WA 0 0 1
\[ 3\] .bss NOBITS 00000000 000034 000000 00 WA 0 0 1
\[ 4\] .eh_frame X86_64_UNWIND 00000000 000034 000008 00 A 0 0 1
- \[ 5\] .shstrtab STRTAB 00000000 [0-9a-f]+ 000036 00 0 0 1
+ \[ 5\] .shstrtab STRTAB 00000000 [0-9a-f]+ 000036 00 . 0 0 1
\[ 6\] .symtab SYMTAB 00000000 [0-9a-f]+ 000050 10 7 5 4
- \[ 7\] .strtab STRTAB 00000000 [0-9a-f]+ 000001 00 0 0 1
+ \[ 7\] .strtab STRTAB 00000000 [0-9a-f]+ 000001 00 . 0 0 1
Key to Flags:
#pass
diff --git a/gas/testsuite/gas/i386/x86-64-unwind.d b/gas/testsuite/gas/i386/x86-64-unwind.d
index 613760f..7a4c64c 100644
--- a/gas/testsuite/gas/i386/x86-64-unwind.d
+++ b/gas/testsuite/gas/i386/x86-64-unwind.d
@@ -17,10 +17,10 @@ Section Headers:
\[ 4\] \.eh_frame X86_64_UNWIND 0000000000000000 00000040
0000000000000008 0000000000000000 A 0 0 1
\[ 5\] \.shstrtab STRTAB 0000000000000000 [0-9a-f]+
- 0000000000000036 0000000000000000 0 0 1
+ 0000000000000036 0000000000000000 . 0 0 1
\[ 6\] \.symtab SYMTAB 0000000000000000 [0-9a-f]+
0000000000000078 0000000000000018 7 5 8
\[ 7\] \.strtab STRTAB 0000000000000000 [0-9a-f]+
- 0000000000000001 0000000000000000 0 0 1
+ 0000000000000001 0000000000000000 . 0 0 1
Key to Flags:
#...