summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-devtools/binutils/binutils-2.26.inc2
-rw-r--r--meta/recipes-devtools/binutils/binutils/0013-Fix-GOT-address-computations-in-initial-PLT-entries-.patch72
-rw-r--r--meta/recipes-devtools/binutils/binutils/0014-Correct-nios2-_gp-address-computation.patch106
3 files changed, 180 insertions, 0 deletions
diff --git a/meta/recipes-devtools/binutils/binutils-2.26.inc b/meta/recipes-devtools/binutils/binutils-2.26.inc
index c955471c26..dd5c8caf58 100644
--- a/meta/recipes-devtools/binutils/binutils-2.26.inc
+++ b/meta/recipes-devtools/binutils/binutils-2.26.inc
@@ -32,6 +32,8 @@ SRC_URI = "\
32 file://0010-Fix-rpath-in-libtool-when-sysroot-is-enabled.patch \ 32 file://0010-Fix-rpath-in-libtool-when-sysroot-is-enabled.patch \
33 file://0011-Change-default-emulation-for-mips64-linux.patch \ 33 file://0011-Change-default-emulation-for-mips64-linux.patch \
34 file://0012-Add-XLP-instructions-support.patch \ 34 file://0012-Add-XLP-instructions-support.patch \
35 file://0013-Fix-GOT-address-computations-in-initial-PLT-entries-.patch \
36 file://0014-Correct-nios2-_gp-address-computation.patch \
35 " 37 "
36S = "${WORKDIR}/git" 38S = "${WORKDIR}/git"
37 39
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
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