summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2011-06-21 17:58:06 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-06-22 16:57:34 +0100
commit3071ceb2bd1a42b28682e0ec851cbea62843e426 (patch)
tree2590654c66dd53559800cbc3c5eb659c6e8d1935 /meta/recipes-devtools
parentdcd3cbaf925ebdc2a7aa146a21d658fd43143305 (diff)
downloadpoky-3071ceb2bd1a42b28682e0ec851cbea62843e426.tar.gz
binutils_2.21.bb: Fix ld segfault exposed by eglibc 2.14 on x86_64
(From OE-Core rev: c8dfb7d31ceb3cc92452bda7d4fbf6fd2e248509) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/binutils/binutils-2.21/binutils-pr12366.patch428
-rw-r--r--meta/recipes-devtools/binutils/binutils_2.21.bb3
2 files changed, 430 insertions, 1 deletions
diff --git a/meta/recipes-devtools/binutils/binutils-2.21/binutils-pr12366.patch b/meta/recipes-devtools/binutils/binutils-2.21/binutils-pr12366.patch
new file mode 100644
index 0000000000..c11a802941
--- /dev/null
+++ b/meta/recipes-devtools/binutils/binutils-2.21/binutils-pr12366.patch
@@ -0,0 +1,428 @@
1This is backport from 2.21 branch
2
3Upstream-Status: Backport
4
5Signed-off-by: Khem Raj <raj.khem@gmail.com>
6
7
8commit 946593d19f203b02efd45b5102dd2787d9418e24
9Author: H.J. Lu <hjl.tools@gmail.com>
10Date: Wed May 25 17:41:32 2011 +0000
11
12 Handle STT_GNU_IFUNC symols when building shared library.
13
14 bfd/
15
16 2012-05-25 H.J. Lu <hongjiu.lu@intel.com>
17
18 Backport from mainline
19 2012-01-06 H.J. Lu <hongjiu.lu@intel.com>
20
21 PR ld/12366
22 PR ld/12371
23 * elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Properly
24 handle symbols marked with regular reference, but not non-GOT
25 reference when building shared library.
26
27 * elf32-i386.c (elf_i386_gc_sweep_hook): Properly handle
28 local and global STT_GNU_IFUNC symols when building shared
29 library.
30 * elf64-x86-64.c (elf_x86_64_gc_sweep_hook): Likewise.
31
32 ld/testsuite/
33
34 2012-05-25 H.J. Lu <hongjiu.lu@intel.com>
35
36 Backport from mainline
37 2012-01-06 H.J. Lu <hongjiu.lu@intel.com>
38
39 PR ld/12366
40 PR ld/12371
41 * ld-ifunc/ifunc-10-i386.s: Add more tests.
42 * ld-ifunc/ifunc-10-x86-64.s: Likewise.
43 * ld-ifunc/ifunc-11-i386.s: Likewise.
44 * ld-ifunc/ifunc-11-x86-64.s: Likewise.
45
46 * ld-ifunc/ifunc-12-i386.d: New.
47 * ld-ifunc/ifunc-12-i386.s: Likewise.
48 * ld-ifunc/ifunc-12-x86-64.d: Likewise.
49 * ld-ifunc/ifunc-12-x86-64.s: Likewise.
50 * ld-ifunc/ifunc-13-i386.d: Likewise.
51 * ld-ifunc/ifunc-13-x86-64.d: Likewise.
52 * ld-ifunc/ifunc-13a-i386.s: Likewise.
53 * ld-ifunc/ifunc-13a-x86-64.s: Likewise.
54 * ld-ifunc/ifunc-13b-i386.s: Likewise.
55 * ld-ifunc/ifunc-13b-x86-64.s: Likewise.
56
57Index: binutils-2.21/bfd/elf-ifunc.c
58===================================================================
59--- binutils-2.21.orig/bfd/elf-ifunc.c 2010-07-13 09:59:10.000000000 -0700
60+++ binutils-2.21/bfd/elf-ifunc.c 2011-06-21 16:33:40.751884107 -0700
61@@ -190,10 +190,29 @@
62 /* Support garbage collection against STT_GNU_IFUNC symbols. */
63 if (h->plt.refcount <= 0 && h->got.refcount <= 0)
64 {
65- h->got = htab->init_got_offset;
66- h->plt = htab->init_plt_offset;
67- *head = NULL;
68- return TRUE;
69+ /* When building shared library, we need to handle the case
70+ where it is marked with regular reference, but not non-GOT
71+ reference. It may happen if we didn't see STT_GNU_IFUNC
72+ symbol at the time when checking relocations. */
73+ bfd_size_type count = 0;
74+
75+ if (info->shared
76+ && !h->non_got_ref
77+ && h->ref_regular)
78+ {
79+ for (p = *head; p != NULL; p = p->next)
80+ count += p->count;
81+ if (count != 0)
82+ h->non_got_ref = 1;
83+ }
84+
85+ if (count == 0)
86+ {
87+ h->got = htab->init_got_offset;
88+ h->plt = htab->init_plt_offset;
89+ *head = NULL;
90+ return TRUE;
91+ }
92 }
93
94 /* Return and discard space for dynamic relocations against it if
95Index: binutils-2.21/bfd/elf32-i386.c
96===================================================================
97--- binutils-2.21.orig/bfd/elf32-i386.c 2010-10-21 05:29:02.000000000 -0700
98+++ binutils-2.21/bfd/elf32-i386.c 2011-06-21 16:33:40.761884138 -0700
99@@ -1807,23 +1807,10 @@
100 r_symndx = ELF32_R_SYM (rel->r_info);
101 if (r_symndx >= symtab_hdr->sh_info)
102 {
103- struct elf_i386_link_hash_entry *eh;
104- struct elf_dyn_relocs **pp;
105- struct elf_dyn_relocs *p;
106-
107 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
108 while (h->root.type == bfd_link_hash_indirect
109 || h->root.type == bfd_link_hash_warning)
110 h = (struct elf_link_hash_entry *) h->root.u.i.link;
111- eh = (struct elf_i386_link_hash_entry *) h;
112-
113- for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
114- if (p->sec == sec)
115- {
116- /* Everything must go for SEC. */
117- *pp = p->next;
118- break;
119- }
120 }
121 else
122 {
123@@ -1843,6 +1830,22 @@
124 }
125 }
126
127+ if (h)
128+ {
129+ struct elf_i386_link_hash_entry *eh;
130+ struct elf_dyn_relocs **pp;
131+ struct elf_dyn_relocs *p;
132+
133+ eh = (struct elf_i386_link_hash_entry *) h;
134+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
135+ if (p->sec == sec)
136+ {
137+ /* Everything must go for SEC. */
138+ *pp = p->next;
139+ break;
140+ }
141+ }
142+
143 r_type = ELF32_R_TYPE (rel->r_info);
144 if (! elf_i386_tls_transition (info, abfd, sec, NULL,
145 symtab_hdr, sym_hashes,
146@@ -1883,7 +1886,8 @@
147
148 case R_386_32:
149 case R_386_PC32:
150- if (info->shared)
151+ if (info->shared
152+ && (h == NULL || h->type != STT_GNU_IFUNC))
153 break;
154 /* Fall through */
155
156Index: binutils-2.21/bfd/elf64-x86-64.c
157===================================================================
158--- binutils-2.21.orig/bfd/elf64-x86-64.c 2010-10-21 05:29:02.000000000 -0700
159+++ binutils-2.21/bfd/elf64-x86-64.c 2011-06-21 16:33:40.761884138 -0700
160@@ -1645,23 +1645,10 @@
161 r_symndx = ELF64_R_SYM (rel->r_info);
162 if (r_symndx >= symtab_hdr->sh_info)
163 {
164- struct elf64_x86_64_link_hash_entry *eh;
165- struct elf_dyn_relocs **pp;
166- struct elf_dyn_relocs *p;
167-
168 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
169 while (h->root.type == bfd_link_hash_indirect
170 || h->root.type == bfd_link_hash_warning)
171 h = (struct elf_link_hash_entry *) h->root.u.i.link;
172- eh = (struct elf64_x86_64_link_hash_entry *) h;
173-
174- for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
175- if (p->sec == sec)
176- {
177- /* Everything must go for SEC. */
178- *pp = p->next;
179- break;
180- }
181 }
182 else
183 {
184@@ -1682,7 +1669,24 @@
185 }
186 }
187
188- r_type = ELF64_R_TYPE (rel->r_info);
189+ if (h)
190+ {
191+ struct elf64_x86_64_link_hash_entry *eh;
192+ struct elf_dyn_relocs **pp;
193+ struct elf_dyn_relocs *p;
194+
195+ eh = (struct elf64_x86_64_link_hash_entry *) h;
196+
197+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
198+ if (p->sec == sec)
199+ {
200+ /* Everything must go for SEC. */
201+ *pp = p->next;
202+ break;
203+ }
204+ }
205+
206+ r_type = ELF32_R_TYPE (rel->r_info);
207 if (! elf64_x86_64_tls_transition (info, abfd, sec, NULL,
208 symtab_hdr, sym_hashes,
209 &r_type, GOT_UNKNOWN,
210@@ -1733,7 +1737,8 @@
211 case R_X86_64_PC16:
212 case R_X86_64_PC32:
213 case R_X86_64_PC64:
214- if (info->shared)
215+ if (info->shared
216+ && (h == NULL || h->type != STT_GNU_IFUNC))
217 break;
218 /* Fall thru */
219
220Index: binutils-2.21/ld/testsuite/ld-ifunc/ifunc-10-i386.s
221===================================================================
222--- binutils-2.21.orig/ld/testsuite/ld-ifunc/ifunc-10-i386.s 2010-07-13 09:59:14.000000000 -0700
223+++ binutils-2.21/ld/testsuite/ld-ifunc/ifunc-10-i386.s 2011-06-21 16:36:36.832142380 -0700
224@@ -6,6 +6,8 @@
225 movl ifunc@GOTOFF(%ecx), %eax
226 call ifunc@PLT
227 call ifunc
228+ movl xxx@GOT(%ecx), %eax
229+ movl xxx, %eax
230 ret
231
232 .section .text.bar,"ax",@progbits
233@@ -18,3 +20,7 @@
234 .type ifunc, @gnu_indirect_function
235 ifunc:
236 ret
237+
238+ .section .data.foo,"aw",@progbits
239+xxx:
240+ .long ifunc
241Index: binutils-2.21/ld/testsuite/ld-ifunc/ifunc-10-x86-64.s
242===================================================================
243--- binutils-2.21.orig/ld/testsuite/ld-ifunc/ifunc-10-x86-64.s 2010-07-13 09:59:14.000000000 -0700
244+++ binutils-2.21/ld/testsuite/ld-ifunc/ifunc-10-x86-64.s 2011-06-21 16:36:36.822142371 -0700
245@@ -6,6 +6,7 @@
246 movl ifunc(%rip), %eax
247 call ifunc@PLT
248 call ifunc
249+ movl xxx(%rip), %eax
250 ret
251
252 .section .text.bar,"ax",@progbits
253@@ -18,3 +19,7 @@
254 .type ifunc, @gnu_indirect_function
255 ifunc:
256 ret
257+
258+ .section .data.foo,"aw",@progbits
259+xxx:
260+ .quad ifunc
261Index: binutils-2.21/ld/testsuite/ld-ifunc/ifunc-11-i386.s
262===================================================================
263--- binutils-2.21.orig/ld/testsuite/ld-ifunc/ifunc-11-i386.s 2010-07-13 09:59:14.000000000 -0700
264+++ binutils-2.21/ld/testsuite/ld-ifunc/ifunc-11-i386.s 2011-06-21 16:36:36.832142380 -0700
265@@ -3,9 +3,11 @@
266 foo:
267 .global foo
268 movl ifunc@GOT(%ecx), %eax
269- movl ifunc@GOTOFF(%ecx), %eax
270+ movl ifunc@GOTOFF(%ecx), %eax
271 call ifunc@PLT
272 call ifunc
273+ movl xxx@GOT(%ecx), %eax
274+ movl xxx, %eax
275 ret
276
277 .section .text.bar,"ax",@progbits
278@@ -16,6 +18,10 @@
279
280 .section .text.ifunc,"ax",@progbits
281 .type ifunc, @gnu_indirect_function
282- .global ifunc
283+ .global ifunc
284 ifunc:
285 ret
286+
287+ .section .data.foo,"aw",@progbits
288+xxx:
289+ .long ifunc
290Index: binutils-2.21/ld/testsuite/ld-ifunc/ifunc-11-x86-64.s
291===================================================================
292--- binutils-2.21.orig/ld/testsuite/ld-ifunc/ifunc-11-x86-64.s 2010-07-13 09:59:14.000000000 -0700
293+++ binutils-2.21/ld/testsuite/ld-ifunc/ifunc-11-x86-64.s 2011-06-21 16:36:36.822142371 -0700
294@@ -6,6 +6,7 @@
295 movl ifunc(%rip), %eax
296 call ifunc@PLT
297 call ifunc
298+ movl xxx(%rip), %eax
299 ret
300
301 .section .text.bar,"ax",@progbits
302@@ -19,3 +20,7 @@
303 .global ifunc
304 ifunc:
305 ret
306+
307+ .section .data.foo,"aw",@progbits
308+xxx:
309+ .quad ifunc
310Index: binutils-2.21/ld/testsuite/ld-ifunc/ifunc-12-i386.d
311===================================================================
312--- /dev/null 1970-01-01 00:00:00.000000000 +0000
313+++ binutils-2.21/ld/testsuite/ld-ifunc/ifunc-12-i386.d 2011-06-21 16:33:40.761884138 -0700
314@@ -0,0 +1,6 @@
315+#ld: -shared -m elf_i386 -e bar --gc-sections
316+#as: --32
317+#readelf: -r --wide
318+#target: x86_64-*-* i?86-*-*
319+
320+There are no relocations in this file.
321Index: binutils-2.21/ld/testsuite/ld-ifunc/ifunc-12-x86-64.d
322===================================================================
323--- /dev/null 1970-01-01 00:00:00.000000000 +0000
324+++ binutils-2.21/ld/testsuite/ld-ifunc/ifunc-12-x86-64.d 2011-06-21 16:33:40.761884138 -0700
325@@ -0,0 +1,6 @@
326+#ld: -shared -m elf_x86_64 -e bar --gc-sections
327+#as: --64
328+#readelf: -r --wide
329+#target: x86_64-*-*
330+
331+There are no relocations in this file.
332Index: binutils-2.21/ld/testsuite/ld-ifunc/ifunc-13-i386.d
333===================================================================
334--- /dev/null 1970-01-01 00:00:00.000000000 +0000
335+++ binutils-2.21/ld/testsuite/ld-ifunc/ifunc-13-i386.d 2011-06-21 16:33:40.761884138 -0700
336@@ -0,0 +1,19 @@
337+#source: ifunc-13a-i386.s
338+#source: ifunc-13b-i386.s
339+#ld: -shared -m elf_i386 -z nocombreloc
340+#as: --32
341+#readelf: -r --wide
342+#target: x86_64-*-* i?86-*-*
343+
344+Relocation section '.rel.got' at .*
345+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
346+#...
347+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_GLOB_DAT[ ]+ifunc\(\)[ ]+ifunc
348+#...
349+Relocation section '.rel.ifunc' at .*
350+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
351+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_32[ ]+ifunc\(\)[ ]+ifunc
352+#...
353+Relocation section '.rel.plt' at .*
354+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
355+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_JUMP_SLOT[ ]+ifunc\(\)[ ]+ifunc
356Index: binutils-2.21/ld/testsuite/ld-ifunc/ifunc-13-x86-64.d
357===================================================================
358--- /dev/null 1970-01-01 00:00:00.000000000 +0000
359+++ binutils-2.21/ld/testsuite/ld-ifunc/ifunc-13-x86-64.d 2011-06-21 16:33:40.761884138 -0700
360@@ -0,0 +1,18 @@
361+#source: ifunc-13a-x86-64.s
362+#source: ifunc-13b-x86-64.s
363+#ld: -shared -m elf_x86_64 -z nocombreloc
364+#as: --64
365+#readelf: -r --wide
366+#target: x86_64-*-*
367+
368+Relocation section '.rela.got' at .*
369+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
370+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_GLOB_DAT[ ]+ifunc\(\)[ ]+ifunc \+ 0
371+#...
372+Relocation section '.rela.ifunc' at .*
373+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
374+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_64[ ]+ifunc\(\)[ ]+ifunc \+ 0
375+#...
376+Relocation section '.rela.plt' at .*
377+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
378+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_JUMP_SLOT[ ]+ifunc\(\)[ ]+ifunc \+ 0
379Index: binutils-2.21/ld/testsuite/ld-ifunc/ifunc-13a-i386.s
380===================================================================
381--- /dev/null 1970-01-01 00:00:00.000000000 +0000
382+++ binutils-2.21/ld/testsuite/ld-ifunc/ifunc-13a-i386.s 2011-06-21 16:36:36.822142371 -0700
383@@ -0,0 +1,10 @@
384+ .text
385+ .type foo, @function
386+ .global
387+foo:
388+ movl xxx@GOT(%ebx), %eax
389+ ret
390+
391+ .data
392+xxx:
393+ .long ifunc
394Index: binutils-2.21/ld/testsuite/ld-ifunc/ifunc-13a-x86-64.s
395===================================================================
396--- /dev/null 1970-01-01 00:00:00.000000000 +0000
397+++ binutils-2.21/ld/testsuite/ld-ifunc/ifunc-13a-x86-64.s 2011-06-21 16:36:36.822142371 -0700
398@@ -0,0 +1,10 @@
399+ .text
400+ .type foo, @function
401+ .global
402+foo:
403+ movl xxx(%rip), %eax
404+ ret
405+
406+ .data
407+xxx:
408+ .quad ifunc
409Index: binutils-2.21/ld/testsuite/ld-ifunc/ifunc-13b-i386.s
410===================================================================
411--- /dev/null 1970-01-01 00:00:00.000000000 +0000
412+++ binutils-2.21/ld/testsuite/ld-ifunc/ifunc-13b-i386.s 2011-06-21 16:33:40.761884138 -0700
413@@ -0,0 +1,5 @@
414+ .text
415+ .type ifunc, @gnu_indirect_function
416+ .globl ifunc
417+ifunc:
418+ ret
419Index: binutils-2.21/ld/testsuite/ld-ifunc/ifunc-13b-x86-64.s
420===================================================================
421--- /dev/null 1970-01-01 00:00:00.000000000 +0000
422+++ binutils-2.21/ld/testsuite/ld-ifunc/ifunc-13b-x86-64.s 2011-06-21 16:33:40.761884138 -0700
423@@ -0,0 +1,5 @@
424+ .text
425+ .type ifunc, @gnu_indirect_function
426+ .globl ifunc
427+ifunc:
428+ ret
diff --git a/meta/recipes-devtools/binutils/binutils_2.21.bb b/meta/recipes-devtools/binutils/binutils_2.21.bb
index 270c720c39..2211931b1d 100644
--- a/meta/recipes-devtools/binutils/binutils_2.21.bb
+++ b/meta/recipes-devtools/binutils/binutils_2.21.bb
@@ -1,6 +1,6 @@
1require binutils.inc 1require binutils.inc
2 2
3PR = "r0" 3PR = "r1"
4 4
5LIC_FILES_CHKSUM="\ 5LIC_FILES_CHKSUM="\
6 file://src-release;endline=17;md5=4830a9ef968f3b18dd5e9f2c00db2d35\ 6 file://src-release;endline=17;md5=4830a9ef968f3b18dd5e9f2c00db2d35\
@@ -29,6 +29,7 @@ SRC_URI = "\
29 file://libiberty_path_fix.patch \ 29 file://libiberty_path_fix.patch \
30 file://binutils-poison.patch \ 30 file://binutils-poison.patch \
31 file://libtool-rpath-fix.patch \ 31 file://libtool-rpath-fix.patch \
32 file://binutils-pr12366.patch \
32 " 33 "
33 34
34SRC_URI[md5sum] = "c84c5acc9d266f1a7044b51c85a823f5" 35SRC_URI[md5sum] = "c84c5acc9d266f1a7044b51c85a823f5"