aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf64-x86-64.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2011-01-06 18:45:05 +0000
committerH.J. Lu <hjl.tools@gmail.com>2011-01-06 18:45:05 +0000
commit3db2e7dda697d71311d698f21d7c65b8ec1774ca (patch)
tree673b7abbfab3b1b454a5d9677950f0a919ca83d1 /bfd/elf64-x86-64.c
parentccfc3d6e06d5b9d2ebd8b8e4239f1313e33f40ac (diff)
downloadgdb-3db2e7dda697d71311d698f21d7c65b8ec1774ca.zip
gdb-3db2e7dda697d71311d698f21d7c65b8ec1774ca.tar.gz
gdb-3db2e7dda697d71311d698f21d7c65b8ec1774ca.tar.bz2
Handle STT_GNU_IFUNC symols when building shared library.
bfd/ 2012-01-06 H.J. Lu <hongjiu.lu@intel.com> PR ld/12366 PR ld/12371 * elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Properly handle symbols marked with regular reference, but not non-GOT reference when building shared library. * elf32-i386.c (elf_i386_gc_sweep_hook): Properly handle local and global STT_GNU_IFUNC symols when building shared library. * elf64-x86-64.c (elf_x86_64_gc_sweep_hook): Likewise. ld/testsuite/ 2012-01-06 H.J. Lu <hongjiu.lu@intel.com> PR ld/12366 PR ld/12371 * ld-ifunc/ifunc-10-i386.s: Add more tests. * ld-ifunc/ifunc-10-x86-64.s: Likewise. * ld-ifunc/ifunc-11-i386.s: Likewise. * ld-ifunc/ifunc-11-x86-64.s: Likewise. * ld-ifunc/ifunc-12-i386.d: New. * ld-ifunc/ifunc-12-i386.s: Likewise. * ld-ifunc/ifunc-12-x86-64.d: Likewise. * ld-ifunc/ifunc-12-x86-64.s: Likewise. * ld-ifunc/ifunc-13-i386.d: Likewise. * ld-ifunc/ifunc-13-x86-64.d: Likewise. * ld-ifunc/ifunc-13a-i386.s: Likewise. * ld-ifunc/ifunc-13a-x86-64.s: Likewise. * ld-ifunc/ifunc-13b-i386.s: Likewise. * ld-ifunc/ifunc-13b-x86-64.s: Likewise.
Diffstat (limited to 'bfd/elf64-x86-64.c')
-rw-r--r--bfd/elf64-x86-64.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 3dd16ba..ceb1a0a 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -1684,23 +1684,10 @@ elf_x86_64_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info,
r_symndx = htab->r_sym (rel->r_info);
if (r_symndx >= symtab_hdr->sh_info)
{
- struct elf_x86_64_link_hash_entry *eh;
- struct elf_dyn_relocs **pp;
- struct elf_dyn_relocs *p;
-
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
while (h->root.type == bfd_link_hash_indirect
|| h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
- eh = (struct elf_x86_64_link_hash_entry *) h;
-
- for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
- if (p->sec == sec)
- {
- /* Everything must go for SEC. */
- *pp = p->next;
- break;
- }
}
else
{
@@ -1720,6 +1707,23 @@ elf_x86_64_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info,
}
}
+ if (h)
+ {
+ struct elf_x86_64_link_hash_entry *eh;
+ struct elf_dyn_relocs **pp;
+ struct elf_dyn_relocs *p;
+
+ eh = (struct elf_x86_64_link_hash_entry *) h;
+
+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
+ if (p->sec == sec)
+ {
+ /* Everything must go for SEC. */
+ *pp = p->next;
+ break;
+ }
+ }
+
r_type = ELF32_R_TYPE (rel->r_info);
if (! elf_x86_64_tls_transition (info, abfd, sec, NULL,
symtab_hdr, sym_hashes,
@@ -1771,7 +1775,8 @@ elf_x86_64_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info,
case R_X86_64_PC16:
case R_X86_64_PC32:
case R_X86_64_PC64:
- if (info->shared)
+ if (info->shared
+ && (h == NULL || h->type != STT_GNU_IFUNC))
break;
/* Fall thru */