aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf64-s390.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-10-14 11:06:00 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-10-14 11:06:20 -0700
commitb27bb18f45a99330600ab57892c3620343425910 (patch)
treea884aaff24c67884c4cfc27ad31f91dec4613914 /bfd/elf64-s390.c
parent31a53da5418528b9ba94bb80a97f0084f40e0c64 (diff)
downloadgdb-b27bb18f45a99330600ab57892c3620343425910.zip
gdb-b27bb18f45a99330600ab57892c3620343425910.tar.gz
gdb-b27bb18f45a99330600ab57892c3620343425910.tar.bz2
s390: Check UNDEFWEAK_NO_DYNAMIC_RELOC
Don't generate dynamic relocation against weak undefined symbol if it is resolved to zero. FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be checked in more places. PR ld/22269 * elf32-s390.c (allocate_dynrelocs): Discard dynamic relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true. (elf_s390_relocate_section): Don't generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true. * elf64-s390.c (allocate_dynrelocs): Discard dynamic relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true. (elf_s390_relocate_section): Don't generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
Diffstat (limited to 'bfd/elf64-s390.c')
-rw-r--r--bfd/elf64-s390.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index 73d0331..c126880 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -1890,7 +1890,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
+ || UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
eh->dyn_relocs = NULL;
/* Make sure undefined weak symbols are output as a dynamic
@@ -2307,6 +2308,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
@@ -2402,6 +2404,9 @@ elf_s390_relocate_section (bfd *output_bfd,
if (bfd_link_relocatable (info))
continue;
+ resolved_to_zero = (h != NULL
+ && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h));
+
switch (r_type)
{
case R_390_GOTPLT12:
@@ -2804,7 +2809,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