]>
Commit | Line | Data |
---|---|---|
602900c1 MT |
1 | commit 14d96265dd8fd934d868c0b8e1991e2fefbe9fc8 |
2 | Author: Will Newton <will.newton@linaro.org> | |
3 | Date: Mon Nov 25 14:44:59 2013 +0000 | |
4 | ||
5 | bfd/elfnn-aarch64.c: Handle static links with ifunc correctly. | |
6 | ||
7 | The code for handling GOT references to ifunc symbols in static links | |
8 | was missing. | |
9 | ||
10 | bfd/ChangeLog: | |
11 | ||
12 | 2013-11-26 Will Newton <will.newton@linaro.org> | |
13 | ||
14 | * elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol): | |
15 | Handle STT_GNU_IFUNC symbols correctly in static links. | |
16 | ||
17 | ld/testsuite/ChangeLog: | |
18 | ||
19 | 2013-11-26 Will Newton <will.newton@linaro.org> | |
20 | ||
21 | * ld-aarch64/aarch64-elf.exp: Add ifunc-22. | |
22 | * ld-aarch64/ifunc-22.d: New file. | |
23 | * ld-aarch64/ifunc-22.s: Likewise. | |
24 | ||
25 | diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c | |
26 | index 3cd3a18..9053635 100644 | |
27 | --- a/bfd/elfnn-aarch64.c | |
28 | +++ b/bfd/elfnn-aarch64.c | |
29 | @@ -6824,7 +6824,34 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd, | |
30 | + htab->root.sgot->output_offset | |
31 | + (h->got.offset & ~(bfd_vma) 1)); | |
32 | ||
33 | - if (info->shared && SYMBOL_REFERENCES_LOCAL (info, h)) | |
34 | + if (h->def_regular | |
35 | + && h->type == STT_GNU_IFUNC) | |
36 | + { | |
37 | + if (info->shared) | |
38 | + { | |
39 | + /* Generate R_AARCH64_GLOB_DAT. */ | |
40 | + goto do_glob_dat; | |
41 | + } | |
42 | + else | |
43 | + { | |
44 | + asection *plt; | |
45 | + | |
46 | + if (!h->pointer_equality_needed) | |
47 | + abort (); | |
48 | + | |
49 | + /* For non-shared object, we can't use .got.plt, which | |
50 | + contains the real function address if we need pointer | |
51 | + equality. We load the GOT entry with the PLT entry. */ | |
52 | + plt = htab->root.splt ? htab->root.splt : htab->root.iplt; | |
53 | + bfd_put_NN (output_bfd, (plt->output_section->vma | |
54 | + + plt->output_offset | |
55 | + + h->plt.offset), | |
56 | + htab->root.sgot->contents | |
57 | + + (h->got.offset & ~(bfd_vma) 1)); | |
58 | + return TRUE; | |
59 | + } | |
60 | + } | |
61 | + else if (info->shared && SYMBOL_REFERENCES_LOCAL (info, h)) | |
62 | { | |
63 | if (!h->def_regular) | |
64 | return FALSE; | |
65 | @@ -6837,6 +6864,7 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd, | |
66 | } | |
67 | else | |
68 | { | |
69 | +do_glob_dat: | |
70 | BFD_ASSERT ((h->got.offset & 1) == 0); | |
71 | bfd_put_NN (output_bfd, (bfd_vma) 0, | |
72 | htab->root.sgot->contents + h->got.offset); | |
73 | diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp | |
74 | index a6b3ea2..692bf34 100644 | |
75 | --- a/ld/testsuite/ld-aarch64/aarch64-elf.exp | |
76 | +++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp | |
77 | @@ -156,3 +156,4 @@ run_dump_test "ifunc-19a" | |
78 | run_dump_test "ifunc-19b" | |
79 | run_dump_test "ifunc-20" | |
80 | run_dump_test "ifunc-21" | |
81 | +run_dump_test "ifunc-22" | |
82 | diff --git a/ld/testsuite/ld-aarch64/ifunc-22.d b/ld/testsuite/ld-aarch64/ifunc-22.d | |
83 | new file mode 100644 | |
84 | index 0000000..f28b039 | |
85 | --- /dev/null | |
86 | +++ b/ld/testsuite/ld-aarch64/ifunc-22.d | |
87 | @@ -0,0 +1,11 @@ | |
88 | +#source: ifunc-22.s | |
89 | +#objdump: -s -j .got | |
90 | +#ld: -static | |
91 | +#target: aarch64*-*-* | |
92 | + | |
93 | +# Ensure GOT is populated correctly in static link | |
94 | + | |
95 | +.*: file format elf64-(little|big)aarch64 | |
96 | + | |
97 | +Contents of section \.got: | |
98 | + 4100f0 00000000 00000000 d0004000 00000000 ..........@..... | |
99 | diff --git a/ld/testsuite/ld-aarch64/ifunc-22.s b/ld/testsuite/ld-aarch64/ifunc-22.s | |
100 | new file mode 100644 | |
101 | index 0000000..69a87bb | |
102 | --- /dev/null | |
103 | +++ b/ld/testsuite/ld-aarch64/ifunc-22.s | |
104 | @@ -0,0 +1,14 @@ | |
105 | + .text | |
106 | + .type ifunc, @gnu_indirect_function | |
107 | + .global ifunc | |
108 | +ifunc: | |
109 | + ret | |
110 | + .size ifunc, .-ifunc | |
111 | + .type _start, @function | |
112 | + .globl _start | |
113 | +_start: | |
114 | + adrp x0, :got:ifunc | |
115 | + ldr x0, [x0, #:got_lo12:ifunc] | |
116 | + .size _start, .-_start | |
117 | + .data | |
118 | + .xword ifunc |