Properly match PLT entry against .got.plt relocation
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 16 Jul 2014 15:16:24 +0000 (08:16 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 16 Jul 2014 17:57:49 +0000 (10:57 -0700)
commit144bed8d4d8a1bdc0067f55f2ee71c07e5594677
treed4f7b7298150ad44133ef5b04eaa363f045225d3
parent4d974e8854dbc506f154efca8879da3f310bb2b9
Properly match PLT entry against .got.plt relocation

Relocations against .got.plt section may not be in the same order as
entries in PLT section.  It is incorrect to assume that the Ith reloction
index against .got.plt section always maps to the (I + 1)th entry in PLT
section.  This patch matches the .got.plt relocation offset/index in PLT
entry against the index in .got.plt relocation table.  It only checks
R_*_JUMP_SLOT and R_*_IRELATIVE relocations.  It ignores R_*_TLS_DESC
and R_*_TLSDESC relocations since they have different PLT entries.

bfd/

PR binutils/17154
* elf32-i386.c (elf_i386_plt_sym_val): Only match R_*_JUMP_SLOT
and R_*_IRELATIVE relocation offset with PLT entry.
* elf64-x86-64.c (elf_x86_64_plt_sym_val): Likewise.
(elf_x86_64_plt_sym_val_offset_plt_bnd): New.
(elf_x86_64_get_synthetic_symtab): Use it.

ld/testsuite/

PR binutils/17154
* ld-ifunc/pr17154-i386.d: New file.
* ld-ifunc/pr17154-x86-64.d: Likewise.
* ld-ifunc/pr17154-x86.s: Likewise.
* ld-x86-64/bnd-ifunc-2.d: Likewise.
* ld-x86-64/bnd-ifunc-2.s: Likewise.
* ld-x86-64/mpx.exp: Run bnd-ifunc-2.
* ld-x86-64/tlsdesc-nacl.pd: Updated.
* ld-x86-64/tlsdesc.pd: Likewise.
12 files changed:
bfd/ChangeLog
bfd/elf32-i386.c
bfd/elf64-x86-64.c
ld/testsuite/ChangeLog
ld/testsuite/ld-ifunc/pr17154-i386.d [new file with mode: 0644]
ld/testsuite/ld-ifunc/pr17154-x86-64.d [new file with mode: 0644]
ld/testsuite/ld-ifunc/pr17154-x86.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/bnd-ifunc-2.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/bnd-ifunc-2.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/mpx.exp
ld/testsuite/ld-x86-64/tlsdesc-nacl.pd
ld/testsuite/ld-x86-64/tlsdesc.pd