• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修订版74437ea28fb611d4c88077b486fd7c0a8b4c2a25 (tree)
时间2016-08-30 00:14:45
作者H.J. Lu <hjl.tools@gmai...>
CommiterH.J. Lu

Log Message

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.

更改概述

差异

--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
1+2016-08-29 H.J. Lu <hongjiu.lu@intel.com>
2+
3+ PR ld/14961
4+ PR ld/20515
5+ * elf32-i386.c (elf_i386_check_relocs): Issue an error when
6+ R_386_PC32 relocation is used to call IFUNC function in PIC
7+ object.
8+
19 2016-08-27 Alan Modra <amodra@gmail.com>
210
311 PR 20520
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -2178,6 +2178,20 @@ do_relocation:
21782178 a function defined in a shared library. */
21792179 if ((sec->flags & SEC_CODE) == 0)
21802180 h->pointer_equality_needed = 1;
2181+ else if (h->type == STT_GNU_IFUNC
2182+ && bfd_link_pic (info))
2183+ {
2184+ if (isym == NULL)
2185+ name = h->root.root.string;
2186+ else
2187+ name = bfd_elf_sym_name (abfd, symtab_hdr, isym,
2188+ NULL);
2189+ (*_bfd_error_handler)
2190+ (_("%B: unsupported non-PIC call to IFUNC `%s'"),
2191+ abfd, name);
2192+ bfd_set_error (bfd_error_bad_value);
2193+ goto error_return;
2194+ }
21812195 }
21822196 else
21832197 {
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,24 @@
1+2016-08-29 H.J. Lu <hongjiu.lu@intel.com>
2+
3+ PR ld/14961
4+ PR ld/20515
5+ * testsuite/ld-i386/i386.exp: Run pr20515.
6+ * testsuite/ld-i386/pr20515.d: New file.
7+ * testsuite/ld-i386/pr20515.s: Likewise.
8+ * testsuite/ld-ifunc/ifunc-14a.s: Use R_386_PLT32 to call IFUNC
9+ function.
10+ * testsuite/ld-ifunc/ifunc-14c.s: Likewise.
11+ * testsuite/ld-ifunc/ifunc-2-i386.s: Likewise.
12+ * testsuite/ld-ifunc/ifunc-2-local-i386.s: Likewise.
13+ * testsuite/ld-ifunc/ifunc.exp: Move PR ld/19784 tests to ...
14+ * testsuite/ld-x86-64/x86-64.exp: Here.
15+ * testsuite/ld-ifunc/pr19784a.c: Moved to ...
16+ * testsuite/ld-x86-64/pr19784a.c: Here.
17+ * testsuite/ld-ifunc/pr19784b.c: Moved to ...
18+ * testsuite/ld-x86-64/pr19784b.c: Here.
19+ * testsuite/ld-ifunc/pr19784c.c: Moved to ...
20+ * testsuite/ld-x86-64/pr19784c.c: Here.
21+
122 2016-08-26 Thomas Preud'homme <thomas.preudhomme@arm.com>
223
324 * emultempl/armelf.em (params): New static variable.
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -413,6 +413,7 @@ run_dump_test "pr20253-4a"
413413 run_dump_test "pr20253-4b"
414414 run_dump_test "pr20253-4c"
415415 run_dump_test "pr20253-5"
416+run_dump_test "pr20515"
416417
417418 if { !([istarget "i?86-*-linux*"]
418419 || [istarget "i?86-*-gnu*"]
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20515.d
@@ -0,0 +1,3 @@
1+#as: --32
2+#ld: -m elf_i386 -shared
3+#error: unsupported non-PIC call to IFUNC `foo'
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20515.s
@@ -0,0 +1,12 @@
1+ .text
2+ .globl bar
3+ .type bar, @function
4+bar:
5+ jmp foo
6+ .size bar, .-bar
7+ .hidden foo
8+ .type foo, %gnu_indirect_function
9+ .globl foo
10+foo:
11+ ret
12+ .size foo, .-foo
--- a/ld/testsuite/ld-ifunc/ifunc-14a.s
+++ b/ld/testsuite/ld-ifunc/ifunc-14a.s
@@ -2,6 +2,6 @@
22 .globl bar
33 .type bar, @function
44 bar:
5- jmp foo
5+ jmp foo@PLT
66 .size bar, .-bar
77 .hidden foo
--- a/ld/testsuite/ld-ifunc/ifunc-14c.s
+++ b/ld/testsuite/ld-ifunc/ifunc-14c.s
@@ -2,6 +2,6 @@
22 .globl xxx
33 .type xxx, @function
44 xxx:
5- jmp foo
5+ jmp foo@PLT
66 .size xxx, .-xxx
77 .hidden foo
--- a/ld/testsuite/ld-ifunc/ifunc-2-i386.s
+++ b/ld/testsuite/ld-ifunc/ifunc-2-i386.s
@@ -15,7 +15,7 @@ bar:
1515 .L6:
1616 popl %ebx
1717 addl $_GLOBAL_OFFSET_TABLE_+[.-.L6], %ebx
18- call __GI_foo
18+ call __GI_foo@PLT
1919 leal __GI_foo@GOTOFF(%ebx), %eax
2020 ret
2121 .size bar, .-bar
--- a/ld/testsuite/ld-ifunc/ifunc-2-local-i386.s
+++ b/ld/testsuite/ld-ifunc/ifunc-2-local-i386.s
@@ -12,7 +12,7 @@ bar:
1212 .L6:
1313 popl %ebx
1414 addl $_GLOBAL_OFFSET_TABLE_+[.-.L6], %ebx
15- call __GI_foo
15+ call __GI_foo@PLT
1616 leal __GI_foo@GOTOFF(%ebx), %eax
1717 ret
1818 .size bar, .-bar
--- a/ld/testsuite/ld-ifunc/ifunc.exp
+++ b/ld/testsuite/ld-ifunc/ifunc.exp
@@ -505,30 +505,6 @@ run_cc_link_tests [list \
505505 {} \
506506 "libpr18841c.so" \
507507 ] \
508- [list \
509- "Build libpr19784a.so" \
510- "-shared -Wl,-Bsymbolic-functions" \
511- "-fPIC -O2 -g" \
512- { pr19784b.c pr19784c.c } \
513- {} \
514- "libpr19784a.so" \
515- ] \
516- [list \
517- "Build libpr19784b.so" \
518- "-shared -Wl,-Bsymbolic-functions" \
519- "-fPIC -O2 -g" \
520- { pr19784c.c pr19784b.c } \
521- {} \
522- "libpr19784b.so" \
523- ] \
524- [list \
525- "Build pr19784a.o" \
526- "" \
527- "" \
528- { pr19784a.c } \
529- "" \
530- "" \
531- ] \
532508 ]
533509
534510 run_ld_link_exec_tests [list \
@@ -556,20 +532,4 @@ run_ld_link_exec_tests [list \
556532 "pr18841c" \
557533 "pr18841.out" \
558534 ] \
559- [list \
560- "Run pr19784a" \
561- "tmpdir/pr19784a.o tmpdir/libpr19784a.so" \
562- "" \
563- { dummy.c } \
564- "pr19784a" \
565- "pass.out" \
566- ] \
567- [list \
568- "Run pr19784b" \
569- "--as-needed tmpdir/pr19784a.o tmpdir/libpr19784b.so" \
570- "" \
571- { dummy.c } \
572- "pr19784b" \
573- "pass.out" \
574- ] \
575535 ]
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -822,6 +822,28 @@ if { [isnative] && [which $CC] != 0 } {
822822 {{objdump {-dw} pr19319.dd}} \
823823 "pr19319" \
824824 ] \
825+ [list \
826+ "Build libpr19784a.so" \
827+ "-shared -Wl,-Bsymbolic-functions" \
828+ "-fPIC -O2 -g" \
829+ { pr19784b.c pr19784c.c } \
830+ {} \
831+ "libpr19784a.so" \
832+ ] \
833+ [list \
834+ "Build libpr19784b.so" \
835+ "-shared -Wl,-Bsymbolic-functions" \
836+ "-fPIC -O2 -g" \
837+ { pr19784c.c pr19784b.c } \
838+ {} \
839+ "libpr19784b.so" \
840+ ] \
841+ [list \
842+ "Build pr19784a.o" \
843+ "" \
844+ "" \
845+ { pr19784a.c } \
846+ ] \
825847 ]
826848
827849 run_ld_link_exec_tests [list \
@@ -892,6 +914,22 @@ if { [isnative] && [which $CC] != 0 } {
892914 "gotpcrel1" \
893915 "gotpcrel1.out" \
894916 ] \
917+ [list \
918+ "Run pr19784a" \
919+ "tmpdir/pr19784a.o tmpdir/libpr19784a.so" \
920+ "" \
921+ { dummy.s } \
922+ "pr19784a" \
923+ "pass.out" \
924+ ] \
925+ [list \
926+ "Run pr19784b" \
927+ "--as-needed tmpdir/pr19784a.o tmpdir/libpr19784b.so" \
928+ "" \
929+ { dummy.s } \
930+ "pr19784b" \
931+ "pass.out" \
932+ ] \
895933 ]
896934
897935 if { [istarget "x86_64-*-linux*"] \