aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-tilepro.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-10-14 10:25:33 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-10-14 10:25:48 -0700
commita3cd202aae50abe5a571fb8c186b6b6af68edce2 (patch)
treee01ff6c0970a03aab3ba5f323c6f0e08982f7f0d /bfd/elf32-tilepro.c
parentddb7fd0f7b43e4c755c4b8c7752948e050363525 (diff)
downloadgdb-a3cd202aae50abe5a571fb8c186b6b6af68edce2.zip
gdb-a3cd202aae50abe5a571fb8c186b6b6af68edce2.tar.gz
gdb-a3cd202aae50abe5a571fb8c186b6b6af68edce2.tar.bz2
tile: 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-tilepro.c (allocate_dynrelocs): Discard dynamic relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true. (tilepro_elf_relocate_section): Don't generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true. * elfxx-tilegx.c (allocate_dynrelocs): Discard dynamic relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true. (tilegx_elf_relocate_section): Don't generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
Diffstat (limited to 'bfd/elf32-tilepro.c')
-rw-r--r--bfd/elf32-tilepro.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/bfd/elf32-tilepro.c b/bfd/elf32-tilepro.c
index 75a7de5..ad22335 100644
--- a/bfd/elf32-tilepro.c
+++ b/bfd/elf32-tilepro.c
@@ -2332,7 +2332,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
+ || UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
eh->dyn_relocs = NULL;
/* Make sure undefined weak symbols are output as a dynamic
@@ -2860,7 +2861,7 @@ tilepro_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
const char *name;
bfd_vma off;
bfd_boolean is_plt = FALSE;
-
+ bfd_boolean resolved_to_zero;
bfd_boolean unresolved_reloc;
r_type = ELF32_R_TYPE (rel->r_info);
@@ -3035,6 +3036,9 @@ tilepro_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
break;
}
+ resolved_to_zero = (h != NULL
+ && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h));
+
switch (r_type)
{
case R_TILEPRO_IMM16_X0_GOT:
@@ -3203,7 +3207,8 @@ tilepro_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
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)
&& (! howto->pc_relative
|| !SYMBOL_CALLS_LOCAL (info, h)))