diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2016-08-29 08:12:59 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2016-08-29 08:14:45 -0700 |
commit | 74437ea28fb611d4c88077b486fd7c0a8b4c2a25 (patch) | |
tree | 9260072fac164803e6f715c593fe5a7d2e500c2e /bfd | |
parent | 7fac69100a7c1fb52b2e044294a858272bad4e46 (diff) | |
download | gdb-74437ea28fb611d4c88077b486fd7c0a8b4c2a25.zip gdb-74437ea28fb611d4c88077b486fd7c0a8b4c2a25.tar.gz gdb-74437ea28fb611d4c88077b486fd7c0a8b4c2a25.tar.bz2 |
i386: Issue an error on non-PIC call to IFUNC in PIC object
On i386, IFUNC function must be called via PLT. Since PLT in PIC
object uses EBX register, R_386_PLT32 relocation must be used to
call IFUNC function even when IFUNC function is defined locally.
Linker should issue an error when R_386_PC32 relocation is used
to call IFUNC function.
Since PR ld/19784 tests doesn't use PLT relocation to local IFUNC
function, they are moved to the x86-64 test directory.
bfd/
PR ld/14961
PR ld/20515
* elf32-i386.c (elf_i386_check_relocs): Issue an error when
R_386_PC32 relocation is used to call IFUNC function in PIC
object.
ld/
PR ld/14961
PR ld/20515
* testsuite/ld-i386/i386.exp: Run pr20515.
* testsuite/ld-i386/pr20515.d: New file.
* testsuite/ld-i386/pr20515.s: Likewise.
* testsuite/ld-ifunc/ifunc-14a.s: Use R_386_PLT32 to call IFUNC
function.
* testsuite/ld-ifunc/ifunc-14c.s: Likewise.
* testsuite/ld-ifunc/ifunc-2-i386.s: Likewise.
* testsuite/ld-ifunc/ifunc-2-local-i386.s: Likewise.
* testsuite/ld-ifunc/ifunc.exp: Move PR ld/19784 tests to ...
* testsuite/ld-x86-64/x86-64.exp: Here.
* testsuite/ld-ifunc/pr19784a.c: Moved to ...
* testsuite/ld-x86-64/pr19784a.c: Here.
* testsuite/ld-ifunc/pr19784b.c: Moved to ...
* testsuite/ld-x86-64/pr19784b.c: Here.
* testsuite/ld-ifunc/pr19784c.c: Moved to ...
* testsuite/ld-x86-64/pr19784c.c: Here.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 8 | ||||
-rw-r--r-- | bfd/elf32-i386.c | 14 |
2 files changed, 22 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index ef771a9..68a23d1 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,11 @@ +2016-08-29 H.J. Lu <hongjiu.lu@intel.com> + + PR ld/14961 + PR ld/20515 + * elf32-i386.c (elf_i386_check_relocs): Issue an error when + R_386_PC32 relocation is used to call IFUNC function in PIC + object. + 2016-08-27 Alan Modra <amodra@gmail.com> PR 20520 diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 4179572..17f86e8 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -2178,6 +2178,20 @@ do_relocation: a function defined in a shared library. */ if ((sec->flags & SEC_CODE) == 0) h->pointer_equality_needed = 1; + else if (h->type == STT_GNU_IFUNC + && bfd_link_pic (info)) + { + if (isym == NULL) + name = h->root.root.string; + else + name = bfd_elf_sym_name (abfd, symtab_hdr, isym, + NULL); + (*_bfd_error_handler) + (_("%B: unsupported non-PIC call to IFUNC `%s'"), + abfd, name); + bfd_set_error (bfd_error_bad_value); + goto error_return; + } } else { |