• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
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

Revision347a87745eab23d8427349787bde4a938a1e8c3e (tree)
Time2018-03-08 23:36:52
AuthorH.J. Lu <hjl.tools@gmai...>
CommiterH.J. Lu

Log Message

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.

Change Summary

Incremental Difference

--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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+
19 2018-03-07 Renlin Li <renlin.li@arm.com>
210
311 PR ld/20402
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -2221,6 +2221,10 @@ elf_i386_relocate_section (bfd *output_bfd,
22212221
22222222 if ((input_section->flags & SEC_ALLOC) == 0)
22232223 {
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;
22242228 /* Dynamic relocs are not propagated for SEC_DEBUGGING
22252229 sections because such sections are not SEC_ALLOC and
22262230 thus ld.so will not process them. */
@@ -2440,6 +2444,7 @@ do_ifunc_pointer:
24402444 }
24412445 }
24422446
2447+skip_ifunc:
24432448 resolved_to_zero = (eh != NULL
24442449 && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
24452450
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2503,6 +2503,10 @@ elf_x86_64_relocate_section (bfd *output_bfd,
25032503
25042504 if ((input_section->flags & SEC_ALLOC) == 0)
25052505 {
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;
25062510 /* Dynamic relocs are not propagated for SEC_DEBUGGING
25072511 sections because such sections are not SEC_ALLOC and
25082512 thus ld.so will not process them. */
@@ -2726,6 +2730,7 @@ do_ifunc_pointer:
27262730 }
27272731 }
27282732
2733+skip_ifunc:
27292734 resolved_to_zero = (eh != NULL
27302735 && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
27312736
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -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+
111 2018-03-07 Max Filippov <jcmvbkbc@gmail.com>
212
313 * emulparams/elf32xtensa.sh (COMMONPAGESIZE): Define.
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -459,6 +459,7 @@ run_dump_test "pr22115-1c"
459459 run_dump_test "pr22115-1d"
460460 run_dump_test "pr22135"
461461 run_dump_test "pr22782"
462+run_dump_test "pr22929"
462463
463464 if { !([istarget "i?86-*-linux*"]
464465 || [istarget "i?86-*-gnu*"]
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr22929.d
@@ -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+#...
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr22929.s
@@ -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
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr22929.d
@@ -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+#...
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr22929.s
@@ -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
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -605,6 +605,7 @@ run_dump_test "pr20253-5a"
605605 run_dump_test "pr20253-5b"
606606 run_dump_test "tlsdesc2"
607607 run_dump_test "pr22048"
608+run_dump_test "pr22929"
608609
609610 proc undefined_weak {cflags ldflags} {
610611 set testname "Undefined weak symbol"