GNU Binutils with patches for OS216
Revision | f657f8c4a1dc0ac69b16b1dc6eacbf5286f1f0a0 (tree) |
---|---|
Time | 2018-03-09 23:37:36 |
Author | Nick Clifton <nickc@redh...> |
Commiter | Nick Clifton |
Fix Sparc, s390 and AArch64 targets so that they can handle relocs against ifunc symbols found in note sections.
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.
@@ -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 | + | |
1 | 12 | 2018-03-08 H.J. Lu <hongjiu.lu@intel.com> |
2 | 13 | |
3 | 14 | PR ld/22929 |
@@ -2605,6 +2605,9 @@ elf_s390_relocate_section (bfd *output_bfd, | ||
2605 | 2605 | case R_390_8: |
2606 | 2606 | case R_390_16: |
2607 | 2607 | case R_390_32: |
2608 | + if ((input_section->flags & SEC_ALLOC) == 0) | |
2609 | + break; | |
2610 | + | |
2608 | 2611 | if (h != NULL |
2609 | 2612 | && s390_is_ifunc_symbol_p (h) |
2610 | 2613 | && h->def_regular) |
@@ -2666,9 +2669,6 @@ elf_s390_relocate_section (bfd *output_bfd, | ||
2666 | 2669 | } |
2667 | 2670 | } |
2668 | 2671 | |
2669 | - if ((input_section->flags & SEC_ALLOC) == 0) | |
2670 | - break; | |
2671 | - | |
2672 | 2672 | if ((bfd_link_pic (info) |
2673 | 2673 | && (h == NULL |
2674 | 2674 | || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT |
@@ -2565,6 +2565,9 @@ elf_s390_relocate_section (bfd *output_bfd, | ||
2565 | 2565 | case R_390_32: |
2566 | 2566 | case R_390_64: |
2567 | 2567 | |
2568 | + if ((input_section->flags & SEC_ALLOC) == 0) | |
2569 | + break; | |
2570 | + | |
2568 | 2571 | if (h != NULL |
2569 | 2572 | && s390_is_ifunc_symbol_p (h) |
2570 | 2573 | && h->def_regular) |
@@ -2627,9 +2630,6 @@ elf_s390_relocate_section (bfd *output_bfd, | ||
2627 | 2630 | } |
2628 | 2631 | } |
2629 | 2632 | |
2630 | - if ((input_section->flags & SEC_ALLOC) == 0) | |
2631 | - break; | |
2632 | - | |
2633 | 2633 | if ((bfd_link_pic (info) |
2634 | 2634 | && (h == NULL |
2635 | 2635 | || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT |
@@ -5110,6 +5110,11 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, | ||
5110 | 5110 | |
5111 | 5111 | if ((input_section->flags & SEC_ALLOC) == 0) |
5112 | 5112 | { |
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 | + | |
5113 | 5118 | /* Dynamic relocs are not propagated for SEC_DEBUGGING |
5114 | 5119 | sections because such sections are not SEC_ALLOC and |
5115 | 5120 | thus ld.so will not process them. */ |
@@ -5305,6 +5310,7 @@ bad_ifunc_reloc: | ||
5305 | 5310 | } |
5306 | 5311 | } |
5307 | 5312 | |
5313 | + skip_ifunc: | |
5308 | 5314 | resolved_to_zero = (h != NULL |
5309 | 5315 | && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)); |
5310 | 5316 |
@@ -3001,7 +3001,13 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, | ||
3001 | 3001 | |
3002 | 3002 | if ((input_section->flags & SEC_ALLOC) == 0 |
3003 | 3003 | || 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 | + } | |
3005 | 3011 | |
3006 | 3012 | plt_sec = htab->elf.splt; |
3007 | 3013 | if (! plt_sec) |
@@ -3105,6 +3111,7 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, | ||
3105 | 3111 | } |
3106 | 3112 | } |
3107 | 3113 | |
3114 | + skip_ifunc: | |
3108 | 3115 | eh = (struct _bfd_sparc_elf_link_hash_entry *) h; |
3109 | 3116 | resolved_to_zero = eh && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh); |
3110 | 3117 |
@@ -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 | + | |
1 | 10 | 2018-03-08 H.J. Lu <hongjiu.lu@intel.com> |
2 | 11 | |
3 | 12 | PR ld/22929 |
@@ -47,6 +47,9 @@ if ![check_shared_lib_support] { | ||
47 | 47 | return |
48 | 48 | } |
49 | 49 | |
50 | +# This test does not need a compiler... | |
51 | +run_dump_test "ifuncmod5" | |
52 | + | |
50 | 53 | # We need a working compiler. (Strictly speaking this is |
51 | 54 | # not true, we could use target specific assembler files). |
52 | 55 | if { [which $CC] == 0 } { |
@@ -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 | + |
@@ -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 | + |