From 9d734efa1034d266249751978f95a686ec9d19c6 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 14 Nov 2016 10:13:03 -0800 Subject: Also check GOT PLT for R_X86_64_PLTOFF64 Since "-z now" replaces PLT with GOT PLT, we should also check GOT PLT for R_X86_64_PLTOFF64 relocation. bfd/ PR ld/20800 * elf64-x86-64.c (elf_x86_64_relocate_section): Also check plt_got.offset for R_X86_64_PLTOFF64. ld/ PR ld/20800 * testsuite/ld-x86-64/pr20800a.S: New file. * testsuite/ld-x86-64/pr20800b.S: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run PR ld/20800 test. --- bfd/ChangeLog | 6 ++++++ bfd/elf64-x86-64.c | 11 +++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'bfd') diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 521e319..b8ae634 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2016-11-14 H.J. Lu + + PR ld/20800 + * elf64-x86-64.c (elf_x86_64_relocate_section): Also check + plt_got.offset for R_X86_64_PLTOFF64. + 2016-11-14 Nick Clifton * coffcode.h (coff_slurp_symbol_table): Fix typo: Faal -> Fall. diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 76f09bd..05a4776 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -4693,10 +4693,17 @@ do_ifunc_pointer: symbols it's the symbol itself relative to GOT. */ if (h != NULL /* See PLT32 handling. */ - && h->plt.offset != (bfd_vma) -1 + && (h->plt.offset != (bfd_vma) -1 + || eh->plt_got.offset != (bfd_vma) -1) && htab->elf.splt != NULL) { - if (htab->plt_bnd != NULL) + if (eh->plt_got.offset != (bfd_vma) -1) + { + /* Use the GOT PLT. */ + resolved_plt = htab->plt_got; + plt_offset = eh->plt_got.offset; + } + else if (htab->plt_bnd != NULL) { resolved_plt = htab->plt_bnd; plt_offset = eh->plt_bnd.offset; -- cgit v1.1