diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2017-10-07 15:11:12 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2017-10-11 13:57:33 -0700 |
commit | d666266806b4e04e41437ab1453b75d4419edabb (patch) | |
tree | 7cb298c796a1e6a5a2453be52fa28790f5902ebf | |
parent | daa640da38126f0ac3e0ac788c1ef58fa838a5c8 (diff) | |
download | binutils-gdb-d666266806b4e04e41437ab1453b75d4419edabb.tar.gz |
s390: Check UNDEFINED_WEAK_RESOLVED_TO_ZERO
Don't generate dynamic relocation against weak undefined symbol if
it is resolved to zero. FIXME: UNDEFINED_WEAK_RESOLVED_TO_ZERO may
need to be checked in more places.
PR ld/22269
* elf32-s390.c (allocate_dynrelocs): Discard dynamic
relocations if UNDEFINED_WEAK_RESOLVED_TO_ZERO is true.
(elf_s390_relocate_section): Don't generate dynamic relocation
if UNDEFINED_WEAK_RESOLVED_TO_ZERO is true.
* elf64-s390.c (allocate_dynrelocs): Discard dynamic
relocations if UNDEFINED_WEAK_RESOLVED_TO_ZERO is true.
(elf_s390_relocate_section): Don't generate dynamic relocation
if UNDEFINED_WEAK_RESOLVED_TO_ZERO is true.
-rw-r--r-- | bfd/elf32-s390.c | 10 | ||||
-rw-r--r-- | bfd/elf64-s390.c | 10 |
2 files changed, 16 insertions, 4 deletions
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index 36fedf9a24f..a44bdd2af3b 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -1773,7 +1773,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) if (eh->dyn_relocs != NULL && h->root.type == bfd_link_hash_undefweak) { - if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT) + if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT + || UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, h)) eh->dyn_relocs = NULL; /* Make sure undefined weak symbols are output as a dynamic @@ -2183,6 +2184,7 @@ elf_s390_relocate_section (bfd *output_bfd, bfd_reloc_status_type r; int tls_type; asection *base_got = htab->elf.sgot; + bfd_boolean resolved_to_zero; r_type = ELF32_R_TYPE (rel->r_info); if (r_type == (int) R_390_GNU_VTINHERIT @@ -2274,6 +2276,9 @@ elf_s390_relocate_section (bfd *output_bfd, if (bfd_link_relocatable (info)) continue; + resolved_to_zero = (h != NULL + && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, h)); + switch (r_type) { case R_390_GOTPLT12: @@ -2662,7 +2667,8 @@ elf_s390_relocate_section (bfd *output_bfd, if ((bfd_link_pic (info) && (h == NULL - || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + && !resolved_to_zero) || h->root.type != bfd_link_hash_undefweak) && ((r_type != R_390_PC16 && r_type != R_390_PC12DBL diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 898f2e816e1..2dd7bad8611 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -1710,7 +1710,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, if (eh->dyn_relocs != NULL && h->root.type == bfd_link_hash_undefweak) { - if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT) + if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT + || UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, h)) eh->dyn_relocs = NULL; /* Make sure undefined weak symbols are output as a dynamic @@ -2127,6 +2128,7 @@ elf_s390_relocate_section (bfd *output_bfd, bfd_reloc_status_type r; int tls_type; asection *base_got = htab->elf.sgot; + bfd_boolean resolved_to_zero; r_type = ELF64_R_TYPE (rel->r_info); if (r_type == (int) R_390_GNU_VTINHERIT @@ -2222,6 +2224,9 @@ elf_s390_relocate_section (bfd *output_bfd, if (bfd_link_relocatable (info)) continue; + resolved_to_zero = (h != NULL + && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, h)); + switch (r_type) { case R_390_GOTPLT12: @@ -2624,7 +2629,8 @@ elf_s390_relocate_section (bfd *output_bfd, if ((bfd_link_pic (info) && (h == NULL - || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + && !resolved_to_zero) || h->root.type != bfd_link_hash_undefweak) && ((r_type != R_390_PC16 && r_type != R_390_PC12DBL |