summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/binutils/binutils/0014-Correct-nios2-_gp-address-computation.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/0014-Correct-nios2-_gp-address-computation.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/0014-Correct-nios2-_gp-address-computation.patch')
-rw-r--r--meta/recipes-devtools/binutils/binutils/0014-Correct-nios2-_gp-address-computation.patch106
1 files changed, 106 insertions, 0 deletions
diff --git a/meta/recipes-devtools/binutils/binutils/0014-Correct-nios2-_gp-address-computation.patch b/meta/recipes-devtools/binutils/binutils/0014-Correct-nios2-_gp-address-computation.patch
new file mode 100644
index 0000000000..7a4c1db4ee
--- /dev/null
+++ b/meta/recipes-devtools/binutils/binutils/0014-Correct-nios2-_gp-address-computation.patch
@@ -0,0 +1,106 @@
1From fcf984ae68c89e5495e65fe6456650cc014b5ea7 Mon Sep 17 00:00:00 2001
2From: Sandra Loosemore <sandra@codesourcery.com>
3Date: Sun, 27 Dec 2015 12:30:26 -0800
4Subject: [PATCH 2/2] Correct nios2 _gp address computation.
5
62015-12-27 Sandra Loosemore <sandra@codesourcery.com>
7
8 bfd/
9 * elf32-nios2.c (nios2_elf_assign_gp): Correct computation of _gp
10 address.
11 (nios2_elf32_relocate_section): Tidy code for R_NIOS2_GPREL error
12 messages.
13
14Signed-off-by: Marek Vasut <marex@denx.de>
15Upstream-Status: Backport
16---
17 bfd/elf32-nios2.c | 31 +++++++++++++++++++++----------
18 1 file changed, 21 insertions(+), 10 deletions(-)
19
20diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c
21index 1c54320..babecf3 100644
22--- a/bfd/elf32-nios2.c
23+++ b/bfd/elf32-nios2.c
24@@ -3086,7 +3086,15 @@ lookup:
25 case bfd_link_hash_defined:
26 case bfd_link_hash_defweak:
27 gp_found = TRUE;
28- *pgp = lh->u.def.value;
29+ {
30+ asection *sym_sec = lh->u.def.section;
31+ bfd_vma sym_value = lh->u.def.value;
32+
33+ if (sym_sec->output_section)
34+ sym_value = (sym_value + sym_sec->output_offset
35+ + sym_sec->output_section->vma);
36+ *pgp = sym_value;
37+ }
38 break;
39 case bfd_link_hash_indirect:
40 case bfd_link_hash_warning:
41@@ -3719,7 +3727,6 @@ nios2_elf32_relocate_section (bfd *output_bfd,
42 struct elf32_nios2_link_hash_entry *eh;
43 bfd_vma relocation;
44 bfd_vma gp;
45- bfd_vma reloc_address;
46 bfd_reloc_status_type r = bfd_reloc_ok;
47 const char *name = NULL;
48 int r_type;
49@@ -3762,12 +3769,6 @@ nios2_elf32_relocate_section (bfd *output_bfd,
50 if (bfd_link_relocatable (info))
51 continue;
52
53- if (sec && sec->output_section)
54- reloc_address = (sec->output_section->vma + sec->output_offset
55- + rel->r_offset);
56- else
57- reloc_address = 0;
58-
59 if (howto)
60 {
61 switch (howto->type)
62@@ -3816,6 +3817,15 @@ nios2_elf32_relocate_section (bfd *output_bfd,
63 /* Turns an absolute address into a gp-relative address. */
64 if (!nios2_elf_assign_gp (output_bfd, &gp, info))
65 {
66+ bfd_vma reloc_address;
67+
68+ if (sec && sec->output_section)
69+ reloc_address = (sec->output_section->vma
70+ + sec->output_offset
71+ + rel->r_offset);
72+ else
73+ reloc_address = 0;
74+
75 format = _("global pointer relative relocation at address "
76 "0x%08x when _gp not defined\n");
77 sprintf (msgbuf, format, reloc_address);
78@@ -3825,7 +3835,7 @@ nios2_elf32_relocate_section (bfd *output_bfd,
79 else
80 {
81 bfd_vma symbol_address = rel->r_addend + relocation;
82- relocation = relocation + rel->r_addend - gp;
83+ relocation = symbol_address - gp;
84 rel->r_addend = 0;
85 if (((signed) relocation < -32768
86 || (signed) relocation > 32767)
87@@ -3833,6 +3843,8 @@ nios2_elf32_relocate_section (bfd *output_bfd,
88 || h->root.type == bfd_link_hash_defined
89 || h->root.type == bfd_link_hash_defweak))
90 {
91+ if (h)
92+ name = h->root.root.string;
93 format = _("Unable to reach %s (at 0x%08x) from the "
94 "global pointer (at 0x%08x) because the "
95 "offset (%d) is out of the allowed range, "
96@@ -3848,7 +3860,6 @@ nios2_elf32_relocate_section (bfd *output_bfd,
97 rel->r_offset, relocation,
98 rel->r_addend);
99 }
100-
101 break;
102 case R_NIOS2_UJMP:
103 r = nios2_elf32_do_ujmp_relocate (input_bfd, howto,
104--
1052.7.0
106