summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/binutils/binutils/fix-pr16428.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/binutils/binutils/fix-pr16428.patch')
-rw-r--r--meta/recipes-devtools/binutils/binutils/fix-pr16428.patch123
1 files changed, 123 insertions, 0 deletions
diff --git a/meta/recipes-devtools/binutils/binutils/fix-pr16428.patch b/meta/recipes-devtools/binutils/binutils/fix-pr16428.patch
new file mode 100644
index 0000000000..4584748bb2
--- /dev/null
+++ b/meta/recipes-devtools/binutils/binutils/fix-pr16428.patch
@@ -0,0 +1,123 @@
1commit 4199e3b8669d0a36448687850374fdc2ad7240b6
2Author: Alan Modra <amodra@gmail.com>
3Date: Wed Jan 15 21:50:55 2014 +1030
4
5 non-PIC references to __ehdr_start in pie and shared
6
7 Rather than hacking every backend to not discard dynamic relocations
8 against an undefined hidden __ehdr_start, make it appear to be defined
9 early. We want __ehdr_start hidden before size_dynamic_sections so
10 that it isn't put in .dynsym, but we do need the dynamic relocations
11 for a PIE or shared library with a non-PIC reference. Defining it
12 early is wrong if we don't actually define the symbol later to its
13 proper value. (In some cases we want to leave the symbol undefined,
14 for example, when the ELF header isn't loaded, and we don't have this
15 infomation available in before_allocation.)
16
17 ld/
18 * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Define
19 __ehdr_start before size_dynamic_sections and restore afterwards.
20 ld/testsuite/
21 * ld-elf/ehdr_start-shared.d: New.
22 * ld-elf/ehdr_start-userdef.d: xfail frv.
23 * ld-elf/ehdr_start-weak.d: Likewise.
24 * ld-elf/ehdr_start.d: Likewise.
25
26Upstream-Status: Backport
27
28diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
29index 9a2fe89..13f86f0 100644
30--- a/ld/emultempl/elf32.em
31+++ b/ld/emultempl/elf32.em
32@@ -1480,6 +1480,8 @@ gld${EMULATION_NAME}_before_allocation (void)
33 const char *rpath;
34 asection *sinterp;
35 bfd *abfd;
36+ struct elf_link_hash_entry *ehdr_start = NULL;
37+ struct bfd_link_hash_entry ehdr_start_save;
38
39 if (is_elf_hash_table (link_info.hash))
40 {
41@@ -1504,6 +1506,16 @@ gld${EMULATION_NAME}_before_allocation (void)
42 _bfd_elf_link_hash_hide_symbol (&link_info, h, TRUE);
43 if (ELF_ST_VISIBILITY (h->other) != STV_INTERNAL)
44 h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;
45+ /* Don't leave the symbol undefined. Undefined hidden
46+ symbols typically won't have dynamic relocations, but
47+ we most likely will need dynamic relocations for
48+ __ehdr_start if we are building a PIE or shared
49+ library. */
50+ ehdr_start = h;
51+ ehdr_start_save = h->root;
52+ h->root.type = bfd_link_hash_defined;
53+ h->root.u.def.section = bfd_abs_section_ptr;
54+ h->root.u.def.value = 0;
55 }
56 }
57
58@@ -1620,6 +1632,14 @@ ${ELF_INTERPRETER_SET_DEFAULT}
59
60 if (!bfd_elf_size_dynsym_hash_dynstr (link_info.output_bfd, &link_info))
61 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
62+
63+ if (ehdr_start != NULL)
64+ {
65+ /* If we twiddled __ehdr_start to defined earlier, put it back
66+ as it was. */
67+ ehdr_start->root.type = ehdr_start_save.type;
68+ ehdr_start->root.u = ehdr_start_save.u;
69+ }
70 }
71
72 EOF
73diff --git a/ld/testsuite/ld-elf/ehdr_start-shared.d b/ld/testsuite/ld-elf/ehdr_start-shared.d
74new file mode 100644
75index 0000000..c17516a
76--- /dev/null
77+++ b/ld/testsuite/ld-elf/ehdr_start-shared.d
78@@ -0,0 +1,9 @@
79+#source: ehdr_start.s
80+#ld: -e _start -shared
81+#nm: -n
82+#target: *-*-linux* *-*-gnu* *-*-nacl*
83+#xfail: cris*-*-* frv-*-*
84+
85+#...
86+[0-9a-f]*000 [Adrt] __ehdr_start
87+#pass
88diff --git a/ld/testsuite/ld-elf/ehdr_start-userdef.d b/ld/testsuite/ld-elf/ehdr_start-userdef.d
89index 2a88e98..b58ae3f 100644
90--- a/ld/testsuite/ld-elf/ehdr_start-userdef.d
91+++ b/ld/testsuite/ld-elf/ehdr_start-userdef.d
92@@ -2,6 +2,7 @@
93 #ld: -e _start -T ehdr_start-userdef.t
94 #readelf: -Ws
95 #target: *-*-linux* *-*-gnu* *-*-nacl*
96+#xfail: frv-*-*
97
98 #...
99 Symbol table '\.symtab' contains [0-9]+ entries:
100diff --git a/ld/testsuite/ld-elf/ehdr_start-weak.d b/ld/testsuite/ld-elf/ehdr_start-weak.d
101index 8bd9035..24ae34c 100644
102--- a/ld/testsuite/ld-elf/ehdr_start-weak.d
103+++ b/ld/testsuite/ld-elf/ehdr_start-weak.d
104@@ -2,6 +2,7 @@
105 #ld: -e _start -T ehdr_start-missing.t
106 #nm: -n
107 #target: *-*-linux* *-*-gnu* *-*-nacl*
108+#xfail: frv-*-*
109
110 #...
111 \s+[wU] __ehdr_start
112diff --git a/ld/testsuite/ld-elf/ehdr_start.d b/ld/testsuite/ld-elf/ehdr_start.d
113index 52e5b54..d538b66 100644
114--- a/ld/testsuite/ld-elf/ehdr_start.d
115+++ b/ld/testsuite/ld-elf/ehdr_start.d
116@@ -2,6 +2,7 @@
117 #ld: -e _start
118 #nm: -n
119 #target: *-*-linux* *-*-gnu* *-*-nacl*
120+#xfail: frv-*-*
121
122 #...
123 [0-9a-f]*000 [Adrt] __ehdr_start