• 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

Revisionf657f8c4a1dc0ac69b16b1dc6eacbf5286f1f0a0 (tree)
Time2018-03-09 23:37:36
AuthorNick Clifton <nickc@redh...>
CommiterNick Clifton

Log Message

Fix Sparc, s390 and AArch64 targets so that they can handle relocs against ifunc symbols found in note sections.

Following on from PR 22929, I have found the same problem exists with
other ifunc supporting targets too. Plus see this link for the bug
being reported against the s390x binutils for Fedora rawhide:
So I am going to check in the patch below which applies the same
change that H.J. made for the x86_64 target to the other affected
  1. (Specifically: S390, AArch64 and Sparc). Plus it adds a new
    test to the linker testsuite to make sure that this problem stays
    fixed.

bfd * elf64-s390.c (elf_s390_relocate_section): Move check for
relocations against non-allocated sections to before the code that
handles ifunc relocations.
* elf32-s390.c (elf_s390_relocate_section): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Treat
relocs against IFUNC symbols in non-allocated sections as relocs
against FUNC symbols.
* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Likewise.

ld * testsuite/ld-ifunc/ifuncmod5.s: New test. Checks that targets
that support IFUNC symbols can handle relocations against those
symbols in NOTE sections.
* testsuite/ld-ifunc/ifuncmod5.d: New file: Driver for the new
test.
* testsuite/ld-ifunc/ifunc.exp: Run the new test.

Change Summary

Incremental Difference

