GNU Binutils with patches for OS216
修订版 | 74437ea28fb611d4c88077b486fd7c0a8b4c2a25 (tree) |
---|---|
时间 | 2016-08-30 00:14:45 |
作者 | H.J. Lu <hjl.tools@gmai...> |
Commiter | H.J. Lu |
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.
@@ -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 | + | |
1 | 9 | 2016-08-27 Alan Modra <amodra@gmail.com> |
2 | 10 | |
3 | 11 | PR 20520 |
@@ -2178,6 +2178,20 @@ do_relocation: | ||
2178 | 2178 | a function defined in a shared library. */ |
2179 | 2179 | if ((sec->flags & SEC_CODE) == 0) |
2180 | 2180 | 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 | + } | |
2181 | 2195 | } |
2182 | 2196 | else |
2183 | 2197 | { |
@@ -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 | + | |
1 | 22 | 2016-08-26 Thomas Preud'homme <thomas.preudhomme@arm.com> |
2 | 23 | |
3 | 24 | * emultempl/armelf.em (params): New static variable. |
@@ -413,6 +413,7 @@ run_dump_test "pr20253-4a" | ||
413 | 413 | run_dump_test "pr20253-4b" |
414 | 414 | run_dump_test "pr20253-4c" |
415 | 415 | run_dump_test "pr20253-5" |
416 | +run_dump_test "pr20515" | |
416 | 417 | |
417 | 418 | if { !([istarget "i?86-*-linux*"] |
418 | 419 | || [istarget "i?86-*-gnu*"] |
@@ -0,0 +1,3 @@ | ||
1 | +#as: --32 | |
2 | +#ld: -m elf_i386 -shared | |
3 | +#error: unsupported non-PIC call to IFUNC `foo' |
@@ -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 |
@@ -2,6 +2,6 @@ | ||
2 | 2 | .globl bar |
3 | 3 | .type bar, @function |
4 | 4 | bar: |
5 | - jmp foo | |
5 | + jmp foo@PLT | |
6 | 6 | .size bar, .-bar |
7 | 7 | .hidden foo |
@@ -2,6 +2,6 @@ | ||
2 | 2 | .globl xxx |
3 | 3 | .type xxx, @function |
4 | 4 | xxx: |
5 | - jmp foo | |
5 | + jmp foo@PLT | |
6 | 6 | .size xxx, .-xxx |
7 | 7 | .hidden foo |
@@ -15,7 +15,7 @@ bar: | ||
15 | 15 | .L6: |
16 | 16 | popl %ebx |
17 | 17 | addl $_GLOBAL_OFFSET_TABLE_+[.-.L6], %ebx |
18 | - call __GI_foo | |
18 | + call __GI_foo@PLT | |
19 | 19 | leal __GI_foo@GOTOFF(%ebx), %eax |
20 | 20 | ret |
21 | 21 | .size bar, .-bar |
@@ -12,7 +12,7 @@ bar: | ||
12 | 12 | .L6: |
13 | 13 | popl %ebx |
14 | 14 | addl $_GLOBAL_OFFSET_TABLE_+[.-.L6], %ebx |
15 | - call __GI_foo | |
15 | + call __GI_foo@PLT | |
16 | 16 | leal __GI_foo@GOTOFF(%ebx), %eax |
17 | 17 | ret |
18 | 18 | .size bar, .-bar |
@@ -505,30 +505,6 @@ run_cc_link_tests [list \ | ||
505 | 505 | {} \ |
506 | 506 | "libpr18841c.so" \ |
507 | 507 | ] \ |
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 | - ] \ | |
532 | 508 | ] |
533 | 509 | |
534 | 510 | run_ld_link_exec_tests [list \ |
@@ -556,20 +532,4 @@ run_ld_link_exec_tests [list \ | ||
556 | 532 | "pr18841c" \ |
557 | 533 | "pr18841.out" \ |
558 | 534 | ] \ |
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 | - ] \ | |
575 | 535 | ] |
@@ -822,6 +822,28 @@ if { [isnative] && [which $CC] != 0 } { | ||
822 | 822 | {{objdump {-dw} pr19319.dd}} \ |
823 | 823 | "pr19319" \ |
824 | 824 | ] \ |
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 | + ] \ | |
825 | 847 | ] |
826 | 848 | |
827 | 849 | run_ld_link_exec_tests [list \ |
@@ -892,6 +914,22 @@ if { [isnative] && [which $CC] != 0 } { | ||
892 | 914 | "gotpcrel1" \ |
893 | 915 | "gotpcrel1.out" \ |
894 | 916 | ] \ |
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 | + ] \ | |
895 | 933 | ] |
896 | 934 | |
897 | 935 | if { [istarget "x86_64-*-linux*"] \ |