aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf64-x86-64.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2016-01-30 14:11:03 -0800
committerH.J. Lu <hjl.tools@gmail.com>2016-01-30 16:08:20 -0800
commitd9e3b590692e62d83c21e39ec6641c4c09e70e4c (patch)
tree346f0b0fb8d8b63b09565b53c0bbb19a8ec5986f /bfd/elf64-x86-64.c
parent654ec4010a45077280a8d97f24c153f289eb62ed (diff)
downloadgdb-d9e3b590692e62d83c21e39ec6641c4c09e70e4c.zip
gdb-d9e3b590692e62d83c21e39ec6641c4c09e70e4c.tar.gz
gdb-d9e3b590692e62d83c21e39ec6641c4c09e70e4c.tar.bz2
Check reloc against IFUNC symbol only with dynamic symbols
There is no need to check relocation IFUNC symbol if there are no dynamic symbols. bfd/ PR ld/19539 * elf32-i386.c (elf_i386_reloc_type_class): Check relocation against STT_GNU_IFUNC symbol only with dynamic symbols. * elf64-x86-64.c (elf_x86_64_reloc_type_class): Likewise. ld/ PR ld/19539 * testsuite/ld-elf/pr19539.d: New file. * testsuite/ld-elf/pr19539.s: Likewise. * testsuite/ld-elf/pr19539.t: Likewise.
Diffstat (limited to 'bfd/elf64-x86-64.c')
-rw-r--r--bfd/elf64-x86-64.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index bbdb03a..37528be 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -5728,19 +5728,23 @@ elf_x86_64_reloc_type_class (const struct bfd_link_info *info,
bfd *abfd = info->output_bfd;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
struct elf_x86_64_link_hash_table *htab = elf_x86_64_hash_table (info);
- unsigned long r_symndx = htab->r_sym (rela->r_info);
- Elf_Internal_Sym sym;
-
- if (htab->elf.dynsym == NULL
- || !bed->s->swap_symbol_in (abfd,
- (htab->elf.dynsym->contents
- + r_symndx * bed->s->sizeof_sym),
- 0, &sym))
- abort ();
- /* Check relocation against STT_GNU_IFUNC symbol. */
- if (ELF_ST_TYPE (sym.st_info) == STT_GNU_IFUNC)
- return reloc_class_ifunc;
+ if (htab->elf.dynsym != NULL
+ && htab->elf.dynsym->contents != NULL)
+ {
+ /* Check relocation against STT_GNU_IFUNC symbol if there are
+ dynamic symbols. */
+ unsigned long r_symndx = htab->r_sym (rela->r_info);
+ Elf_Internal_Sym sym;
+ if (!bed->s->swap_symbol_in (abfd,
+ (htab->elf.dynsym->contents
+ + r_symndx * bed->s->sizeof_sym),
+ 0, &sym))
+ abort ();
+
+ if (ELF_ST_TYPE (sym.st_info) == STT_GNU_IFUNC)
+ return reloc_class_ifunc;
+ }
switch ((int) ELF32_R_TYPE (rela->r_info))
{