GNU Binutils with patches for OS216
Revision | 347a87745eab23d8427349787bde4a938a1e8c3e (tree) |
---|---|
Time | 2018-03-08 23:36:52 |
Author | H.J. Lu <hjl.tools@gmai...> |
Commiter | H.J. Lu |
x86: Treat relocation against IFUNC symbol as FUNC
When resolving a relocation against IFUNC symbol in a SHT_NOTE section
without SHF_ALLOC, we treat it as relocation against FUNC symbol since
it needs the address of IFUNC symbol, not the address returned by IFUNC
function.
bfd/
PR ld/22929
* elf32-i386.c (elf_i386_relocate_section): Treat relocation
against IFUNC symbol in SHT_NOTE section without SHF_ALLOC as
relocation against FUNC symbol.
* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
ld/
PR ld/22929
* testsuite/ld-i386/i386.exp: Run PR ld/22929 test.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr22929.d: New file.
* testsuite/ld-i386/pr22929.s: Likewise.
* testsuite/ld-x86-64/pr22929.d: Likewise.
* testsuite/ld-x86-64/pr22929.s: Likewise.
@@ -1,3 +1,11 @@ | ||
1 | +2018-03-08 H.J. Lu <hongjiu.lu@intel.com> | |
2 | + | |
3 | + PR ld/22929 | |
4 | + * elf32-i386.c (elf_i386_relocate_section): Treat relocation | |
5 | + against IFUNC symbol in SHT_NOTE section without SHF_ALLOC as | |
6 | + relocation against FUNC symbol. | |
7 | + * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise. | |
8 | + | |
1 | 9 | 2018-03-07 Renlin Li <renlin.li@arm.com> |
2 | 10 | |
3 | 11 | PR ld/20402 |
@@ -2221,6 +2221,10 @@ elf_i386_relocate_section (bfd *output_bfd, | ||
2221 | 2221 | |
2222 | 2222 | if ((input_section->flags & SEC_ALLOC) == 0) |
2223 | 2223 | { |
2224 | + /* If this is a SHT_NOTE section without SHF_ALLOC, treat | |
2225 | + STT_GNU_IFUNC symbol as STT_FUNC. */ | |
2226 | + if (elf_section_type (input_section) == SHT_NOTE) | |
2227 | + goto skip_ifunc; | |
2224 | 2228 | /* Dynamic relocs are not propagated for SEC_DEBUGGING |
2225 | 2229 | sections because such sections are not SEC_ALLOC and |
2226 | 2230 | thus ld.so will not process them. */ |
@@ -2440,6 +2444,7 @@ do_ifunc_pointer: | ||
2440 | 2444 | } |
2441 | 2445 | } |
2442 | 2446 | |
2447 | +skip_ifunc: | |
2443 | 2448 | resolved_to_zero = (eh != NULL |
2444 | 2449 | && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh)); |
2445 | 2450 |
@@ -2503,6 +2503,10 @@ elf_x86_64_relocate_section (bfd *output_bfd, | ||
2503 | 2503 | |
2504 | 2504 | if ((input_section->flags & SEC_ALLOC) == 0) |
2505 | 2505 | { |
2506 | + /* If this is a SHT_NOTE section without SHF_ALLOC, treat | |
2507 | + STT_GNU_IFUNC symbol as STT_FUNC. */ | |
2508 | + if (elf_section_type (input_section) == SHT_NOTE) | |
2509 | + goto skip_ifunc; | |
2506 | 2510 | /* Dynamic relocs are not propagated for SEC_DEBUGGING |
2507 | 2511 | sections because such sections are not SEC_ALLOC and |
2508 | 2512 | thus ld.so will not process them. */ |
@@ -2726,6 +2730,7 @@ do_ifunc_pointer: | ||
2726 | 2730 | } |
2727 | 2731 | } |
2728 | 2732 | |
2733 | +skip_ifunc: | |
2729 | 2734 | resolved_to_zero = (eh != NULL |
2730 | 2735 | && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh)); |
2731 | 2736 |
@@ -1,3 +1,13 @@ | ||
1 | +2018-03-08 H.J. Lu <hongjiu.lu@intel.com> | |
2 | + | |
3 | + PR ld/22929 | |
4 | + * testsuite/ld-i386/i386.exp: Run PR ld/22929 test. | |
5 | + * testsuite/ld-x86-64/x86-64.exp: Likewise. | |
6 | + * testsuite/ld-i386/pr22929.d: New file. | |
7 | + * testsuite/ld-i386/pr22929.s: Likewise. | |
8 | + * testsuite/ld-x86-64/pr22929.d: Likewise. | |
9 | + * testsuite/ld-x86-64/pr22929.s: Likewise. | |
10 | + | |
1 | 11 | 2018-03-07 Max Filippov <jcmvbkbc@gmail.com> |
2 | 12 | |
3 | 13 | * emulparams/elf32xtensa.sh (COMMONPAGESIZE): Define. |
@@ -459,6 +459,7 @@ run_dump_test "pr22115-1c" | ||
459 | 459 | run_dump_test "pr22115-1d" |
460 | 460 | run_dump_test "pr22135" |
461 | 461 | run_dump_test "pr22782" |
462 | +run_dump_test "pr22929" | |
462 | 463 | |
463 | 464 | if { !([istarget "i?86-*-linux*"] |
464 | 465 | || [istarget "i?86-*-gnu*"] |
@@ -0,0 +1,11 @@ | ||
1 | +#as: --32 | |
2 | +#ld: -melf_i386 -shared | |
3 | +#readelf: -r --wide -s | |
4 | + | |
5 | +There are no relocations in this file. | |
6 | +#... | |
7 | +Symbol table '.symtab' contains [0-9]+ entries: | |
8 | + Num: Value Size Type Bind Vis Ndx Name | |
9 | +#... | |
10 | +[ \t]+[a-f0-9]+: [a-f0-9]+ +1 IFUNC +GLOBAL DEFAULT +[a-f0-9]+ +foo | |
11 | +#... |
@@ -0,0 +1,21 @@ | ||
1 | + .text | |
2 | + .globl foo | |
3 | + .type foo, %gnu_indirect_function | |
4 | +foo: | |
5 | + ret | |
6 | + .size foo, .-foo | |
7 | + .pushsection .gnu.build.attributes, "", %note | |
8 | + .dc.l 6 # size of name | |
9 | + .dc.l 16 # descsz = sizeof (addresses) | |
10 | + .dc.l 0x101 # type = FUNC | |
11 | + .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0 # name (numeric: -fstack-protector status) | |
12 | + .dc.b 0, 0 # Padding | |
13 | + .dc.a foo | |
14 | + .dc.a foo_end # description (symbol name) | |
15 | + .popsection | |
16 | + | |
17 | +foo_end: | |
18 | + .section .rodata.cst4,"aM",@progbits,4 | |
19 | + .align 4 | |
20 | +.LC0: | |
21 | + .long 1065353216 |
@@ -0,0 +1,11 @@ | ||
1 | +#as: --64 | |
2 | +#ld: -melf_x86_64 -shared | |
3 | +#readelf: -r --wide -s | |
4 | + | |
5 | +There are no relocations in this file. | |
6 | +#... | |
7 | +Symbol table '.symtab' contains [0-9]+ entries: | |
8 | + Num: Value Size Type Bind Vis Ndx Name | |
9 | +#... | |
10 | +[ \t]+[a-f0-9]+: [a-f0-9]+ +1 IFUNC +GLOBAL DEFAULT +[a-f0-9]+ +foo | |
11 | +#... |
@@ -0,0 +1,21 @@ | ||
1 | + .text | |
2 | + .globl foo | |
3 | + .type foo, %gnu_indirect_function | |
4 | +foo: | |
5 | + ret | |
6 | + .size foo, .-foo | |
7 | + .pushsection .gnu.build.attributes, "", %note | |
8 | + .dc.l 6 # size of name | |
9 | + .dc.l 16 # descsz = sizeof (addresses) | |
10 | + .dc.l 0x101 # type = FUNC | |
11 | + .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0 # name (numeric: -fstack-protector status) | |
12 | + .dc.b 0, 0 # Padding | |
13 | + .dc.a foo | |
14 | + .dc.a foo_end # description (symbol name) | |
15 | + .popsection | |
16 | + | |
17 | +foo_end: | |
18 | + .section .rodata.cst4,"aM",@progbits,4 | |
19 | + .align 4 | |
20 | +.LC0: | |
21 | + .long 1065353216 |
@@ -605,6 +605,7 @@ run_dump_test "pr20253-5a" | ||
605 | 605 | run_dump_test "pr20253-5b" |
606 | 606 | run_dump_test "tlsdesc2" |
607 | 607 | run_dump_test "pr22048" |
608 | +run_dump_test "pr22929" | |
608 | 609 | |
609 | 610 | proc undefined_weak {cflags ldflags} { |
610 | 611 | set testname "Undefined weak symbol" |