summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Rossi <nathan@nathanrossi.com>2016-09-25 04:19:02 +1000
committerNathan Rossi <nathan@nathanrossi.com>2016-10-11 21:10:52 +1000
commit59e716bc054d2ca2f3ad138f6fa9043e985e6f3c (patch)
tree398e4a4f2aaa4ae0fb97083f3bdd7b0ccf561f07
parent2ae639adefe4454b4c0e80751a7a5953f3f92b25 (diff)
downloadmeta-xilinx-59e716bc054d2ca2f3ad138f6fa9043e985e6f3c.tar.gz
binutils: Fix bug in binutils for MicroBlaze
Fix a regression in binutils where the "RELA" and "RELASZ" entries of the .dynamic table were incorrect set to invalid values/addresses. Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
-rw-r--r--recipes-microblaze/binutils/binutils%.bbappend1
-rw-r--r--recipes-microblaze/binutils/files/bfd-elf32-microblaze.c-Fix-regression-with-RELA.patch103
2 files changed, 104 insertions, 0 deletions
diff --git a/recipes-microblaze/binutils/binutils%.bbappend b/recipes-microblaze/binutils/binutils%.bbappend
index 2a53ab74..0f3b0ef7 100644
--- a/recipes-microblaze/binutils/binutils%.bbappend
+++ b/recipes-microblaze/binutils/binutils%.bbappend
@@ -3,5 +3,6 @@
3FILESEXTRAPATHS_append := "${THISDIR}/files:" 3FILESEXTRAPATHS_append := "${THISDIR}/files:"
4SRC_URI_append_microblaze = " \ 4SRC_URI_append_microblaze = " \
5 file://upstream-change-to-garbage-collection-s.patch \ 5 file://upstream-change-to-garbage-collection-s.patch \
6 file://bfd-elf32-microblaze.c-Fix-regression-with-RELA.patch \
6 " 7 "
7 8
diff --git a/recipes-microblaze/binutils/files/bfd-elf32-microblaze.c-Fix-regression-with-RELA.patch b/recipes-microblaze/binutils/files/bfd-elf32-microblaze.c-Fix-regression-with-RELA.patch
new file mode 100644
index 00000000..3f572a20
--- /dev/null
+++ b/recipes-microblaze/binutils/files/bfd-elf32-microblaze.c-Fix-regression-with-RELA.patch
@@ -0,0 +1,103 @@
1From 86090b41b2fd86c5b5391fac9f5785e79fe177c2 Mon Sep 17 00:00:00 2001
2From: Nathan Rossi <nathan@nathanrossi.com>
3Date: Sat, 24 Sep 2016 22:07:42 +1000
4Subject: [PATCH] bfd/elf32-microblaze.c: Fix regression with RELA* values
5 being wrong
6
7Commit 4ade44b727ee77adaa9c22719935d012e253a5e6 introduced a change
8to microblaze where the section was accessed from dynamic sections
9instead of from the output bfd. This meant that for some shared objects
10(mainly executables) the .rela.dyn section was not available, causing
11the DT_RELA* table entries to be set to 0.
12
13This change modifies how microblaze handles the setting of the various
14dynamic table values. Specifically it lets the generic final function
15handle setting RELA* values and modifies the RELASZ value of the dynamic
16table by subtracting the size of other DT_RELA type sections (this is
17how other targets handle the RELASZ value needing to only be the size of
18the .rela.dyn section). This resolves the regression mentioned above.
19
20Additionally this patch changes code for how dynamic table entries are
21modified for microblaze specific requirements. This makes the microblaze
22handling match how other targets modify the values.
23
24Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
25Upstream-Status: Pending
26---
27 bfd/elf32-microblaze.c | 52 +++++++++++++++++++++++++++++---------------------
28 1 file changed, 30 insertions(+), 22 deletions(-)
29
30diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
31index 5496d1613a..34e8ae4261 100644
32--- a/bfd/elf32-microblaze.c
33+++ b/bfd/elf32-microblaze.c
34@@ -3381,36 +3381,44 @@ microblaze_elf_finish_dynamic_sections (bfd *output_bfd,
35 for (; dyncon < dynconend; dyncon++)
36 {
37 Elf_Internal_Dyn dyn;
38- const char *name;
39- bfd_boolean size;
40+ asection *s;
41
42 bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
43
44 switch (dyn.d_tag)
45 {
46- case DT_PLTGOT: name = ".got.plt"; size = FALSE; break;
47- case DT_PLTRELSZ: name = ".rela.plt"; size = TRUE; break;
48- case DT_JMPREL: name = ".rela.plt"; size = FALSE; break;
49- case DT_RELA: name = ".rela.dyn"; size = FALSE; break;
50- case DT_RELASZ: name = ".rela.dyn"; size = TRUE; break;
51- default: name = NULL; size = FALSE; break;
52- }
53+ default:
54+ break;
55
56- if (name != NULL)
57- {
58- asection *s;
59+ case DT_PLTGOT:
60+ s = bfd_get_linker_section (dynobj, ".got.plt");
61+ if (s != NULL)
62+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
63+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
64+ break;
65
66- s = bfd_get_linker_section (dynobj, name);
67- if (s == NULL)
68- dyn.d_un.d_val = 0;
69- else
70- {
71- if (! size)
72- dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
73- else
74- dyn.d_un.d_val = s->size;
75- }
76+ case DT_PLTRELSZ:
77+ s = bfd_get_linker_section (dynobj, ".rela.plt");
78+ if (s != NULL)
79+ dyn.d_un.d_val = s->size;
80+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
81+ break;
82+
83+ case DT_JMPREL:
84+ s = bfd_get_linker_section (dynobj, ".rela.plt");
85+ if (s != NULL)
86+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
87+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
88+ break;
89+
90+ case DT_RELASZ:
91+ /* The PLT relocs are not counted in the RELASZ value of the
92+ * .dynamic table. */
93+ s = bfd_get_linker_section (dynobj, ".rela.plt");
94+ if (s != NULL)
95+ dyn.d_un.d_val -= s->size;
96 bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
97+ break;
98 }
99 }
100
101--
1022.9.3
103