summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/binutils/binutils/0013-Fix-GOT-address-computations-in-initial-PLT-entries-.patch
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2016-02-10 01:04:01 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-11 12:27:48 +0000
commit611e3d87d81364b19888afcaa03d328a64bdcdb0 (patch)
tree57ec055b7ac42866bc1976f7ce1417e905d73291 /meta/recipes-devtools/binutils/binutils/0013-Fix-GOT-address-computations-in-initial-PLT-entries-.patch
parent027eac541457bca36ba4ebc7d5ff8da09e1243bb (diff)
downloadpoky-611e3d87d81364b19888afcaa03d328a64bdcdb0.tar.gz
binutils: Repair nios2 PLT and GP handling
Repair corner cases in nios2 PLT and GP handling. See the patches themselves for extensive detailed explanation. The patches don't contain the ChangeLog entries, since the changelog entries often cause trouble when applying the patch. (From OE-Core rev: fdac5c38183aa96faea8d51d16ce5f54ee16f944) Signed-off-by: Marek Vasut <marex@denx.de> Cc: Ross Burton <ross.burton@intel.com> Cc: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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-.patch72
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 @@
1From 45490ccc18bbb518550209c38b2278b04703c183 Mon Sep 17 00:00:00 2001
2From: Sandra Loosemore <sandra@codesourcery.com>
3Date: Wed, 9 Dec 2015 16:13:58 -0800
4Subject: [PATCH 1/2] Fix GOT address computations in initial PLT entries for
5 nios2.
6
72015-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
14Signed-off-by: Marek Vasut <marex@denx.de>
15Upstream-Status: Backport
16---
17 bfd/elf32-nios2.c | 23 ++++++++++++++++-------
18 1 file changed, 16 insertions(+), 7 deletions(-)
19
20diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c
21index 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--
712.7.0
72