]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - binutils/patches/binutils-2.24-aarch64-fix-gotplt-offset-ifunc.patch
binutils: Update to 2.24
[people/ms/ipfire-3.x.git] / binutils / patches / binutils-2.24-aarch64-fix-gotplt-offset-ifunc.patch
1 commit 67428c4aa56d4183d0f531e0d752040745a94423
2 Author: Will Newton <will.newton@linaro.org>
3 Date: Mon Nov 25 11:07:07 2013 +0000
4
5 bfd/elfnn-aarch64.c: Fix miscalculation of GOTPLT offset for ifunc syms.
6
7 The .got.plt header size was not being correctly taken into account
8 when calculating the offset for relocations against ifunc symbols.
9
10 bfd/ChangeLog:
11
12 2013-11-26 Will Newton <will.newton@linaro.org>
13
14 * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Ensure
15 PLT_INDEX is calculated using correct header size.
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-21 test.
22 * ld-aarch64/ifunc-21.d: New file.
23 * ld-aarch64/ifunc-21.s: Likewise.
24
25 diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
26 index 6bc414e..3cd3a18 100644
27 --- a/bfd/elfnn-aarch64.c
28 +++ b/bfd/elfnn-aarch64.c
29 @@ -3589,7 +3589,8 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
30
31 if (globals->root.splt != NULL)
32 {
33 - plt_index = h->plt.offset / globals->plt_entry_size - 1;
34 + plt_index = ((h->plt.offset - globals->plt_header_size) /
35 + globals->plt_entry_size);
36 off = (plt_index + 3) * GOT_ENTRY_SIZE;
37 base_got = globals->root.sgotplt;
38 }
39 diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
40 index 5c150dd..a6b3ea2 100644
41 --- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
42 +++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
43 @@ -155,3 +155,4 @@ run_dump_test "ifunc-18b"
44 run_dump_test "ifunc-19a"
45 run_dump_test "ifunc-19b"
46 run_dump_test "ifunc-20"
47 +run_dump_test "ifunc-21"
48 diff --git a/ld/testsuite/ld-aarch64/ifunc-21.d b/ld/testsuite/ld-aarch64/ifunc-21.d
49 new file mode 100644
50 index 0000000..fa139b2
51 --- /dev/null
52 +++ b/ld/testsuite/ld-aarch64/ifunc-21.d
53 @@ -0,0 +1,31 @@
54 +#source: ifunc-21.s
55 +#ld: -shared -z nocombreloc
56 +#objdump: -d -s -j .got.plt -j .text
57 +#target: aarch64*-*-*
58 +
59 +# Ensure the .got.plt slot used is correct
60 +
61 +.*: file format elf64-(little|big)aarch64
62 +
63 +Contents of section .text:
64 + 02a0 .*
65 +Contents of section .got.plt:
66 + 103a8 0+ 0+ 0+ 0+ .*
67 + 103b8 0+ 0+ [0-9a-f]+ 0+ .*
68 +
69 +Disassembly of section .text:
70 +
71 +0+2a0 <ifunc>:
72 + 2a0: d65f03c0 ret
73 +
74 +0+2a4 <bar>:
75 + 2a4: 90000080 adrp x0, 10000 <.*>
76 + 2a8: f941e000 ldr x0, \[x0,#960\]
77 + 2ac: d65f03c0 ret
78 +
79 +Disassembly of section .got.plt:
80 +
81 +.*:
82 +.*
83 +.*
84 +.*
85 diff --git a/ld/testsuite/ld-aarch64/ifunc-21.s b/ld/testsuite/ld-aarch64/ifunc-21.s
86 new file mode 100644
87 index 0000000..a1563dc
88 --- /dev/null
89 +++ b/ld/testsuite/ld-aarch64/ifunc-21.s
90 @@ -0,0 +1,13 @@
91 + .text
92 + .type ifunc, @gnu_indirect_function
93 + .hidden ifunc
94 +ifunc:
95 + ret
96 + .size ifunc, .-ifunc
97 + .type bar, @function
98 + .globl bar
99 +bar:
100 + adrp x0, :got:ifunc
101 + ldr x0, [x0, #:got_lo12:ifunc]
102 + ret
103 + .size bar, .-bar