aboutsummaryrefslogtreecommitdiffstats
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:28 +0000
commitfdac5c38183aa96faea8d51d16ce5f54ee16f944 (patch)
treee7398a67b04e1327314c00057ee0078bab406621 /meta/recipes-devtools/binutils/binutils/0014-Correct-nios2-_gp-address-computation.patch
parent948165dce7475b815a344fd3c3d58165e6865d48 (diff)
downloadopenembedded-core-contrib-fdac5c38183aa96faea8d51d16ce5f54ee16f944.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. 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>
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 @@
+From fcf984ae68c89e5495e65fe6456650cc014b5ea7 Mon Sep 17 00:00:00 2001
+From: Sandra Loosemore <sandra@codesourcery.com>
+Date: Sun, 27 Dec 2015 12:30:26 -0800
+Subject: [PATCH 2/2] Correct nios2 _gp address computation.
+
+2015-12-27 Sandra Loosemore <sandra@codesourcery.com>
+
+ bfd/
+ * elf32-nios2.c (nios2_elf_assign_gp): Correct computation of _gp
+ address.
+ (nios2_elf32_relocate_section): Tidy code for R_NIOS2_GPREL error
+ messages.
+
+Signed-off-by: Marek Vasut <marex@denx.de>
+Upstream-Status: Backport
+---
+ bfd/elf32-nios2.c | 31 +++++++++++++++++++++----------
+ 1 file changed, 21 insertions(+), 10 deletions(-)
+
+diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c
+index 1c54320..babecf3 100644
+--- a/bfd/elf32-nios2.c
++++ b/bfd/elf32-nios2.c
+@@ -3086,7 +3086,15 @@ lookup:
+ case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
+ gp_found = TRUE;
+- *pgp = lh->u.def.value;
++ {
++ asection *sym_sec = lh->u.def.section;
++ bfd_vma sym_value = lh->u.def.value;
++
++ if (sym_sec->output_section)
++ sym_value = (sym_value + sym_sec->output_offset
++ + sym_sec->output_section->vma);
++ *pgp = sym_value;
++ }
+ break;
+ case bfd_link_hash_indirect:
+ case bfd_link_hash_warning:
+@@ -3719,7 +3727,6 @@ nios2_elf32_relocate_section (bfd *output_bfd,
+ struct elf32_nios2_link_hash_entry *eh;
+ bfd_vma relocation;
+ bfd_vma gp;
+- bfd_vma reloc_address;
+ bfd_reloc_status_type r = bfd_reloc_ok;
+ const char *name = NULL;
+ int r_type;
+@@ -3762,12 +3769,6 @@ nios2_elf32_relocate_section (bfd *output_bfd,
+ if (bfd_link_relocatable (info))
+ continue;
+
+- if (sec && sec->output_section)
+- reloc_address = (sec->output_section->vma + sec->output_offset
+- + rel->r_offset);
+- else
+- reloc_address = 0;
+-
+ if (howto)
+ {
+ switch (howto->type)
+@@ -3816,6 +3817,15 @@ nios2_elf32_relocate_section (bfd *output_bfd,
+ /* Turns an absolute address into a gp-relative address. */
+ if (!nios2_elf_assign_gp (output_bfd, &gp, info))
+ {
++ bfd_vma reloc_address;
++
++ if (sec && sec->output_section)
++ reloc_address = (sec->output_section->vma
++ + sec->output_offset
++ + rel->r_offset);
++ else
++ reloc_address = 0;
++
+ format = _("global pointer relative relocation at address "
+ "0x%08x when _gp not defined\n");
+ sprintf (msgbuf, format, reloc_address);
+@@ -3825,7 +3835,7 @@ nios2_elf32_relocate_section (bfd *output_bfd,
+ else
+ {
+ bfd_vma symbol_address = rel->r_addend + relocation;
+- relocation = relocation + rel->r_addend - gp;
++ relocation = symbol_address - gp;
+ rel->r_addend = 0;
+ if (((signed) relocation < -32768
+ || (signed) relocation > 32767)
+@@ -3833,6 +3843,8 @@ nios2_elf32_relocate_section (bfd *output_bfd,
+ || h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak))
+ {
++ if (h)
++ name = h->root.root.string;
+ format = _("Unable to reach %s (at 0x%08x) from the "
+ "global pointer (at 0x%08x) because the "
+ "offset (%d) is out of the allowed range, "
+@@ -3848,7 +3860,6 @@ nios2_elf32_relocate_section (bfd *output_bfd,
+ rel->r_offset, relocation,
+ rel->r_addend);
+ }
+-
+ break;
+ case R_NIOS2_UJMP:
+ r = nios2_elf32_do_ujmp_relocate (input_bfd, howto,
+--
+2.7.0
+