--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,14 @@
1+2018-03-09 Nick Clifton <nickc@redhat.com>
2+
3+ * elf64-s390.c (elf_s390_relocate_section): Move check for
4+ relocations against non-allocated sections to before the code that
5+ handles ifunc relocations.
6+ * elf32-s390.c (elf_s390_relocate_section): Likewise.
7+ * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Treat
8+ relocs against IFUNC symbols in non-allocated sections as relocs
9+ against FUNC symbols.
10+ * elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Likewise.
11+
112 2018-03-08 H.J. Lu <hongjiu.lu@intel.com>
213
314 PR ld/22929
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -2605,6 +2605,9 @@ elf_s390_relocate_section (bfd *output_bfd,
26052605 case R_390_8:
26062606 case R_390_16:
26072607 case R_390_32:
2608+ if ((input_section->flags & SEC_ALLOC) == 0)
2609+ break;
2610+
26082611 if (h != NULL
26092612 && s390_is_ifunc_symbol_p (h)
26102613 && h->def_regular)
@@ -2666,9 +2669,6 @@ elf_s390_relocate_section (bfd *output_bfd,
26662669 }
26672670 }
26682671
2669- if ((input_section->flags & SEC_ALLOC) == 0)
2670- break;
2671-
26722672 if ((bfd_link_pic (info)
26732673 && (h == NULL
26742674 || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -2565,6 +2565,9 @@ elf_s390_relocate_section (bfd *output_bfd,
25652565 case R_390_32:
25662566 case R_390_64:
25672567
2568+ if ((input_section->flags & SEC_ALLOC) == 0)
2569+ break;
2570+
25682571 if (h != NULL
25692572 && s390_is_ifunc_symbol_p (h)
25702573 && h->def_regular)
@@ -2627,9 +2630,6 @@ elf_s390_relocate_section (bfd *output_bfd,
26272630 }
26282631 }
26292632
2630- if ((input_section->flags & SEC_ALLOC) == 0)
2631- break;
2632-
26332633 if ((bfd_link_pic (info)
26342634 && (h == NULL
26352635 || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -5110,6 +5110,11 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
51105110
51115111 if ((input_section->flags & SEC_ALLOC) == 0)
51125112 {
5113+ /* If this is a SHT_NOTE section without SHF_ALLOC, treat
5114+ STT_GNU_IFUNC symbol as STT_FUNC. */
5115+ if (elf_section_type (input_section) == SHT_NOTE)
5116+ goto skip_ifunc;
5117+
51135118 /* Dynamic relocs are not propagated for SEC_DEBUGGING
51145119 sections because such sections are not SEC_ALLOC and
51155120 thus ld.so will not process them. */
@@ -5305,6 +5310,7 @@ bad_ifunc_reloc:
53055310 }
53065311 }
53075312
5313+ skip_ifunc:
53085314 resolved_to_zero = (h != NULL
53095315 && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h));
53105316
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -3001,7 +3001,13 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
30013001
30023002 if ((input_section->flags & SEC_ALLOC) == 0
30033003 || h->plt.offset == (bfd_vma) -1)
3004- abort ();
3004+ {
3005+ /* If this is a SHT_NOTE section without SHF_ALLOC, treat
3006+ STT_GNU_IFUNC symbol as STT_FUNC. */
3007+ if (elf_section_type (input_section) == SHT_NOTE)
3008+ goto skip_ifunc;
3009+ abort ();
3010+ }
30053011
30063012 plt_sec = htab->elf.splt;
30073013 if (! plt_sec)
@@ -3105,6 +3111,7 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
31053111 }
31063112 }
31073113
3114+ skip_ifunc:
31083115 eh = (struct _bfd_sparc_elf_link_hash_entry *) h;
31093116 resolved_to_zero = eh && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
31103117
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
1+2018-03-09 Nick Clifton <nickc@redhat.com>
2+
3+ * testsuite/ld-ifunc/ifuncmod5.s: New test. Checks that targets
4+ that support IFUNC symbols can handle relocations against those
5+ symbols in NOTE sections.
6+ * testsuite/ld-ifunc/ifuncmod5.d: New file: Driver for the new
7+ test.
8+ * testsuite/ld-ifunc/ifunc.exp: Run the new test.
9+
110 2018-03-08 H.J. Lu <hongjiu.lu@intel.com>
211
312 PR ld/22929
--- a/ld/testsuite/ld-ifunc/ifunc.exp
+++ b/ld/testsuite/ld-ifunc/ifunc.exp
@@ -47,6 +47,9 @@ if ![check_shared_lib_support] {
4747 return
4848 }
4949
50+# This test does not need a compiler...
51+run_dump_test "ifuncmod5"
52+
5053 # We need a working compiler. (Strictly speaking this is
5154 # not true, we could use target specific assembler files).
5255 if { [which $CC] == 0 } {
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifuncmod5.d
@@ -0,0 +1,8 @@
1+# name: Reloc against IFUNC symbol in NOTE section
2+# ld: -shared
3+# nm: -p
4+
5+# We do not actually care about the notes at the moment.
6+# The purpose of this test is to make sure that the link completes successfully.
7+#pass
8+
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifuncmod5.s
@@ -0,0 +1,105 @@
1+ .file "ifuncmod5.c"
2+
3+ .text
4+ .type ifuncmod5.c, STT_NOTYPE
5+ifuncmod5.c:
6+ .size ifuncmod5.c, 0
7+
8+ .pushsection .gnu.build.attributes, "", %note
9+ .balign 4
10+ .dc.l 8
11+ .dc.l 16
12+ .dc.l 0x100
13+ .asciz "GA$3p4"
14+ .dc.a ifuncmod5.c
15+ .dc.a ifuncmod5.c_end
16+ .popsection
17+
18+.Ltext0:
19+#APP
20+ .protected global
21+ .type foo, %gnu_indirect_function
22+ .type foo_hidden, %gnu_indirect_function
23+ .type foo_protected, %gnu_indirect_function
24+ .hidden foo_hidden
25+ .protected foo_protected
26+#NO_APP
27+ .align 8
28+ .type one, %function
29+one:
30+ .dc.l 0
31+ .size one, .-one
32+ .align 8
33+
34+.globl foo
35+ .type foo, %function
36+foo:
37+ .dc.l 0
38+ .size foo, .-foo
39+
40+ .pushsection .gnu.build.attributes
41+ .dc.l 6
42+ .dc.l 16
43+ .dc.l 0x101
44+ .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0
45+ .dc.b 0, 0
46+ .dc.a foo
47+ .dc.a foo_end
48+ .popsection
49+
50+foo_end:
51+ .align 8
52+.globl foo_hidden
53+ .type foo_hidden, %function
54+foo_hidden:
55+ .dc.l 0
56+ .size foo_hidden, .-foo_hidden
57+
58+ .pushsection .gnu.build.attributes
59+ .dc.l 6
60+ .dc.l 16
61+ .dc.l 0x101
62+ .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0
63+ .dc.b 0, 0
64+ .dc.a foo_hidden
65+ .dc.a foo_hidden_end
66+ .popsection
67+
68+foo_hidden_end:
69+ .align 8
70+
71+ .globl foo_protected
72+ .type foo_protected, %function
73+foo_protected:
74+ .dc.l 0
75+
76+ .size foo_protected, .-foo_protected
77+
78+ .pushsection .gnu.build.attributes
79+ .dc.l 6
80+ .dc.l 16
81+ .dc.l 0x101
82+ .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0
83+ .dc.b 0, 0
84+ .dc.a foo_protected
85+ .dc.a foo_protected_end
86+ .popsection
87+
88+foo_protected_end:
89+ .globl global
90+
91+ .data
92+ .align 4
93+ .type global, %object
94+ .size global, 4
95+global:
96+ .long -1
97+
98+ .text
99+ .Letext0:
100+
101+ifuncmod5.c_end:
102+ .type ifuncmod5.c_end, STT_NOTYPE
103+ .size ifuncmod5.c_end, 0
104+
105+