diff options
Diffstat (limited to 'meta/recipes-devtools/binutils/binutils/0013-Fix-GOT-address-computations-in-initial-PLT-entries-.patch')
-rw-r--r-- | meta/recipes-devtools/binutils/binutils/0013-Fix-GOT-address-computations-in-initial-PLT-entries-.patch | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/meta/recipes-devtools/binutils/binutils/0013-Fix-GOT-address-computations-in-initial-PLT-entries-.patch b/meta/recipes-devtools/binutils/binutils/0013-Fix-GOT-address-computations-in-initial-PLT-entries-.patch new file mode 100644 index 0000000000..a62b519173 --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0013-Fix-GOT-address-computations-in-initial-PLT-entries-.patch | |||
@@ -0,0 +1,72 @@ | |||
1 | From 45490ccc18bbb518550209c38b2278b04703c183 Mon Sep 17 00:00:00 2001 | ||
2 | From: Sandra Loosemore <sandra@codesourcery.com> | ||
3 | Date: Wed, 9 Dec 2015 16:13:58 -0800 | ||
4 | Subject: [PATCH 1/2] Fix GOT address computations in initial PLT entries for | ||
5 | nios2. | ||
6 | |||
7 | 2015-12-09 Sandra Loosemore <sandra@codesourcery.com> | ||
8 | |||
9 | bfd/ | ||
10 | * elf32-nios2.c (nios2_elf32_finish_dynamic_sections): Correct | ||
11 | %hiadj/%lo computations for _GLOBAL_OFFSET_TABLE_ in initial | ||
12 | PLT entries. Assert alignment requirements. | ||
13 | |||
14 | Signed-off-by: Marek Vasut <marex@denx.de> | ||
15 | Upstream-Status: Backport | ||
16 | --- | ||
17 | bfd/elf32-nios2.c | 23 ++++++++++++++++------- | ||
18 | 1 file changed, 16 insertions(+), 7 deletions(-) | ||
19 | |||
20 | diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c | ||
21 | index 6b29d8b..1c54320 100644 | ||
22 | --- a/bfd/elf32-nios2.c | ||
23 | +++ b/bfd/elf32-nios2.c | ||
24 | @@ -5383,12 +5383,17 @@ nios2_elf32_finish_dynamic_sections (bfd *output_bfd, | ||
25 | + sgotplt->output_offset); | ||
26 | if (bfd_link_pic (info)) | ||
27 | { | ||
28 | - bfd_vma corrected = got_address - (splt->output_section->vma | ||
29 | - + splt->output_offset + 4); | ||
30 | + bfd_vma got_pcrel = got_address - (splt->output_section->vma | ||
31 | + + splt->output_offset); | ||
32 | + /* Both GOT and PLT must be aligned to a 16-byte boundary | ||
33 | + for the two loads to share the %hiadj part. The 4-byte | ||
34 | + offset for nextpc is accounted for in the %lo offsets | ||
35 | + on the loads. */ | ||
36 | + BFD_ASSERT ((got_pcrel & 0xf) == 0); | ||
37 | nios2_elf32_install_data (splt, nios2_so_plt0_entry, 0, 6); | ||
38 | - nios2_elf32_install_imm16 (splt, 4, hiadj (corrected)); | ||
39 | - nios2_elf32_install_imm16 (splt, 12, (corrected & 0xffff) + 4); | ||
40 | - nios2_elf32_install_imm16 (splt, 16, (corrected & 0xffff) + 8); | ||
41 | + nios2_elf32_install_imm16 (splt, 4, hiadj (got_pcrel)); | ||
42 | + nios2_elf32_install_imm16 (splt, 12, got_pcrel & 0xffff); | ||
43 | + nios2_elf32_install_imm16 (splt, 16, (got_pcrel + 4) & 0xffff); | ||
44 | } | ||
45 | else | ||
46 | { | ||
47 | @@ -5404,6 +5409,10 @@ nios2_elf32_finish_dynamic_sections (bfd *output_bfd, | ||
48 | 6 | ((res_size - (res_offset + 4)) << 6), | ||
49 | splt->contents + res_offset); | ||
50 | |||
51 | + /* The GOT must be aligned to a 16-byte boundary for the | ||
52 | + two loads to share the same %hiadj part. */ | ||
53 | + BFD_ASSERT ((got_address & 0xf) == 0); | ||
54 | + | ||
55 | nios2_elf32_install_data (splt, nios2_plt0_entry, res_size, 7); | ||
56 | nios2_elf32_install_imm16 (splt, res_size, hiadj (res_start)); | ||
57 | nios2_elf32_install_imm16 (splt, res_size + 4, | ||
58 | @@ -5411,9 +5420,9 @@ nios2_elf32_finish_dynamic_sections (bfd *output_bfd, | ||
59 | nios2_elf32_install_imm16 (splt, res_size + 12, | ||
60 | hiadj (got_address)); | ||
61 | nios2_elf32_install_imm16 (splt, res_size + 16, | ||
62 | - (got_address & 0xffff) + 4); | ||
63 | + (got_address + 4) & 0xffff); | ||
64 | nios2_elf32_install_imm16 (splt, res_size + 20, | ||
65 | - (got_address & 0xffff) + 8); | ||
66 | + (got_address + 8) & 0xffff); | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | -- | ||
71 | 2.7.0 | ||
72 | |||