1 commit 67428c4aa56d4183d0f531e0d752040745a94423
2 Author: Will Newton <will.newton@linaro.org>
3 Date: Mon Nov 25 11:07:07 2013 +0000
5 bfd/elfnn-aarch64.c: Fix miscalculation of GOTPLT offset for ifunc syms.
7 The .got.plt header size was not being correctly taken into account
8 when calculating the offset for relocations against ifunc symbols.
12 2013-11-26 Will Newton <will.newton@linaro.org>
14 * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Ensure
15 PLT_INDEX is calculated using correct header size.
17 ld/testsuite/ChangeLog:
19 2013-11-26 Will Newton <will.newton@linaro.org>
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.
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,
31 if (globals->root.splt != NULL)
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;
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
50 index 0000000..fa139b2
52 +++ b/ld/testsuite/ld-aarch64/ifunc-21.d
55 +#ld: -shared -z nocombreloc
56 +#objdump: -d -s -j .got.plt -j .text
57 +#target: aarch64*-*-*
59 +# Ensure the .got.plt slot used is correct
61 +.*: file format elf64-(little|big)aarch64
63 +Contents of section .text:
65 +Contents of section .got.plt:
66 + 103a8 0+ 0+ 0+ 0+ .*
67 + 103b8 0+ 0+ [0-9a-f]+ 0+ .*
69 +Disassembly of section .text:
75 + 2a4: 90000080 adrp x0, 10000 <.*>
76 + 2a8: f941e000 ldr x0, \[x0,#960\]
79 +Disassembly of section .got.plt:
85 diff --git a/ld/testsuite/ld-aarch64/ifunc-21.s b/ld/testsuite/ld-aarch64/ifunc-21.s
87 index 0000000..a1563dc
89 +++ b/ld/testsuite/ld-aarch64/ifunc-21.s
92 + .type ifunc, @gnu_indirect_function
96 + .size ifunc, .-ifunc
97 + .type bar, @function
100 + adrp x0, :got:ifunc
101 + ldr x0, [x0, #:got_lo12:ifunc]