summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/elfutils/elfutils-0.158
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/elfutils/elfutils-0.158')
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.158/CVE-2014-0172.patch35
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.158/arm_backend.diff603
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.158/core_filename.patch27
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.158/elf_additions.diff77
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.158/fixheadercheck.patch24
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.158/hppa_backend.diff800
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.158/m4-biarch.m4-tweak-AC_RUN_IFELSE-for-cross-compiling.patch34
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.158/m68k_backend.diff493
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.158/mips_backend.diff712
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.158/mips_readelf_w.patch22
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.158/redhat-portability.diff955
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.158/redhat-robustify.diff1756
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.158/scanf-format.patch40
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.158/testsuite-ignore-elflint.diff39
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.158/unwind_non_linux.patch256
15 files changed, 0 insertions, 5873 deletions
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.158/CVE-2014-0172.patch b/meta/recipes-devtools/elfutils/elfutils-0.158/CVE-2014-0172.patch
deleted file mode 100644
index 6c44314589..0000000000
--- a/meta/recipes-devtools/elfutils/elfutils-0.158/CVE-2014-0172.patch
+++ /dev/null
@@ -1,35 +0,0 @@
1From 7f1eec317db79627b473c5b149a22a1b20d1f68f Mon Sep 17 00:00:00 2001
2From: Mark Wielaard <mjw@redhat.com>
3Date: Wed, 9 Apr 2014 11:33:23 +0200
4Subject: [PATCH] CVE-2014-0172 Check for overflow before calling malloc to
5 uncompress data.
6
7https://bugzilla.redhat.com/show_bug.cgi?id=1085663
8
9Reported-by: Florian Weimer <fweimer@redhat.com>
10Signed-off-by: Mark Wielaard <mjw@redhat.com>
11
12Index: elfutils-0.158/libdw/dwarf_begin_elf.c
13===================================================================
14--- elfutils-0.158.orig/libdw/dwarf_begin_elf.c 2014-05-01 17:10:01.928213292 +0000
15+++ elfutils-0.158/libdw/dwarf_begin_elf.c 2014-05-01 17:10:01.924213375 +0000
16@@ -1,5 +1,5 @@
17 /* Create descriptor from ELF descriptor for processing file.
18- Copyright (C) 2002-2011 Red Hat, Inc.
19+ Copyright (C) 2002-2011, 2014 Red Hat, Inc.
20 This file is part of elfutils.
21 Written by Ulrich Drepper <drepper@redhat.com>, 2002.
22
23@@ -289,6 +289,12 @@
24 memcpy (&size, data->d_buf + 4, sizeof size);
25 size = be64toh (size);
26
27+ /* Check for unsigned overflow so malloc always allocated
28+ enough memory for both the Elf_Data header and the
29+ uncompressed section data. */
30+ if (unlikely (sizeof (Elf_Data) + size < size))
31+ break;
32+
33 Elf_Data *zdata = malloc (sizeof (Elf_Data) + size);
34 if (unlikely (zdata == NULL))
35 break;
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.158/arm_backend.diff b/meta/recipes-devtools/elfutils/elfutils-0.158/arm_backend.diff
deleted file mode 100644
index fc3d6dc3f4..0000000000
--- a/meta/recipes-devtools/elfutils/elfutils-0.158/arm_backend.diff
+++ /dev/null
@@ -1,603 +0,0 @@
1Index: elfutils-0.158/backends/arm_init.c
2===================================================================
3--- elfutils-0.158.orig/backends/arm_init.c 2014-04-21 11:13:24.378519252 +0000
4+++ elfutils-0.158/backends/arm_init.c 2014-04-21 11:13:24.374519343 +0000
5@@ -35,21 +35,32 @@
6 #define RELOC_PREFIX R_ARM_
7 #include "libebl_CPU.h"
8
9+#include "libebl_arm.h"
10+
11 /* This defines the common reloc hooks based on arm_reloc.def. */
12 #include "common-reloc.c"
13
14
15 const char *
16 arm_init (elf, machine, eh, ehlen)
17- Elf *elf __attribute__ ((unused));
18+ Elf *elf;
19 GElf_Half machine __attribute__ ((unused));
20 Ebl *eh;
21 size_t ehlen;
22 {
23+ int soft_float = 0;
24+
25 /* Check whether the Elf_BH object has a sufficent size. */
26 if (ehlen < sizeof (Ebl))
27 return NULL;
28
29+ if (elf) {
30+ GElf_Ehdr ehdr_mem;
31+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
32+ if (ehdr && (ehdr->e_flags & EF_ARM_SOFT_FLOAT))
33+ soft_float = 1;
34+ }
35+
36 /* We handle it. */
37 eh->name = "ARM";
38 arm_init_reloc (eh);
39@@ -61,7 +72,10 @@
40 HOOK (eh, core_note);
41 HOOK (eh, auxv_info);
42 HOOK (eh, check_object_attribute);
43- HOOK (eh, return_value_location);
44+ if (soft_float)
45+ eh->return_value_location = arm_return_value_location_soft;
46+ else
47+ eh->return_value_location = arm_return_value_location_hard;
48 HOOK (eh, abi_cfi);
49
50 return MODVERSION;
51Index: elfutils-0.158/backends/arm_regs.c
52===================================================================
53--- elfutils-0.158.orig/backends/arm_regs.c 2014-04-21 11:13:24.378519252 +0000
54+++ elfutils-0.158/backends/arm_regs.c 2014-04-21 11:13:24.374519343 +0000
55@@ -31,6 +31,7 @@
56 #endif
57
58 #include <string.h>
59+#include <stdio.h>
60 #include <dwarf.h>
61
62 #define BACKEND arm_
63@@ -76,6 +77,9 @@
64 break;
65
66 case 16 + 0 ... 16 + 7:
67+ /* AADWARF says that there are no registers in that range,
68+ * but gcc maps FPA registers here
69+ */
70 regno += 96 - 16;
71 /* Fall through. */
72 case 96 + 0 ... 96 + 7:
73@@ -87,11 +91,139 @@
74 namelen = 2;
75 break;
76
77+ case 64 + 0 ... 64 + 9:
78+ *setname = "VFP";
79+ *bits = 32;
80+ *type = DW_ATE_float;
81+ name[0] = 's';
82+ name[1] = regno - 64 + '0';
83+ namelen = 2;
84+ break;
85+
86+ case 64 + 10 ... 64 + 31:
87+ *setname = "VFP";
88+ *bits = 32;
89+ *type = DW_ATE_float;
90+ name[0] = 's';
91+ name[1] = (regno - 64) / 10 + '0';
92+ name[2] = (regno - 64) % 10 + '0';
93+ namelen = 3;
94+ break;
95+
96+ case 104 + 0 ... 104 + 7:
97+ /* XXX TODO:
98+ * This can be either intel wireless MMX general purpose/control
99+ * registers or xscale accumulator, which have different usage.
100+ * We only have the intel wireless MMX here now.
101+ * The name needs to be changed for the xscale accumulator too. */
102+ *setname = "MMX";
103+ *type = DW_ATE_unsigned;
104+ *bits = 32;
105+ memcpy(name, "wcgr", 4);
106+ name[4] = regno - 104 + '0';
107+ namelen = 5;
108+ break;
109+
110+ case 112 + 0 ... 112 + 9:
111+ *setname = "MMX";
112+ *type = DW_ATE_unsigned;
113+ *bits = 64;
114+ name[0] = 'w';
115+ name[1] = 'r';
116+ name[2] = regno - 112 + '0';
117+ namelen = 3;
118+ break;
119+
120+ case 112 + 10 ... 112 + 15:
121+ *setname = "MMX";
122+ *type = DW_ATE_unsigned;
123+ *bits = 64;
124+ name[0] = 'w';
125+ name[1] = 'r';
126+ name[2] = '1';
127+ name[3] = regno - 112 - 10 + '0';
128+ namelen = 4;
129+ break;
130+
131 case 128:
132+ *setname = "state";
133 *type = DW_ATE_unsigned;
134 return stpcpy (name, "spsr") + 1 - name;
135
136+ case 129:
137+ *setname = "state";
138+ *type = DW_ATE_unsigned;
139+ return stpcpy(name, "spsr_fiq") + 1 - name;
140+
141+ case 130:
142+ *setname = "state";
143+ *type = DW_ATE_unsigned;
144+ return stpcpy(name, "spsr_irq") + 1 - name;
145+
146+ case 131:
147+ *setname = "state";
148+ *type = DW_ATE_unsigned;
149+ return stpcpy(name, "spsr_abt") + 1 - name;
150+
151+ case 132:
152+ *setname = "state";
153+ *type = DW_ATE_unsigned;
154+ return stpcpy(name, "spsr_und") + 1 - name;
155+
156+ case 133:
157+ *setname = "state";
158+ *type = DW_ATE_unsigned;
159+ return stpcpy(name, "spsr_svc") + 1 - name;
160+
161+ case 144 ... 150:
162+ *setname = "integer";
163+ *type = DW_ATE_signed;
164+ *bits = 32;
165+ return sprintf(name, "r%d_usr", regno - 144 + 8) + 1;
166+
167+ case 151 ... 157:
168+ *setname = "integer";
169+ *type = DW_ATE_signed;
170+ *bits = 32;
171+ return sprintf(name, "r%d_fiq", regno - 151 + 8) + 1;
172+
173+ case 158 ... 159:
174+ *setname = "integer";
175+ *type = DW_ATE_signed;
176+ *bits = 32;
177+ return sprintf(name, "r%d_irq", regno - 158 + 13) + 1;
178+
179+ case 160 ... 161:
180+ *setname = "integer";
181+ *type = DW_ATE_signed;
182+ *bits = 32;
183+ return sprintf(name, "r%d_abt", regno - 160 + 13) + 1;
184+
185+ case 162 ... 163:
186+ *setname = "integer";
187+ *type = DW_ATE_signed;
188+ *bits = 32;
189+ return sprintf(name, "r%d_und", regno - 162 + 13) + 1;
190+
191+ case 164 ... 165:
192+ *setname = "integer";
193+ *type = DW_ATE_signed;
194+ *bits = 32;
195+ return sprintf(name, "r%d_svc", regno - 164 + 13) + 1;
196+
197+ case 192 ... 199:
198+ *setname = "MMX";
199+ *bits = 32;
200+ *type = DW_ATE_unsigned;
201+ name[0] = 'w';
202+ name[1] = 'c';
203+ name[2] = regno - 192 + '0';
204+ namelen = 3;
205+ break;
206+
207 case 256 + 0 ... 256 + 9:
208+ /* XXX TODO: Neon also uses those registers and can contain
209+ * both float and integers */
210 *setname = "VFP";
211 *type = DW_ATE_float;
212 *bits = 64;
213Index: elfutils-0.158/backends/arm_retval.c
214===================================================================
215--- elfutils-0.158.orig/backends/arm_retval.c 2014-04-21 11:13:24.378519252 +0000
216+++ elfutils-0.158/backends/arm_retval.c 2014-04-21 11:13:24.374519343 +0000
217@@ -48,6 +48,13 @@
218 #define nloc_intreg 1
219 #define nloc_intregs(n) (2 * (n))
220
221+/* f1 */ /* XXX TODO: f0 can also have number 96 if program was compiled with -mabi=aapcs */
222+static const Dwarf_Op loc_fpreg[] =
223+ {
224+ { .atom = DW_OP_reg16 },
225+ };
226+#define nloc_fpreg 1
227+
228 /* The return value is a structure and is actually stored in stack space
229 passed in a hidden argument by the caller. But, the compiler
230 helpfully returns the address of that space in r0. */
231@@ -58,8 +65,9 @@
232 #define nloc_aggregate 1
233
234
235-int
236-arm_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
237+static int
238+arm_return_value_location_ (Dwarf_Die *functypedie, const Dwarf_Op **locp,
239+ int soft_float)
240 {
241 /* Start with the function's type, and get the DW_AT_type attribute,
242 which is the type of the return value. */
243@@ -112,14 +120,31 @@
244 else
245 return -1;
246 }
247+ if (tag == DW_TAG_base_type)
248+ {
249+ Dwarf_Word encoding;
250+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
251+ &attr_mem), &encoding) != 0)
252+ return -1;
253+
254+ if ((encoding == DW_ATE_float) && !soft_float)
255+ {
256+ *locp = loc_fpreg;
257+ if (size <= 8)
258+ return nloc_fpreg;
259+ goto aggregate;
260+ }
261+ }
262 if (size <= 16)
263 {
264 intreg:
265 *locp = loc_intreg;
266 return size <= 4 ? nloc_intreg : nloc_intregs ((size + 3) / 4);
267 }
268+ /* fall through. */
269
270 aggregate:
271+ /* XXX TODO sometimes aggregates are returned in r0 (-mabi=aapcs) */
272 *locp = loc_aggregate;
273 return nloc_aggregate;
274
275@@ -138,3 +163,18 @@
276 DWARF and might be valid. */
277 return -2;
278 }
279+
280+/* return location for -mabi=apcs-gnu -msoft-float */
281+int
282+arm_return_value_location_soft (Dwarf_Die *functypedie, const Dwarf_Op **locp)
283+{
284+ return arm_return_value_location_ (functypedie, locp, 1);
285+}
286+
287+/* return location for -mabi=apcs-gnu -mhard-float (current default) */
288+int
289+arm_return_value_location_hard (Dwarf_Die *functypedie, const Dwarf_Op **locp)
290+{
291+ return arm_return_value_location_ (functypedie, locp, 0);
292+}
293+
294Index: elfutils-0.158/libelf/elf.h
295===================================================================
296--- elfutils-0.158.orig/libelf/elf.h 2014-04-21 11:13:24.378519252 +0000
297+++ elfutils-0.158/libelf/elf.h 2014-04-21 11:13:24.374519343 +0000
298@@ -2318,6 +2318,9 @@
299 #define EF_ARM_EABI_VER4 0x04000000
300 #define EF_ARM_EABI_VER5 0x05000000
301
302+/* EI_OSABI values */
303+#define ELFOSABI_ARM_AEABI 64 /* Contains symbol versioning. */
304+
305 /* Additional symbol types for Thumb. */
306 #define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */
307 #define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */
308@@ -2335,12 +2338,19 @@
309
310 /* Processor specific values for the Phdr p_type field. */
311 #define PT_ARM_EXIDX (PT_LOPROC + 1) /* ARM unwind segment. */
312+#define PT_ARM_UNWIND PT_ARM_EXIDX
313
314 /* Processor specific values for the Shdr sh_type field. */
315 #define SHT_ARM_EXIDX (SHT_LOPROC + 1) /* ARM unwind section. */
316 #define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) /* Preemption details. */
317 #define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) /* ARM attributes section. */
318
319+/* Processor specific values for the Dyn d_tag field. */
320+#define DT_ARM_RESERVED1 (DT_LOPROC + 0)
321+#define DT_ARM_SYMTABSZ (DT_LOPROC + 1)
322+#define DT_ARM_PREEMTMAB (DT_LOPROC + 2)
323+#define DT_ARM_RESERVED2 (DT_LOPROC + 3)
324+#define DT_ARM_NUM 4
325
326 /* AArch64 relocs. */
327
328@@ -2619,6 +2629,7 @@
329 TLS block (LDR, STR). */
330 #define R_ARM_TLS_IE12GP 111 /* 12 bit GOT entry relative
331 to GOT origin (LDR). */
332+/* 112 - 127 private range */
333 #define R_ARM_ME_TOO 128 /* Obsolete. */
334 #define R_ARM_THM_TLS_DESCSEQ 129
335 #define R_ARM_THM_TLS_DESCSEQ16 129
336Index: elfutils-0.158/backends/libebl_arm.h
337===================================================================
338--- /dev/null 1970-01-01 00:00:00.000000000 +0000
339+++ elfutils-0.158/backends/libebl_arm.h 2014-04-21 11:13:24.374519343 +0000
340@@ -0,0 +1,9 @@
341+#ifndef _LIBEBL_ARM_H
342+#define _LIBEBL_ARM_H 1
343+
344+#include <libdw.h>
345+
346+extern int arm_return_value_location_soft(Dwarf_Die *, const Dwarf_Op **locp);
347+extern int arm_return_value_location_hard(Dwarf_Die *, const Dwarf_Op **locp);
348+
349+#endif
350Index: elfutils-0.158/tests/run-allregs.sh
351===================================================================
352--- elfutils-0.158.orig/tests/run-allregs.sh 2014-04-21 11:13:24.378519252 +0000
353+++ elfutils-0.158/tests/run-allregs.sh 2014-04-21 11:13:24.378519252 +0000
354@@ -2671,7 +2671,28 @@
355 13: sp (sp), address 32 bits
356 14: lr (lr), address 32 bits
357 15: pc (pc), address 32 bits
358- 128: spsr (spsr), unsigned 32 bits
359+ 144: r8_usr (r8_usr), signed 32 bits
360+ 145: r9_usr (r9_usr), signed 32 bits
361+ 146: r10_usr (r10_usr), signed 32 bits
362+ 147: r11_usr (r11_usr), signed 32 bits
363+ 148: r12_usr (r12_usr), signed 32 bits
364+ 149: r13_usr (r13_usr), signed 32 bits
365+ 150: r14_usr (r14_usr), signed 32 bits
366+ 151: r8_fiq (r8_fiq), signed 32 bits
367+ 152: r9_fiq (r9_fiq), signed 32 bits
368+ 153: r10_fiq (r10_fiq), signed 32 bits
369+ 154: r11_fiq (r11_fiq), signed 32 bits
370+ 155: r12_fiq (r12_fiq), signed 32 bits
371+ 156: r13_fiq (r13_fiq), signed 32 bits
372+ 157: r14_fiq (r14_fiq), signed 32 bits
373+ 158: r13_irq (r13_irq), signed 32 bits
374+ 159: r14_irq (r14_irq), signed 32 bits
375+ 160: r13_abt (r13_abt), signed 32 bits
376+ 161: r14_abt (r14_abt), signed 32 bits
377+ 162: r13_und (r13_und), signed 32 bits
378+ 163: r14_und (r14_und), signed 32 bits
379+ 164: r13_svc (r13_svc), signed 32 bits
380+ 165: r14_svc (r14_svc), signed 32 bits
381 FPA registers:
382 16: f0 (f0), float 96 bits
383 17: f1 (f1), float 96 bits
384@@ -2689,7 +2710,72 @@
385 101: f5 (f5), float 96 bits
386 102: f6 (f6), float 96 bits
387 103: f7 (f7), float 96 bits
388+MMX registers:
389+ 104: wcgr0 (wcgr0), unsigned 32 bits
390+ 105: wcgr1 (wcgr1), unsigned 32 bits
391+ 106: wcgr2 (wcgr2), unsigned 32 bits
392+ 107: wcgr3 (wcgr3), unsigned 32 bits
393+ 108: wcgr4 (wcgr4), unsigned 32 bits
394+ 109: wcgr5 (wcgr5), unsigned 32 bits
395+ 110: wcgr6 (wcgr6), unsigned 32 bits
396+ 111: wcgr7 (wcgr7), unsigned 32 bits
397+ 112: wr0 (wr0), unsigned 64 bits
398+ 113: wr1 (wr1), unsigned 64 bits
399+ 114: wr2 (wr2), unsigned 64 bits
400+ 115: wr3 (wr3), unsigned 64 bits
401+ 116: wr4 (wr4), unsigned 64 bits
402+ 117: wr5 (wr5), unsigned 64 bits
403+ 118: wr6 (wr6), unsigned 64 bits
404+ 119: wr7 (wr7), unsigned 64 bits
405+ 120: wr8 (wr8), unsigned 64 bits
406+ 121: wr9 (wr9), unsigned 64 bits
407+ 122: wr10 (wr10), unsigned 64 bits
408+ 123: wr11 (wr11), unsigned 64 bits
409+ 124: wr12 (wr12), unsigned 64 bits
410+ 125: wr13 (wr13), unsigned 64 bits
411+ 126: wr14 (wr14), unsigned 64 bits
412+ 127: wr15 (wr15), unsigned 64 bits
413+ 192: wc0 (wc0), unsigned 32 bits
414+ 193: wc1 (wc1), unsigned 32 bits
415+ 194: wc2 (wc2), unsigned 32 bits
416+ 195: wc3 (wc3), unsigned 32 bits
417+ 196: wc4 (wc4), unsigned 32 bits
418+ 197: wc5 (wc5), unsigned 32 bits
419+ 198: wc6 (wc6), unsigned 32 bits
420+ 199: wc7 (wc7), unsigned 32 bits
421 VFP registers:
422+ 64: s0 (s0), float 32 bits
423+ 65: s1 (s1), float 32 bits
424+ 66: s2 (s2), float 32 bits
425+ 67: s3 (s3), float 32 bits
426+ 68: s4 (s4), float 32 bits
427+ 69: s5 (s5), float 32 bits
428+ 70: s6 (s6), float 32 bits
429+ 71: s7 (s7), float 32 bits
430+ 72: s8 (s8), float 32 bits
431+ 73: s9 (s9), float 32 bits
432+ 74: s10 (s10), float 32 bits
433+ 75: s11 (s11), float 32 bits
434+ 76: s12 (s12), float 32 bits
435+ 77: s13 (s13), float 32 bits
436+ 78: s14 (s14), float 32 bits
437+ 79: s15 (s15), float 32 bits
438+ 80: s16 (s16), float 32 bits
439+ 81: s17 (s17), float 32 bits
440+ 82: s18 (s18), float 32 bits
441+ 83: s19 (s19), float 32 bits
442+ 84: s20 (s20), float 32 bits
443+ 85: s21 (s21), float 32 bits
444+ 86: s22 (s22), float 32 bits
445+ 87: s23 (s23), float 32 bits
446+ 88: s24 (s24), float 32 bits
447+ 89: s25 (s25), float 32 bits
448+ 90: s26 (s26), float 32 bits
449+ 91: s27 (s27), float 32 bits
450+ 92: s28 (s28), float 32 bits
451+ 93: s29 (s29), float 32 bits
452+ 94: s30 (s30), float 32 bits
453+ 95: s31 (s31), float 32 bits
454 256: d0 (d0), float 64 bits
455 257: d1 (d1), float 64 bits
456 258: d2 (d2), float 64 bits
457@@ -2722,6 +2808,13 @@
458 285: d29 (d29), float 64 bits
459 286: d30 (d30), float 64 bits
460 287: d31 (d31), float 64 bits
461+state registers:
462+ 128: spsr (spsr), unsigned 32 bits
463+ 129: spsr_fiq (spsr_fiq), unsigned 32 bits
464+ 130: spsr_irq (spsr_irq), unsigned 32 bits
465+ 131: spsr_abt (spsr_abt), unsigned 32 bits
466+ 132: spsr_und (spsr_und), unsigned 32 bits
467+ 133: spsr_svc (spsr_svc), unsigned 32 bits
468 EOF
469
470 # See run-readelf-mixed-corenote.sh for instructions to regenerate
471Index: elfutils-0.158/tests/run-readelf-mixed-corenote.sh
472===================================================================
473--- elfutils-0.158.orig/tests/run-readelf-mixed-corenote.sh 2014-04-21 11:13:24.378519252 +0000
474+++ elfutils-0.158/tests/run-readelf-mixed-corenote.sh 2014-04-21 11:13:24.378519252 +0000
475@@ -30,12 +30,11 @@
476 pid: 11087, ppid: 11063, pgrp: 11087, sid: 11063
477 utime: 0.000000, stime: 0.010000, cutime: 0.000000, cstime: 0.000000
478 orig_r0: -1, fpvalid: 1
479- r0: 1 r1: -1091672508 r2: -1091672500
480- r3: 0 r4: 0 r5: 0
481- r6: 33728 r7: 0 r8: 0
482- r9: 0 r10: -1225703496 r11: -1091672844
483- r12: 0 sp: 0xbeee64f4 lr: 0xb6dc3f48
484- pc: 0x00008500 spsr: 0x60000010
485+ r0: 1 r1: -1091672508 r2: -1091672500 r3: 0
486+ r4: 0 r5: 0 r6: 33728 r7: 0
487+ r8: 0 r9: 0 r10: -1225703496 r11: -1091672844
488+ r12: 0 sp: 0xbeee64f4 lr: 0xb6dc3f48 pc: 0x00008500
489+ spsr: 0x60000010
490 CORE 124 PRPSINFO
491 state: 0, sname: R, zomb: 0, nice: 0, flag: 0x00400500
492 uid: 0, gid: 0, pid: 11087, ppid: 11063, pgrp: 11087, sid: 11063
493Index: elfutils-0.158/tests/run-addrcfi.sh
494===================================================================
495--- elfutils-0.158.orig/tests/run-addrcfi.sh 2014-04-21 11:13:24.378519252 +0000
496+++ elfutils-0.158/tests/run-addrcfi.sh 2014-04-21 11:13:24.378519252 +0000
497@@ -2530,6 +2530,38 @@
498 FPA reg21 (f5): undefined
499 FPA reg22 (f6): undefined
500 FPA reg23 (f7): undefined
501+ VFP reg64 (s0): undefined
502+ VFP reg65 (s1): undefined
503+ VFP reg66 (s2): undefined
504+ VFP reg67 (s3): undefined
505+ VFP reg68 (s4): undefined
506+ VFP reg69 (s5): undefined
507+ VFP reg70 (s6): undefined
508+ VFP reg71 (s7): undefined
509+ VFP reg72 (s8): undefined
510+ VFP reg73 (s9): undefined
511+ VFP reg74 (s10): undefined
512+ VFP reg75 (s11): undefined
513+ VFP reg76 (s12): undefined
514+ VFP reg77 (s13): undefined
515+ VFP reg78 (s14): undefined
516+ VFP reg79 (s15): undefined
517+ VFP reg80 (s16): undefined
518+ VFP reg81 (s17): undefined
519+ VFP reg82 (s18): undefined
520+ VFP reg83 (s19): undefined
521+ VFP reg84 (s20): undefined
522+ VFP reg85 (s21): undefined
523+ VFP reg86 (s22): undefined
524+ VFP reg87 (s23): undefined
525+ VFP reg88 (s24): undefined
526+ VFP reg89 (s25): undefined
527+ VFP reg90 (s26): undefined
528+ VFP reg91 (s27): undefined
529+ VFP reg92 (s28): undefined
530+ VFP reg93 (s29): undefined
531+ VFP reg94 (s30): undefined
532+ VFP reg95 (s31): undefined
533 FPA reg96 (f0): undefined
534 FPA reg97 (f1): undefined
535 FPA reg98 (f2): undefined
536@@ -2538,7 +2570,66 @@
537 FPA reg101 (f5): undefined
538 FPA reg102 (f6): undefined
539 FPA reg103 (f7): undefined
540- integer reg128 (spsr): undefined
541+ MMX reg104 (wcgr0): undefined
542+ MMX reg105 (wcgr1): undefined
543+ MMX reg106 (wcgr2): undefined
544+ MMX reg107 (wcgr3): undefined
545+ MMX reg108 (wcgr4): undefined
546+ MMX reg109 (wcgr5): undefined
547+ MMX reg110 (wcgr6): undefined
548+ MMX reg111 (wcgr7): undefined
549+ MMX reg112 (wr0): undefined
550+ MMX reg113 (wr1): undefined
551+ MMX reg114 (wr2): undefined
552+ MMX reg115 (wr3): undefined
553+ MMX reg116 (wr4): undefined
554+ MMX reg117 (wr5): undefined
555+ MMX reg118 (wr6): undefined
556+ MMX reg119 (wr7): undefined
557+ MMX reg120 (wr8): undefined
558+ MMX reg121 (wr9): undefined
559+ MMX reg122 (wr10): undefined
560+ MMX reg123 (wr11): undefined
561+ MMX reg124 (wr12): undefined
562+ MMX reg125 (wr13): undefined
563+ MMX reg126 (wr14): undefined
564+ MMX reg127 (wr15): undefined
565+ state reg128 (spsr): undefined
566+ state reg129 (spsr_fiq): undefined
567+ state reg130 (spsr_irq): undefined
568+ state reg131 (spsr_abt): undefined
569+ state reg132 (spsr_und): undefined
570+ state reg133 (spsr_svc): undefined
571+ integer reg144 (r8_usr): undefined
572+ integer reg145 (r9_usr): undefined
573+ integer reg146 (r10_usr): undefined
574+ integer reg147 (r11_usr): undefined
575+ integer reg148 (r12_usr): undefined
576+ integer reg149 (r13_usr): undefined
577+ integer reg150 (r14_usr): undefined
578+ integer reg151 (r8_fiq): undefined
579+ integer reg152 (r9_fiq): undefined
580+ integer reg153 (r10_fiq): undefined
581+ integer reg154 (r11_fiq): undefined
582+ integer reg155 (r12_fiq): undefined
583+ integer reg156 (r13_fiq): undefined
584+ integer reg157 (r14_fiq): undefined
585+ integer reg158 (r13_irq): undefined
586+ integer reg159 (r14_irq): undefined
587+ integer reg160 (r13_abt): undefined
588+ integer reg161 (r14_abt): undefined
589+ integer reg162 (r13_und): undefined
590+ integer reg163 (r14_und): undefined
591+ integer reg164 (r13_svc): undefined
592+ integer reg165 (r14_svc): undefined
593+ MMX reg192 (wc0): undefined
594+ MMX reg193 (wc1): undefined
595+ MMX reg194 (wc2): undefined
596+ MMX reg195 (wc3): undefined
597+ MMX reg196 (wc4): undefined
598+ MMX reg197 (wc5): undefined
599+ MMX reg198 (wc6): undefined
600+ MMX reg199 (wc7): undefined
601 VFP reg256 (d0): undefined
602 VFP reg257 (d1): undefined
603 VFP reg258 (d2): undefined
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.158/core_filename.patch b/meta/recipes-devtools/elfutils/elfutils-0.158/core_filename.patch
deleted file mode 100644
index e2f0576d7b..0000000000
--- a/meta/recipes-devtools/elfutils/elfutils-0.158/core_filename.patch
+++ /dev/null
@@ -1,27 +0,0 @@
1From: Matthias Klose <doko@ubuntu.com>
2Date: Tue, 7 Jan 2014 10:25:29 +0100
3Subject: [PATCH] tests: backtrace-subr.sh (check_native_core) should check
4 core file name.
5
6Needed when /proc/sys/kernel/core_uses_pid is set to 0. Try to rename
7the core file, and if it does still fail, skip the test.
8
9diff --git a/tests/backtrace-subr.sh b/tests/backtrace-subr.sh
10index e7ece91..62b873c 100644
11--- a/tests/backtrace-subr.sh
12+++ b/tests/backtrace-subr.sh
13@@ -111,6 +111,11 @@ check_native_core()
14
15 # Skip the test if we cannot adjust core ulimit.
16 core="core.`ulimit -c unlimited || exit 77; set +ex; testrun ${abs_builddir}/$child --gencore; true`"
17+ # see if /proc/sys/kernel/core_uses_pid is set to 0
18+ if [ -f core ]; then
19+ mv core "$core"
20+ fi
21+ if [ ! -f "$core" ]; then exit 77; fi
22
23 if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then
24 VALGRIND_CMD="$SAVED_VALGRIND_CMD"
25--
261.9.2
27
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.158/elf_additions.diff b/meta/recipes-devtools/elfutils/elfutils-0.158/elf_additions.diff
deleted file mode 100644
index 671c8ee1ae..0000000000
--- a/meta/recipes-devtools/elfutils/elfutils-0.158/elf_additions.diff
+++ /dev/null
@@ -1,77 +0,0 @@
1Upstream-Status: Backport
2
3Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
4---
5 libelf/elf.h | 27 +++++++++++++++++++++++++--
6 1 file changed, 25 insertions(+), 2 deletions(-)
7
8diff --git a/libelf/elf.h b/libelf/elf.h
9--- a/libelf/elf.h
10+++ b/libelf/elf.h
11@@ -142,6 +142,7 @@ typedef struct
12 #define ELFOSABI_NETBSD 2 /* NetBSD. */
13 #define ELFOSABI_GNU 3 /* Object uses GNU ELF extensions. */
14 #define ELFOSABI_LINUX ELFOSABI_GNU /* Compatibility alias. */
15+#define ELFOSABI_HURD 4 /* GNU/Hurd */
16 #define ELFOSABI_SOLARIS 6 /* Sun Solaris. */
17 #define ELFOSABI_AIX 7 /* IBM AIX. */
18 #define ELFOSABI_IRIX 8 /* SGI Irix. */
19@@ -149,8 +150,13 @@ typedef struct
20 #define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */
21 #define ELFOSABI_MODESTO 11 /* Novell Modesto. */
22 #define ELFOSABI_OPENBSD 12 /* OpenBSD. */
23+#define ELFOSABI_OPENVMS 13 /* OpenVMS */
24+#define ELFOSABI_NSK 14 /* Hewlett-Packard Non-Stop Kernel */
25+#define ELFOSABI_AROS 15 /* Amiga Research OS */
26+/* 64-255 Architecture-specific value range */
27 #define ELFOSABI_ARM_AEABI 64 /* ARM EABI */
28 #define ELFOSABI_ARM 97 /* ARM */
29+/* This is deprecated? It's not in the latest version anymore. */
30 #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
31
32 #define EI_ABIVERSION 8 /* ABI version */
33@@ -205,7 +211,7 @@ typedef struct
34 #define EM_H8_300H 47 /* Hitachi H8/300H */
35 #define EM_H8S 48 /* Hitachi H8S */
36 #define EM_H8_500 49 /* Hitachi H8/500 */
37-#define EM_IA_64 50 /* Intel Merced */
38+#define EM_IA_64 50 /* Intel IA64 */
39 #define EM_MIPS_X 51 /* Stanford MIPS-X */
40 #define EM_COLDFIRE 52 /* Motorola Coldfire */
41 #define EM_68HC12 53 /* Motorola M68HC12 */
42@@ -219,7 +225,8 @@ typedef struct
43 #define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
44 #define EM_X86_64 62 /* AMD x86-64 architecture */
45 #define EM_PDSP 63 /* Sony DSP Processor */
46-
47+#define EM_PDP10 64 /* Digital Equipment Corp. PDP-10 */
48+#define EM_PDP11 65 /* Digital Equipment Corp. PDP-11 */
49 #define EM_FX66 66 /* Siemens FX66 microcontroller */
50 #define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
51 #define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
52@@ -249,6 +256,22 @@ typedef struct
53 #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
54 #define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
55 #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
56+#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */
57+#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Processor */
58+#define EM_NS32K 97 /* National Semiconductor 32000 series */
59+#define EM_TPC 98 /* Tenor Network TPC processor */
60+#define EM_SNP1K 99 /* Trebia SNP 1000 processor */
61+#define EM_ST200 100 /* STMicroelectronics (www.st.com) ST200 microcontroller */
62+#define EM_IP2K 101 /* Ubicom IP2XXX microcontroller family */
63+#define EM_MAX 102 /* MAX Processor */
64+#define EM_CR 103 /* National Semiconductor CompactRISC */
65+#define EM_F2MC16 104 /* Fujitsu F2MC16 */
66+#define EM_MSP430 105 /* TI msp430 micro controller */
67+#define EM_BLACKFIN 106 /* Analog Devices Blackfin (DSP) processor */
68+#define EM_SE_C33 107 /* S1C33 Family of Seiko Epson processors */
69+#define EM_SEP 108 /* Sharp embedded microprocessor */
70+#define EM_ARCA 109 /* Arca RISC Microprocessor */
71+
72 #define EM_AARCH64 183 /* ARM AARCH64 */
73 #define EM_TILEPRO 188 /* Tilera TILEPro */
74 #define EM_MICROBLAZE 189 /* Xilinx MicroBlaze */
75--
761.8.1.2
77
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.158/fixheadercheck.patch b/meta/recipes-devtools/elfutils/elfutils-0.158/fixheadercheck.patch
deleted file mode 100644
index 8796e9a394..0000000000
--- a/meta/recipes-devtools/elfutils/elfutils-0.158/fixheadercheck.patch
+++ /dev/null
@@ -1,24 +0,0 @@
1For some binaries we can get a invalid section alignment, for example if
2sh_align = 1 and sh_addralign is 0. In the case of a zero size section like
3".note.GNU-stack", this is irrelavent as far as I can tell and we shouldn't
4error in this case.
5
6RP 2014/6/11
7
8Upstream-Status: Pending
9
10Index: elfutils-0.158/libelf/elf32_updatenull.c
11===================================================================
12--- elfutils-0.158.orig/libelf/elf32_updatenull.c 2012-12-14 22:40:48.000000000 +0000
13+++ elfutils-0.158/libelf/elf32_updatenull.c 2014-06-11 16:35:43.417386291 +0000
14@@ -327,8 +327,8 @@
15 we test for the alignment of the section being large
16 enough for the largest alignment required by a data
17 block. */
18- if (unlikely (! powerof2 (shdr->sh_addralign))
19- || unlikely (shdr->sh_addralign < sh_align))
20+ if (shdr->sh_size && (unlikely (! powerof2 (shdr->sh_addralign))
21+ || unlikely (shdr->sh_addralign < sh_align)))
22 {
23 __libelf_seterrno (ELF_E_INVALID_ALIGN);
24 return -1;
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.158/hppa_backend.diff b/meta/recipes-devtools/elfutils/elfutils-0.158/hppa_backend.diff
deleted file mode 100644
index 6c19d176e0..0000000000
--- a/meta/recipes-devtools/elfutils/elfutils-0.158/hppa_backend.diff
+++ /dev/null
@@ -1,800 +0,0 @@
1Index: elfutils-0.158/backends/parisc_init.c
2===================================================================
3--- /dev/null 1970-01-01 00:00:00.000000000 +0000
4+++ elfutils-0.158/backends/parisc_init.c 2014-04-21 11:12:12.228150280 +0000
5@@ -0,0 +1,74 @@
6+/* Initialization of PA-RISC specific backend library.
7+ Copyright (C) 2002, 2005, 2006 Red Hat, Inc.
8+ This file is part of Red Hat elfutils.
9+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
10+
11+ Red Hat elfutils is free software; you can redistribute it and/or modify
12+ it under the terms of the GNU General Public License as published by the
13+ Free Software Foundation; version 2 of the License.
14+
15+ Red Hat elfutils is distributed in the hope that it will be useful, but
16+ WITHOUT ANY WARRANTY; without even the implied warranty of
17+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18+ General Public License for more details.
19+
20+ You should have received a copy of the GNU General Public License along
21+ with Red Hat elfutils; if not, write to the Free Software Foundation,
22+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
23+
24+ Red Hat elfutils is an included package of the Open Invention Network.
25+ An included package of the Open Invention Network is a package for which
26+ Open Invention Network licensees cross-license their patents. No patent
27+ license is granted, either expressly or impliedly, by designation as an
28+ included package. Should you wish to participate in the Open Invention
29+ Network licensing program, please visit www.openinventionnetwork.com
30+ <http://www.openinventionnetwork.com>. */
31+
32+#ifdef HAVE_CONFIG_H
33+# include <config.h>
34+#endif
35+
36+#define BACKEND parisc_
37+#define RELOC_PREFIX R_PARISC_
38+#include "libebl_CPU.h"
39+#include "libebl_parisc.h"
40+
41+/* This defines the common reloc hooks based on parisc_reloc.def. */
42+#include "common-reloc.c"
43+
44+
45+const char *
46+parisc_init (elf, machine, eh, ehlen)
47+ Elf *elf __attribute__ ((unused));
48+ GElf_Half machine __attribute__ ((unused));
49+ Ebl *eh;
50+ size_t ehlen;
51+{
52+ int pa64 = 0;
53+
54+ /* Check whether the Elf_BH object has a sufficent size. */
55+ if (ehlen < sizeof (Ebl))
56+ return NULL;
57+
58+ if (elf) {
59+ GElf_Ehdr ehdr_mem;
60+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
61+ if (ehdr && (ehdr->e_flags & EF_PARISC_WIDE))
62+ pa64 = 1;
63+ }
64+ /* We handle it. */
65+ eh->name = "PA-RISC";
66+ parisc_init_reloc (eh);
67+ HOOK (eh, reloc_simple_type);
68+ HOOK (eh, machine_flag_check);
69+ HOOK (eh, symbol_type_name);
70+ HOOK (eh, segment_type_name);
71+ HOOK (eh, section_type_name);
72+ HOOK (eh, register_info);
73+ if (pa64)
74+ eh->return_value_location = parisc_return_value_location_64;
75+ else
76+ eh->return_value_location = parisc_return_value_location_32;
77+
78+ return MODVERSION;
79+}
80Index: elfutils-0.158/backends/parisc_regs.c
81===================================================================
82--- /dev/null 1970-01-01 00:00:00.000000000 +0000
83+++ elfutils-0.158/backends/parisc_regs.c 2014-04-21 11:12:12.228150280 +0000
84@@ -0,0 +1,159 @@
85+/* Register names and numbers for PA-RISC DWARF.
86+ Copyright (C) 2005, 2006 Red Hat, Inc.
87+ This file is part of Red Hat elfutils.
88+
89+ Red Hat elfutils is free software; you can redistribute it and/or modify
90+ it under the terms of the GNU General Public License as published by the
91+ Free Software Foundation; version 2 of the License.
92+
93+ Red Hat elfutils is distributed in the hope that it will be useful, but
94+ WITHOUT ANY WARRANTY; without even the implied warranty of
95+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
96+ General Public License for more details.
97+
98+ You should have received a copy of the GNU General Public License along
99+ with Red Hat elfutils; if not, write to the Free Software Foundation,
100+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
101+
102+ Red Hat elfutils is an included package of the Open Invention Network.
103+ An included package of the Open Invention Network is a package for which
104+ Open Invention Network licensees cross-license their patents. No patent
105+ license is granted, either expressly or impliedly, by designation as an
106+ included package. Should you wish to participate in the Open Invention
107+ Network licensing program, please visit www.openinventionnetwork.com
108+ <http://www.openinventionnetwork.com>. */
109+
110+#ifdef HAVE_CONFIG_H
111+# include <config.h>
112+#endif
113+
114+#include <string.h>
115+#include <dwarf.h>
116+
117+#define BACKEND parisc_
118+#include "libebl_CPU.h"
119+
120+ssize_t
121+parisc_register_info (Ebl *ebl, int regno, char *name, size_t namelen,
122+ const char **prefix, const char **setname,
123+ int *bits, int *type)
124+{
125+ int pa64 = 0;
126+
127+ if (ebl->elf) {
128+ GElf_Ehdr ehdr_mem;
129+ GElf_Ehdr *ehdr = gelf_getehdr (ebl->elf, &ehdr_mem);
130+ if (ehdr->e_flags & EF_PARISC_WIDE)
131+ pa64 = 1;
132+ }
133+
134+ int nregs = pa64 ? 127 : 128;
135+
136+ if (name == NULL)
137+ return nregs;
138+
139+ if (regno < 0 || regno >= nregs || namelen < 6)
140+ return -1;
141+
142+ *prefix = "%";
143+
144+ if (regno < 32)
145+ {
146+ *setname = "integer";
147+ *type = DW_ATE_signed;
148+ if (pa64)
149+ {
150+ *bits = 64;
151+ }
152+ else
153+ {
154+ *bits = 32;
155+ }
156+ }
157+ else if (regno == 32)
158+ {
159+ *setname = "special";
160+ if (pa64)
161+ {
162+ *bits = 6;
163+ }
164+ else
165+ {
166+ *bits = 5;
167+ }
168+ *type = DW_ATE_unsigned;
169+ }
170+ else
171+ {
172+ *setname = "FPU";
173+ *type = DW_ATE_float;
174+ if (pa64)
175+ {
176+ *bits = 64;
177+ }
178+ else
179+ {
180+ *bits = 32;
181+ }
182+ }
183+
184+ if (regno < 33) {
185+ switch (regno)
186+ {
187+ case 0 ... 9:
188+ name[0] = 'r';
189+ name[1] = regno + '0';
190+ namelen = 2;
191+ break;
192+ case 10 ... 31:
193+ name[0] = 'r';
194+ name[1] = regno / 10 + '0';
195+ name[2] = regno % 10 + '0';
196+ namelen = 3;
197+ break;
198+ case 32:
199+ *prefix = NULL;
200+ name[0] = 'S';
201+ name[1] = 'A';
202+ name[2] = 'R';
203+ namelen = 3;
204+ break;
205+ }
206+ }
207+ else {
208+ if (pa64 && ((regno - 72) % 2)) {
209+ *setname = NULL;
210+ return 0;
211+ }
212+
213+ switch (regno)
214+ {
215+ case 72 + 0 ... 72 + 11:
216+ name[0] = 'f';
217+ name[1] = 'r';
218+ name[2] = (regno + 8 - 72) / 2 + '0';
219+ namelen = 3;
220+ if ((regno + 8 - 72) % 2) {
221+ name[3] = 'R';
222+ namelen++;
223+ }
224+ break;
225+ case 72 + 12 ... 72 + 55:
226+ name[0] = 'f';
227+ name[1] = 'r';
228+ name[2] = (regno + 8 - 72) / 2 / 10 + '0';
229+ name[3] = (regno + 8 - 72) / 2 % 10 + '0';
230+ namelen = 4;
231+ if ((regno + 8 - 72) % 2) {
232+ name[4] = 'R';
233+ namelen++;
234+ }
235+ break;
236+ default:
237+ *setname = NULL;
238+ return 0;
239+ }
240+ }
241+ name[namelen++] = '\0';
242+ return namelen;
243+}
244Index: elfutils-0.158/backends/parisc_reloc.def
245===================================================================
246--- /dev/null 1970-01-01 00:00:00.000000000 +0000
247+++ elfutils-0.158/backends/parisc_reloc.def 2014-04-21 11:12:12.228150280 +0000
248@@ -0,0 +1,128 @@
249+/* List the relocation types for PA-RISC. -*- C -*-
250+ Copyright (C) 2005 Red Hat, Inc.
251+ This file is part of Red Hat elfutils.
252+
253+ Red Hat elfutils is free software; you can redistribute it and/or modify
254+ it under the terms of the GNU General Public License as published by the
255+ Free Software Foundation; version 2 of the License.
256+
257+ Red Hat elfutils is distributed in the hope that it will be useful, but
258+ WITHOUT ANY WARRANTY; without even the implied warranty of
259+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
260+ General Public License for more details.
261+
262+ You should have received a copy of the GNU General Public License along
263+ with Red Hat elfutils; if not, write to the Free Software Foundation,
264+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
265+
266+ Red Hat elfutils is an included package of the Open Invention Network.
267+ An included package of the Open Invention Network is a package for which
268+ Open Invention Network licensees cross-license their patents. No patent
269+ license is granted, either expressly or impliedly, by designation as an
270+ included package. Should you wish to participate in the Open Invention
271+ Network licensing program, please visit www.openinventionnetwork.com
272+ <http://www.openinventionnetwork.com>. */
273+
274+/* NAME, REL|EXEC|DYN */
275+
276+RELOC_TYPE (NONE, EXEC|DYN)
277+RELOC_TYPE (DIR32, REL|EXEC|DYN)
278+RELOC_TYPE (DIR21L, REL|EXEC|DYN)
279+RELOC_TYPE (DIR17R, REL)
280+RELOC_TYPE (DIR17F, REL)
281+RELOC_TYPE (DIR14R, REL|DYN)
282+RELOC_TYPE (PCREL32, REL)
283+RELOC_TYPE (PCREL21L, REL)
284+RELOC_TYPE (PCREL17R, REL)
285+RELOC_TYPE (PCREL17F, REL)
286+RELOC_TYPE (PCREL14R, REL|EXEC)
287+RELOC_TYPE (DPREL21L, REL)
288+RELOC_TYPE (DPREL14WR, REL)
289+RELOC_TYPE (DPREL14DR, REL)
290+RELOC_TYPE (DPREL14R, REL)
291+RELOC_TYPE (GPREL21L, 0)
292+RELOC_TYPE (GPREL14R, 0)
293+RELOC_TYPE (LTOFF21L, REL)
294+RELOC_TYPE (LTOFF14R, REL)
295+RELOC_TYPE (DLTIND14F, 0)
296+RELOC_TYPE (SETBASE, 0)
297+RELOC_TYPE (SECREL32, REL)
298+RELOC_TYPE (BASEREL21L, 0)
299+RELOC_TYPE (BASEREL17R, 0)
300+RELOC_TYPE (BASEREL14R, 0)
301+RELOC_TYPE (SEGBASE, 0)
302+RELOC_TYPE (SEGREL32, REL)
303+RELOC_TYPE (PLTOFF21L, 0)
304+RELOC_TYPE (PLTOFF14R, 0)
305+RELOC_TYPE (PLTOFF14F, 0)
306+RELOC_TYPE (LTOFF_FPTR32, 0)
307+RELOC_TYPE (LTOFF_FPTR21L, 0)
308+RELOC_TYPE (LTOFF_FPTR14R, 0)
309+RELOC_TYPE (FPTR64, 0)
310+RELOC_TYPE (PLABEL32, REL|DYN)
311+RELOC_TYPE (PCREL64, 0)
312+RELOC_TYPE (PCREL22C, 0)
313+RELOC_TYPE (PCREL22F, 0)
314+RELOC_TYPE (PCREL14WR, 0)
315+RELOC_TYPE (PCREL14DR, 0)
316+RELOC_TYPE (PCREL16F, 0)
317+RELOC_TYPE (PCREL16WF, 0)
318+RELOC_TYPE (PCREL16DF, 0)
319+RELOC_TYPE (DIR64, REL|DYN)
320+RELOC_TYPE (DIR14WR, REL)
321+RELOC_TYPE (DIR14DR, REL)
322+RELOC_TYPE (DIR16F, REL)
323+RELOC_TYPE (DIR16WF, REL)
324+RELOC_TYPE (DIR16DF, REL)
325+RELOC_TYPE (GPREL64, 0)
326+RELOC_TYPE (GPREL14WR, 0)
327+RELOC_TYPE (GPREL14DR, 0)
328+RELOC_TYPE (GPREL16F, 0)
329+RELOC_TYPE (GPREL16WF, 0)
330+RELOC_TYPE (GPREL16DF, 0)
331+RELOC_TYPE (LTOFF64, 0)
332+RELOC_TYPE (LTOFF14WR, 0)
333+RELOC_TYPE (LTOFF14DR, 0)
334+RELOC_TYPE (LTOFF16F, 0)
335+RELOC_TYPE (LTOFF16WF, 0)
336+RELOC_TYPE (LTOFF16DF, 0)
337+RELOC_TYPE (SECREL64, 0)
338+RELOC_TYPE (BASEREL14WR, 0)
339+RELOC_TYPE (BASEREL14DR, 0)
340+RELOC_TYPE (SEGREL64, 0)
341+RELOC_TYPE (PLTOFF14WR, 0)
342+RELOC_TYPE (PLTOFF14DR, 0)
343+RELOC_TYPE (PLTOFF16F, 0)
344+RELOC_TYPE (PLTOFF16WF, 0)
345+RELOC_TYPE (PLTOFF16DF, 0)
346+RELOC_TYPE (LTOFF_FPTR64, 0)
347+RELOC_TYPE (LTOFF_FPTR14WR, 0)
348+RELOC_TYPE (LTOFF_FPTR14DR, 0)
349+RELOC_TYPE (LTOFF_FPTR16F, 0)
350+RELOC_TYPE (LTOFF_FPTR16WF, 0)
351+RELOC_TYPE (LTOFF_FPTR16DF, 0)
352+RELOC_TYPE (COPY, EXEC)
353+RELOC_TYPE (IPLT, EXEC|DYN)
354+RELOC_TYPE (EPLT, 0)
355+RELOC_TYPE (TPREL32, DYN)
356+RELOC_TYPE (TPREL21L, 0)
357+RELOC_TYPE (TPREL14R, 0)
358+RELOC_TYPE (LTOFF_TP21L, 0)
359+RELOC_TYPE (LTOFF_TP14R, 0)
360+RELOC_TYPE (LTOFF_TP14F, 0)
361+RELOC_TYPE (TPREL64, 0)
362+RELOC_TYPE (TPREL14WR, 0)
363+RELOC_TYPE (TPREL14DR, 0)
364+RELOC_TYPE (TPREL16F, 0)
365+RELOC_TYPE (TPREL16WF, 0)
366+RELOC_TYPE (TPREL16DF, 0)
367+RELOC_TYPE (LTOFF_TP64, 0)
368+RELOC_TYPE (LTOFF_TP14WR, 0)
369+RELOC_TYPE (LTOFF_TP14DR, 0)
370+RELOC_TYPE (LTOFF_TP16F, 0)
371+RELOC_TYPE (LTOFF_TP16WF, 0)
372+RELOC_TYPE (LTOFF_TP16DF, 0)
373+RELOC_TYPE (TLS_DTPMOD32, DYN)
374+RELOC_TYPE (TLS_DTPMOD64, DYN)
375+
376+#define NO_RELATIVE_RELOC 1
377Index: elfutils-0.158/backends/parisc_retval.c
378===================================================================
379--- /dev/null 1970-01-01 00:00:00.000000000 +0000
380+++ elfutils-0.158/backends/parisc_retval.c 2014-04-21 11:12:12.228150280 +0000
381@@ -0,0 +1,213 @@
382+/* Function return value location for Linux/PA-RISC ABI.
383+ Copyright (C) 2005 Red Hat, Inc.
384+ This file is part of Red Hat elfutils.
385+
386+ Red Hat elfutils is free software; you can redistribute it and/or modify
387+ it under the terms of the GNU General Public License as published by the
388+ Free Software Foundation; version 2 of the License.
389+
390+ Red Hat elfutils is distributed in the hope that it will be useful, but
391+ WITHOUT ANY WARRANTY; without even the implied warranty of
392+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
393+ General Public License for more details.
394+
395+ You should have received a copy of the GNU General Public License along
396+ with Red Hat elfutils; if not, write to the Free Software Foundation,
397+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
398+
399+ Red Hat elfutils is an included package of the Open Invention Network.
400+ An included package of the Open Invention Network is a package for which
401+ Open Invention Network licensees cross-license their patents. No patent
402+ license is granted, either expressly or impliedly, by designation as an
403+ included package. Should you wish to participate in the Open Invention
404+ Network licensing program, please visit www.openinventionnetwork.com
405+ <http://www.openinventionnetwork.com>. */
406+
407+#ifdef HAVE_CONFIG_H
408+# include <config.h>
409+#endif
410+
411+#include <assert.h>
412+#include <dwarf.h>
413+
414+#define BACKEND parisc_
415+#include "libebl_CPU.h"
416+#include "libebl_parisc.h"
417+
418+/* %r28, or pair %r28, %r29. */
419+static const Dwarf_Op loc_intreg32[] =
420+ {
421+ { .atom = DW_OP_reg28 }, { .atom = DW_OP_piece, .number = 4 },
422+ { .atom = DW_OP_reg29 }, { .atom = DW_OP_piece, .number = 4 },
423+ };
424+
425+static const Dwarf_Op loc_intreg[] =
426+ {
427+ { .atom = DW_OP_reg28 }, { .atom = DW_OP_piece, .number = 8 },
428+ { .atom = DW_OP_reg29 }, { .atom = DW_OP_piece, .number = 8 },
429+ };
430+#define nloc_intreg 1
431+#define nloc_intregpair 4
432+
433+/* %fr4L, or pair %fr4L, %fr4R on pa-32 */
434+static const Dwarf_Op loc_fpreg32[] =
435+ {
436+ { .atom = DW_OP_regx, .number = 72 }, { .atom = DW_OP_piece, .number = 4 },
437+ { .atom = DW_OP_regx, .number = 73 }, { .atom = DW_OP_piece, .number = 4 },
438+ };
439+#define nloc_fpreg32 2
440+#define nloc_fpregpair32 4
441+
442+/* $fr4 */
443+static const Dwarf_Op loc_fpreg[] =
444+ {
445+ { .atom = DW_OP_regx, .number = 72 },
446+ };
447+#define nloc_fpreg 1
448+
449+#if 0
450+/* The return value is a structure and is actually stored in stack space
451+ passed in a hidden argument by the caller. Address of the location is stored
452+ in %r28 before function call, but it may be changed by function. */
453+static const Dwarf_Op loc_aggregate[] =
454+ {
455+ { .atom = DW_OP_breg28 },
456+ };
457+#define nloc_aggregate 1
458+#endif
459+
460+static int
461+parisc_return_value_location_ (Dwarf_Die *functypedie, const Dwarf_Op **locp, int pa64)
462+{
463+ Dwarf_Word regsize = pa64 ? 8 : 4;
464+
465+ /* Start with the function's type, and get the DW_AT_type attribute,
466+ which is the type of the return value. */
467+
468+ Dwarf_Attribute attr_mem;
469+ Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type, &attr_mem);
470+ if (attr == NULL)
471+ /* The function has no return value, like a `void' function in C. */
472+ return 0;
473+
474+ Dwarf_Die die_mem;
475+ Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
476+ int tag = dwarf_tag (typedie);
477+
478+ /* Follow typedefs and qualifiers to get to the actual type. */
479+ while (tag == DW_TAG_typedef
480+ || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
481+ || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
482+ {
483+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
484+ typedie = dwarf_formref_die (attr, &die_mem);
485+ tag = dwarf_tag (typedie);
486+ }
487+
488+ switch (tag)
489+ {
490+ case -1:
491+ return -1;
492+
493+ case DW_TAG_subrange_type:
494+ if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
495+ {
496+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
497+ typedie = dwarf_formref_die (attr, &die_mem);
498+ tag = dwarf_tag (typedie);
499+ }
500+ /* Fall through. */
501+
502+ case DW_TAG_base_type:
503+ case DW_TAG_enumeration_type:
504+ case DW_TAG_pointer_type:
505+ case DW_TAG_ptr_to_member_type:
506+ {
507+ Dwarf_Word size;
508+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
509+ &attr_mem), &size) != 0)
510+ {
511+ if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
512+ size = 4;
513+ else
514+ return -1;
515+ }
516+ if (tag == DW_TAG_base_type)
517+ {
518+ Dwarf_Word encoding;
519+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
520+ &attr_mem), &encoding) != 0)
521+ return -1;
522+
523+ if (encoding == DW_ATE_float)
524+ {
525+ if (pa64) {
526+ *locp = loc_fpreg;
527+ if (size <= 8)
528+ return nloc_fpreg;
529+ }
530+ else {
531+ *locp = loc_fpreg32;
532+ if (size <= 4)
533+ return nloc_fpreg32;
534+ else if (size <= 8)
535+ return nloc_fpregpair32;
536+ }
537+ goto aggregate;
538+ }
539+ }
540+ if (pa64)
541+ *locp = loc_intreg;
542+ else
543+ *locp = loc_intreg32;
544+ if (size <= regsize)
545+ return nloc_intreg;
546+ if (size <= 2 * regsize)
547+ return nloc_intregpair;
548+
549+ /* Else fall through. */
550+ }
551+
552+ case DW_TAG_structure_type:
553+ case DW_TAG_class_type:
554+ case DW_TAG_union_type:
555+ case DW_TAG_array_type:
556+ aggregate: {
557+ Dwarf_Word size;
558+ if (dwarf_aggregate_size (typedie, &size) != 0)
559+ return -1;
560+ if (pa64)
561+ *locp = loc_intreg;
562+ else
563+ *locp = loc_intreg32;
564+ if (size <= regsize)
565+ return nloc_intreg;
566+ if (size <= 2 * regsize)
567+ return nloc_intregpair;
568+#if 0
569+ /* there should be some way to know this location... But I do not see it. */
570+ *locp = loc_aggregate;
571+ return nloc_aggregate;
572+#endif
573+ /* fall through. */
574+ }
575+ }
576+
577+ /* XXX We don't have a good way to return specific errors from ebl calls.
578+ This value means we do not understand the type, but it is well-formed
579+ DWARF and might be valid. */
580+ return -2;
581+}
582+
583+int
584+parisc_return_value_location_32 (Dwarf_Die *functypedie, const Dwarf_Op **locp)
585+{
586+ return parisc_return_value_location_ (functypedie, locp, 0);
587+}
588+
589+int
590+parisc_return_value_location_64 (Dwarf_Die *functypedie, const Dwarf_Op **locp)
591+{
592+ return parisc_return_value_location_ (functypedie, locp, 1);
593+}
594+
595Index: elfutils-0.158/backends/parisc_symbol.c
596===================================================================
597--- /dev/null 1970-01-01 00:00:00.000000000 +0000
598+++ elfutils-0.158/backends/parisc_symbol.c 2014-04-21 11:12:12.228150280 +0000
599@@ -0,0 +1,112 @@
600+/* PA-RISC specific symbolic name handling.
601+ Copyright (C) 2002, 2005 Red Hat, Inc.
602+ This file is part of Red Hat elfutils.
603+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
604+
605+ Red Hat elfutils is free software; you can redistribute it and/or modify
606+ it under the terms of the GNU General Public License as published by the
607+ Free Software Foundation; version 2 of the License.
608+
609+ Red Hat elfutils is distributed in the hope that it will be useful, but
610+ WITHOUT ANY WARRANTY; without even the implied warranty of
611+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
612+ General Public License for more details.
613+
614+ You should have received a copy of the GNU General Public License along
615+ with Red Hat elfutils; if not, write to the Free Software Foundation,
616+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
617+
618+ Red Hat elfutils is an included package of the Open Invention Network.
619+ An included package of the Open Invention Network is a package for which
620+ Open Invention Network licensees cross-license their patents. No patent
621+ license is granted, either expressly or impliedly, by designation as an
622+ included package. Should you wish to participate in the Open Invention
623+ Network licensing program, please visit www.openinventionnetwork.com
624+ <http://www.openinventionnetwork.com>. */
625+
626+#ifdef HAVE_CONFIG_H
627+# include <config.h>
628+#endif
629+
630+#include <elf.h>
631+#include <stddef.h>
632+
633+#define BACKEND parisc_
634+#include "libebl_CPU.h"
635+
636+const char *
637+parisc_segment_type_name (int segment, char *buf __attribute__ ((unused)),
638+ size_t len __attribute__ ((unused)))
639+{
640+ switch (segment)
641+ {
642+ case PT_PARISC_ARCHEXT:
643+ return "PARISC_ARCHEXT";
644+ case PT_PARISC_UNWIND:
645+ return "PARISC_UNWIND";
646+ default:
647+ break;
648+ }
649+ return NULL;
650+}
651+
652+/* Return symbolic representation of symbol type. */
653+const char *
654+parisc_symbol_type_name(int symbol, char *buf __attribute__ ((unused)),
655+ size_t len __attribute__ ((unused)))
656+{
657+ if (symbol == STT_PARISC_MILLICODE)
658+ return "PARISC_MILLI";
659+ return NULL;
660+}
661+
662+/* Return symbolic representation of section type. */
663+const char *
664+parisc_section_type_name (int type,
665+ char *buf __attribute__ ((unused)),
666+ size_t len __attribute__ ((unused)))
667+{
668+ switch (type)
669+ {
670+ case SHT_PARISC_EXT:
671+ return "PARISC_EXT";
672+ case SHT_PARISC_UNWIND:
673+ return "PARISC_UNWIND";
674+ case SHT_PARISC_DOC:
675+ return "PARISC_DOC";
676+ }
677+
678+ return NULL;
679+}
680+
681+/* Check whether machine flags are valid. */
682+bool
683+parisc_machine_flag_check (GElf_Word flags)
684+{
685+ if (flags &~ (EF_PARISC_TRAPNIL | EF_PARISC_EXT | EF_PARISC_LSB |
686+ EF_PARISC_WIDE | EF_PARISC_NO_KABP |
687+ EF_PARISC_LAZYSWAP | EF_PARISC_ARCH))
688+ return 0;
689+
690+ GElf_Word arch = flags & EF_PARISC_ARCH;
691+
692+ return ((arch == EFA_PARISC_1_0) || (arch == EFA_PARISC_1_1) ||
693+ (arch == EFA_PARISC_2_0));
694+}
695+
696+/* Check for the simple reloc types. */
697+Elf_Type
698+parisc_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
699+{
700+ switch (type)
701+ {
702+ case R_PARISC_DIR64:
703+ case R_PARISC_SECREL64:
704+ return ELF_T_XWORD;
705+ case R_PARISC_DIR32:
706+ case R_PARISC_SECREL32:
707+ return ELF_T_WORD;
708+ default:
709+ return ELF_T_NUM;
710+ }
711+}
712Index: elfutils-0.158/backends/libebl_parisc.h
713===================================================================
714--- /dev/null 1970-01-01 00:00:00.000000000 +0000
715+++ elfutils-0.158/backends/libebl_parisc.h 2014-04-21 11:12:12.228150280 +0000
716@@ -0,0 +1,9 @@
717+#ifndef _LIBEBL_HPPA_H
718+#define _LIBEBL_HPPA_H 1
719+
720+#include <libdw.h>
721+
722+extern int parisc_return_value_location_32(Dwarf_Die *, const Dwarf_Op **locp);
723+extern int parisc_return_value_location_64(Dwarf_Die *, const Dwarf_Op **locp);
724+
725+#endif
726Index: elfutils-0.158/backends/Makefile.am
727===================================================================
728--- elfutils-0.158.orig/backends/Makefile.am 2014-04-21 11:12:12.252149737 +0000
729+++ elfutils-0.158/backends/Makefile.am 2014-04-21 11:13:11.910801105 +0000
730@@ -33,11 +33,12 @@
731
732
733 modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \
734- tilegx
735+ tilegx parisc
736 libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \
737 libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \
738 libebl_aarch64_pic.a libebl_sparc_pic.a libebl_ppc_pic.a \
739- libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a
740+ libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a \
741+ libebl_parisc_pic.a
742 noinst_LIBRARIES = $(libebl_pic)
743 noinst_DATA = $(libebl_pic:_pic.a=.so)
744
745@@ -116,6 +117,9 @@
746 libebl_tilegx_pic_a_SOURCES = $(tilegx_SRCS)
747 am_libebl_tilegx_pic_a_OBJECTS = $(tilegx_SRCS:.c=.os)
748
749+parisc_SRCS = parisc_init.c parisc_symbol.c parisc_regs.c parisc_retval.c
750+libebl_parisc_pic_a_SOURCES = $(parisc_SRCS)
751+am_libebl_parisc_pic_a_OBJECTS = $(parisc_SRCS:.c=.os)
752
753 libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw)
754 @rm -f $(@:.so=.map)
755Index: elfutils-0.158/libelf/elf.h
756===================================================================
757--- elfutils-0.158.orig/libelf/elf.h 2014-04-21 11:12:12.252149737 +0000
758+++ elfutils-0.158/libelf/elf.h 2014-04-21 11:12:12.228150280 +0000
759@@ -1814,16 +1814,24 @@
760 #define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */
761 #define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */
762 #define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */
763+#define R_PARISC_DPREL14WR 19
764+#define R_PARISC_DPREL14DR 20
765 #define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */
766 #define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */
767 #define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */
768 #define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */
769 #define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */
770+#define R_PARISC_DLTIND14F 39
771+#define R_PARISC_SETBASE 40
772 #define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */
773+#define R_PARISC_BASEREL21L 42
774+#define R_PARISC_BASEREL17R 43
775+#define R_PARISC_BASEREL14R 46
776 #define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */
777 #define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */
778 #define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */
779 #define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */
780+#define R_PARISC_PLTOFF14F 55
781 #define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */
782 #define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */
783 #define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */
784@@ -1832,6 +1840,7 @@
785 #define R_PARISC_PLABEL21L 66 /* Left 21 bits of fdesc address. */
786 #define R_PARISC_PLABEL14R 70 /* Right 14 bits of fdesc address. */
787 #define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */
788+#define R_PARISC_PCREL22C 73
789 #define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */
790 #define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */
791 #define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */
792@@ -1857,6 +1866,8 @@
793 #define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */
794 #define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */
795 #define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */
796+#define R_PARISC_BASEREL14WR 107
797+#define R_PARISC_BASEREL14DR 108
798 #define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */
799 #define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */
800 #define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.158/m4-biarch.m4-tweak-AC_RUN_IFELSE-for-cross-compiling.patch b/meta/recipes-devtools/elfutils/elfutils-0.158/m4-biarch.m4-tweak-AC_RUN_IFELSE-for-cross-compiling.patch
deleted file mode 100644
index 1dbd52d557..0000000000
--- a/meta/recipes-devtools/elfutils/elfutils-0.158/m4-biarch.m4-tweak-AC_RUN_IFELSE-for-cross-compiling.patch
+++ /dev/null
@@ -1,34 +0,0 @@
1m4/biarch.m4: tweak AC_RUN_IFELSE for cross-compiling
2
3Macro: AC_RUN_IFELSE (input,
4 [action-if-true],
5 [action-if-false],
6 [action-if-cross-compiling])
7
8Add the missing [action-if-cross-compiling] part to support
9cross-compiling.
10
11Upstream-Status: inappropriate [oe specific]
12
13Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
14---
15 m4/biarch.m4 | 4 +++-
16 1 file changed, 3 insertions(+), 1 deletion(-)
17
18diff --git a/m4/biarch.m4 b/m4/biarch.m4
19--- a/m4/biarch.m4
20+++ b/m4/biarch.m4
21@@ -40,7 +40,9 @@ AC_CACHE_CHECK([whether $biarch_CC makes executables we can run],
22 save_CC="$CC"
23 CC="$biarch_CC"
24 AC_RUN_IFELSE([AC_LANG_PROGRAM([], [])],
25- utrace_cv_cc_biarch=yes, utrace_cv_cc_biarch=no)
26+ utrace_cv_cc_biarch=yes,
27+ utrace_cv_cc_biarch=no,
28+ utrace_cv_cc_biarch=yes)
29 CC="$save_CC"])], [utrace_cv_cc_biarch=no])
30 AS_IF([test $utrace_cv_cc_biarch != yes], [dnl
31 AC_MSG_WARN([not running biarch tests, $biarch_CC does not work])])])
32--
331.8.1.2
34
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.158/m68k_backend.diff b/meta/recipes-devtools/elfutils/elfutils-0.158/m68k_backend.diff
deleted file mode 100644
index 48bffdad0c..0000000000
--- a/meta/recipes-devtools/elfutils/elfutils-0.158/m68k_backend.diff
+++ /dev/null
@@ -1,493 +0,0 @@
1From: Kurt Roeckx <kurt@roeckx.be>
2From: Thorsten Glaser <tg@mirbsd.de>
3Subject: m68k support
4
5Written by Kurt Roeckx, except for the retval support which was written
6by Thorsten Glaser
7
8
9Index: elfutils-0.158/backends/m68k_init.c
10===================================================================
11--- /dev/null 1970-01-01 00:00:00.000000000 +0000
12+++ elfutils-0.158/backends/m68k_init.c 2014-04-21 11:14:23.813175704 +0000
13@@ -0,0 +1,50 @@
14+/* Initialization of m68k specific backend library.
15+ Copyright (C) 2007 Kurt Roeckx <kurt@roeckx.be>
16+
17+ This software is free software; you can redistribute it and/or modify
18+ it under the terms of the GNU General Public License as published by the
19+ Free Software Foundation; version 2 of the License.
20+
21+ This softare is distributed in the hope that it will be useful, but
22+ WITHOUT ANY WARRANTY; without even the implied warranty of
23+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24+ General Public License for more details.
25+
26+ You should have received a copy of the GNU General Public License along
27+ with this software; if not, write to the Free Software Foundation,
28+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
29+
30+*/
31+
32+#ifdef HAVE_CONFIG_H
33+# include <config.h>
34+#endif
35+
36+#define BACKEND m68k_
37+#define RELOC_PREFIX R_68K_
38+#include "libebl_CPU.h"
39+
40+/* This defines the common reloc hooks based on m68k_reloc.def. */
41+#include "common-reloc.c"
42+
43+
44+const char *
45+m68k_init (elf, machine, eh, ehlen)
46+ Elf *elf __attribute__ ((unused));
47+ GElf_Half machine __attribute__ ((unused));
48+ Ebl *eh;
49+ size_t ehlen;
50+{
51+ /* Check whether the Elf_BH object has a sufficent size. */
52+ if (ehlen < sizeof (Ebl))
53+ return NULL;
54+
55+ /* We handle it. */
56+ eh->name = "m68k";
57+ m68k_init_reloc (eh);
58+ HOOK (eh, reloc_simple_type);
59+ HOOK (eh, return_value_location);
60+ HOOK (eh, register_info);
61+
62+ return MODVERSION;
63+}
64Index: elfutils-0.158/backends/m68k_regs.c
65===================================================================
66--- /dev/null 1970-01-01 00:00:00.000000000 +0000
67+++ elfutils-0.158/backends/m68k_regs.c 2014-04-21 11:14:23.813175704 +0000
68@@ -0,0 +1,106 @@
69+/* Register names and numbers for m68k DWARF.
70+ Copyright (C) 2007 Kurt Roeckx <kurt@roeckx.be>
71+
72+ This software is free software; you can redistribute it and/or modify
73+ it under the terms of the GNU General Public License as published by the
74+ Free Software Foundation; version 2 of the License.
75+
76+ This software is distributed in the hope that it will be useful, but
77+ WITHOUT ANY WARRANTY; without even the implied warranty of
78+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
79+ General Public License for more details.
80+
81+ You should have received a copy of the GNU General Public License along
82+ with this software; if not, write to the Free Software Foundation,
83+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
84+
85+ */
86+
87+#ifdef HAVE_CONFIG_H
88+# include <config.h>
89+#endif
90+
91+#include <string.h>
92+#include <dwarf.h>
93+
94+#define BACKEND m68k_
95+#include "libebl_CPU.h"
96+
97+ssize_t
98+m68k_register_info (Ebl *ebl __attribute__ ((unused)),
99+ int regno, char *name, size_t namelen,
100+ const char **prefix, const char **setname,
101+ int *bits, int *type)
102+{
103+ if (name == NULL)
104+ return 25;
105+
106+ if (regno < 0 || regno > 24 || namelen < 5)
107+ return -1;
108+
109+ *prefix = "%";
110+ *bits = 32;
111+ *type = (regno < 8 ? DW_ATE_signed
112+ : regno < 16 ? DW_ATE_address : DW_ATE_float);
113+
114+ if (regno < 8)
115+ {
116+ *setname = "integer";
117+ }
118+ else if (regno < 16)
119+ {
120+ *setname = "address";
121+ }
122+ else if (regno < 24)
123+ {
124+ *setname = "FPU";
125+ }
126+ else
127+ {
128+ *setname = "address";
129+ *type = DW_ATE_address;
130+ }
131+
132+ switch (regno)
133+ {
134+ case 0 ... 7:
135+ name[0] = 'd';
136+ name[1] = regno + '0';
137+ namelen = 2;
138+ break;
139+
140+ case 8 ... 13:
141+ name[0] = 'a';
142+ name[1] = regno - 8 + '0';
143+ namelen = 2;
144+ break;
145+
146+ case 14:
147+ name[0] = 'f';
148+ name[1] = 'p';
149+ namelen = 2;
150+ break;
151+
152+ case 15:
153+ name[0] = 's';
154+ name[1] = 'p';
155+ namelen = 2;
156+ break;
157+
158+ case 16 ... 23:
159+ name[0] = 'f';
160+ name[1] = 'p';
161+ name[2] = regno - 16 + '0';
162+ namelen = 3;
163+ break;
164+
165+ case 24:
166+ name[0] = 'p';
167+ name[1] = 'c';
168+ namelen = 2;
169+ }
170+
171+ name[namelen++] = '\0';
172+ return namelen;
173+}
174+
175Index: elfutils-0.158/backends/m68k_reloc.def
176===================================================================
177--- /dev/null 1970-01-01 00:00:00.000000000 +0000
178+++ elfutils-0.158/backends/m68k_reloc.def 2014-04-21 11:14:23.813175704 +0000
179@@ -0,0 +1,45 @@
180+/* List the relocation types for m68k. -*- C -*-
181+ Copyright (C) 2007 Kurt Roeckx <kurt@roeckx.be>
182+
183+ This software is free software; you can redistribute it and/or modify
184+ it under the terms of the GNU General Public License as published by the
185+ Free Software Foundation; version 2 of the License.
186+
187+ This software is distributed in the hope that it will be useful, but
188+ WITHOUT ANY WARRANTY; without even the implied warranty of
189+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
190+ General Public License for more details.
191+
192+ You should have received a copy of the GNU General Public License along
193+ with this software; if not, write to the Free Software Foundation,
194+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
195+*/
196+
197+/* NAME, REL|EXEC|DYN */
198+
199+RELOC_TYPE (NONE, 0)
200+RELOC_TYPE (32, REL|EXEC|DYN)
201+RELOC_TYPE (16, REL)
202+RELOC_TYPE (8, REL)
203+RELOC_TYPE (PC32, REL|EXEC|DYN)
204+RELOC_TYPE (PC16, REL)
205+RELOC_TYPE (PC8, REL)
206+RELOC_TYPE (GOT32, REL)
207+RELOC_TYPE (GOT16, REL)
208+RELOC_TYPE (GOT8, REL)
209+RELOC_TYPE (GOT32O, REL)
210+RELOC_TYPE (GOT16O, REL)
211+RELOC_TYPE (GOT8O, REL)
212+RELOC_TYPE (PLT32, REL)
213+RELOC_TYPE (PLT16, REL)
214+RELOC_TYPE (PLT8, REL)
215+RELOC_TYPE (PLT32O, REL)
216+RELOC_TYPE (PLT16O, REL)
217+RELOC_TYPE (PLT8O, REL)
218+RELOC_TYPE (COPY, EXEC)
219+RELOC_TYPE (GLOB_DAT, EXEC|DYN)
220+RELOC_TYPE (JMP_SLOT, EXEC|DYN)
221+RELOC_TYPE (RELATIVE, EXEC|DYN)
222+RELOC_TYPE (GNU_VTINHERIT, REL)
223+RELOC_TYPE (GNU_VTENTRY, REL)
224+
225Index: elfutils-0.158/libelf/elf.h
226===================================================================
227--- elfutils-0.158.orig/libelf/elf.h 2014-04-21 11:14:23.813175704 +0000
228+++ elfutils-0.158/libelf/elf.h 2014-04-21 11:14:23.813175704 +0000
229@@ -1157,6 +1157,9 @@
230 #define R_68K_GLOB_DAT 20 /* Create GOT entry */
231 #define R_68K_JMP_SLOT 21 /* Create PLT entry */
232 #define R_68K_RELATIVE 22 /* Adjust by program base */
233+/* The next 2 are GNU extensions to enable C++ vtable garbage collection. */
234+#define R_68K_GNU_VTINHERIT 23
235+#define R_68K_GNU_VTENTRY 24
236 #define R_68K_TLS_GD32 25 /* 32 bit GOT offset for GD */
237 #define R_68K_TLS_GD16 26 /* 16 bit GOT offset for GD */
238 #define R_68K_TLS_GD8 27 /* 8 bit GOT offset for GD */
239Index: elfutils-0.158/backends/Makefile.am
240===================================================================
241--- elfutils-0.158.orig/backends/Makefile.am 2014-04-21 11:14:23.813175704 +0000
242+++ elfutils-0.158/backends/Makefile.am 2014-04-21 11:14:48.344621167 +0000
243@@ -33,12 +33,12 @@
244
245
246 modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \
247- tilegx parisc mips
248+ tilegx parisc mips m68k
249 libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \
250 libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \
251 libebl_aarch64_pic.a libebl_sparc_pic.a libebl_ppc_pic.a \
252 libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a \
253- libebl_parisc_pic.a libebl_mips_pic.a
254+ libebl_parisc_pic.a libebl_mips_pic.a libebl_m68k_pic.a
255 noinst_LIBRARIES = $(libebl_pic)
256 noinst_DATA = $(libebl_pic:_pic.a=.so)
257
258@@ -125,6 +125,10 @@
259 libebl_mips_pic_a_SOURCES = $(mips_SRCS)
260 am_libebl_mips_pic_a_OBJECTS = $(mips_SRCS:.c=.os)
261
262+m68k_SRCS = m68k_init.c m68k_symbol.c m68k_regs.c m68k_retval.c
263+libebl_m68k_pic_a_SOURCES = $(m68k_SRCS)
264+am_libebl_m68k_pic_a_OBJECTS = $(m68k_SRCS:.c=.os)
265+
266 libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw)
267 @rm -f $(@:.so=.map)
268 echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: *; };' \
269Index: elfutils-0.158/backends/m68k_symbol.c
270===================================================================
271--- /dev/null 1970-01-01 00:00:00.000000000 +0000
272+++ elfutils-0.158/backends/m68k_symbol.c 2014-04-21 11:14:23.813175704 +0000
273@@ -0,0 +1,43 @@
274+/* m68k specific symbolic name handling.
275+ Copyright (C) 2007 Kurt Roeckx <kurt@roeckx.be>
276+
277+ This software is free software; you can redistribute it and/or modify
278+ it under the terms of the GNU General Public License as published by the
279+ Free Software Foundation; version 2 of the License.
280+
281+ This software distributed in the hope that it will be useful, but
282+ WITHOUT ANY WARRANTY; without even the implied warranty of
283+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
284+ General Public License for more details.
285+
286+ You should have received a copy of the GNU General Public License along
287+ with this software; if not, write to the Free Software Foundation,
288+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
289+*/
290+
291+#ifdef HAVE_CONFIG_H
292+# include <config.h>
293+#endif
294+
295+#include <elf.h>
296+#include <stddef.h>
297+
298+#define BACKEND m68k_
299+#include "libebl_CPU.h"
300+
301+/* Check for the simple reloc types. */
302+Elf_Type
303+m68k_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
304+{
305+ switch (type)
306+ {
307+ case R_68K_32:
308+ return ELF_T_SWORD;
309+ case R_68K_16:
310+ return ELF_T_HALF;
311+ case R_68K_8:
312+ return ELF_T_BYTE;
313+ default:
314+ return ELF_T_NUM;
315+ }
316+}
317Index: elfutils-0.158/backends/m68k_retval.c
318===================================================================
319--- /dev/null 1970-01-01 00:00:00.000000000 +0000
320+++ elfutils-0.158/backends/m68k_retval.c 2014-04-21 11:14:23.813175704 +0000
321@@ -0,0 +1,172 @@
322+/* Function return value location for Linux/m68k ABI.
323+ Copyright (C) 2005-2010 Red Hat, Inc.
324+ Copyright (c) 2011 Thorsten Glaser, Debian.
325+ This file is part of Red Hat elfutils.
326+
327+ Red Hat elfutils is free software; you can redistribute it and/or modify
328+ it under the terms of the GNU General Public License as published by the
329+ Free Software Foundation; version 2 of the License.
330+
331+ Red Hat elfutils is distributed in the hope that it will be useful, but
332+ WITHOUT ANY WARRANTY; without even the implied warranty of
333+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
334+ General Public License for more details.
335+
336+ You should have received a copy of the GNU General Public License along
337+ with Red Hat elfutils; if not, write to the Free Software Foundation,
338+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
339+
340+ Red Hat elfutils is an included package of the Open Invention Network.
341+ An included package of the Open Invention Network is a package for which
342+ Open Invention Network licensees cross-license their patents. No patent
343+ license is granted, either expressly or impliedly, by designation as an
344+ included package. Should you wish to participate in the Open Invention
345+ Network licensing program, please visit www.openinventionnetwork.com
346+ <http://www.openinventionnetwork.com>. */
347+
348+#ifdef HAVE_CONFIG_H
349+# include <config.h>
350+#endif
351+
352+#include <assert.h>
353+#include <dwarf.h>
354+
355+#define BACKEND m68k_
356+#include "libebl_CPU.h"
357+
358+
359+/* %d0, or pair %d0, %d1, or %a0 */
360+static const Dwarf_Op loc_intreg[] =
361+ {
362+ { .atom = DW_OP_reg0 }, { .atom = DW_OP_piece, .number = 4 },
363+ { .atom = DW_OP_reg1 }, { .atom = DW_OP_piece, .number = 4 },
364+ };
365+static const Dwarf_Op loc_ptrreg[] =
366+ {
367+ { .atom = DW_OP_reg8 },
368+ };
369+#define nloc_intreg 1
370+#define nloc_intregpair 4
371+#define nloc_ptrreg 1
372+
373+/* %f0 */
374+static const Dwarf_Op loc_fpreg[] =
375+ {
376+ { .atom = DW_OP_reg16 }
377+ };
378+#define nloc_fpreg 1
379+
380+/* Structures are a bit more complicated - small structures are returned
381+ in %d0 / %d1 (-freg-struct-return which is enabled by default), large
382+ structures use %a1 (in constrast to the SYSV psABI which says %a0) as
383+ reentrant storage space indicator. */
384+static const Dwarf_Op loc_aggregate[] =
385+ {
386+ { .atom = DW_OP_breg9, .number = 0 }
387+ };
388+#define nloc_aggregate 1
389+
390+int
391+m68k_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
392+{
393+ Dwarf_Word size;
394+
395+ /* Start with the function's type, and get the DW_AT_type attribute,
396+ which is the type of the return value. */
397+
398+ Dwarf_Attribute attr_mem;
399+ Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type,
400+ &attr_mem);
401+ if (attr == NULL)
402+ /* The function has no return value, like a `void' function in C. */
403+ return 0;
404+
405+ Dwarf_Die die_mem;
406+ Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
407+ int tag = dwarf_tag (typedie);
408+
409+ /* Follow typedefs and qualifiers to get to the actual type. */
410+ while (tag == DW_TAG_typedef
411+ || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
412+ || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
413+ {
414+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
415+ typedie = dwarf_formref_die (attr, &die_mem);
416+ tag = dwarf_tag (typedie);
417+ }
418+
419+ switch (tag)
420+ {
421+ case -1:
422+ return -1;
423+
424+ case DW_TAG_subrange_type:
425+ if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
426+ {
427+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
428+ typedie = dwarf_formref_die (attr, &die_mem);
429+ tag = dwarf_tag (typedie);
430+ }
431+ /* Fall through. */
432+
433+ case DW_TAG_base_type:
434+ case DW_TAG_enumeration_type:
435+ case DW_TAG_pointer_type:
436+ case DW_TAG_ptr_to_member_type:
437+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
438+ &attr_mem), &size) != 0)
439+ {
440+ if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
441+ size = 4;
442+ else
443+ return -1;
444+ }
445+ if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
446+ {
447+ *locp = loc_ptrreg;
448+ return nloc_ptrreg;
449+ }
450+ if (tag == DW_TAG_base_type)
451+ {
452+ Dwarf_Word encoding;
453+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
454+ &attr_mem),
455+ &encoding) != 0)
456+ return -1;
457+ if (encoding == DW_ATE_float)
458+ {
459+ /* XXX really 10? */
460+ if (size > 10)
461+ return -2;
462+ *locp = loc_fpreg;
463+ return nloc_fpreg;
464+ }
465+ }
466+ if (size <= 8)
467+ {
468+ intreg:
469+ /* XXX check endianness of dword pair, int64 vs aggregate */
470+ *locp = loc_intreg;
471+ return size <= 4 ? nloc_intreg : nloc_intregpair;
472+ }
473+
474+ aggregate:
475+ *locp = loc_aggregate;
476+ return nloc_aggregate;
477+
478+ case DW_TAG_structure_type:
479+ case DW_TAG_class_type:
480+ case DW_TAG_union_type:
481+ case DW_TAG_array_type:
482+ if (dwarf_aggregate_size (typedie, &size) == 0
483+ && size > 0 && size <= 8)
484+ /* not accurate for a struct whose only member is a float */
485+ goto intreg;
486+ goto aggregate;
487+ }
488+
489+ /* XXX We don't have a good way to return specific errors from ebl calls.
490+ This value means we do not understand the type, but it is well-formed
491+ DWARF and might be valid. */
492+ return -2;
493+}
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.158/mips_backend.diff b/meta/recipes-devtools/elfutils/elfutils-0.158/mips_backend.diff
deleted file mode 100644
index b188927a0b..0000000000
--- a/meta/recipes-devtools/elfutils/elfutils-0.158/mips_backend.diff
+++ /dev/null
@@ -1,712 +0,0 @@
1Index: elfutils-0.158/backends/mips_init.c
2===================================================================
3--- /dev/null 1970-01-01 00:00:00.000000000 +0000
4+++ elfutils-0.158/backends/mips_init.c 2014-04-21 11:13:36.910235965 +0000
5@@ -0,0 +1,60 @@
6+/* Initialization of mips specific backend library.
7+ Copyright (C) 2006 Red Hat, Inc.
8+ This file is part of Red Hat elfutils.
9+
10+ Red Hat elfutils is free software; you can redistribute it and/or modify
11+ it under the terms of the GNU General Public License as published by the
12+ Free Software Foundation; version 2 of the License.
13+
14+ Red Hat elfutils is distributed in the hope that it will be useful, but
15+ WITHOUT ANY WARRANTY; without even the implied warranty of
16+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+ General Public License for more details.
18+
19+ You should have received a copy of the GNU General Public License along
20+ with Red Hat elfutils; if not, write to the Free Software Foundation,
21+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
22+
23+ Red Hat elfutils is an included package of the Open Invention Network.
24+ An included package of the Open Invention Network is a package for which
25+ Open Invention Network licensees cross-license their patents. No patent
26+ license is granted, either expressly or impliedly, by designation as an
27+ included package. Should you wish to participate in the Open Invention
28+ Network licensing program, please visit www.openinventionnetwork.com
29+ <http://www.openinventionnetwork.com>. */
30+
31+#ifdef HAVE_CONFIG_H
32+# include <config.h>
33+#endif
34+
35+#define BACKEND mips_
36+#define RELOC_PREFIX R_MIPS_
37+#include "libebl_CPU.h"
38+
39+/* This defines the common reloc hooks based on mips_reloc.def. */
40+#include "common-reloc.c"
41+
42+const char *
43+mips_init (elf, machine, eh, ehlen)
44+ Elf *elf __attribute__ ((unused));
45+ GElf_Half machine __attribute__ ((unused));
46+ Ebl *eh;
47+ size_t ehlen;
48+{
49+ /* Check whether the Elf_BH object has a sufficent size. */
50+ if (ehlen < sizeof (Ebl))
51+ return NULL;
52+
53+ /* We handle it. */
54+ if (machine == EM_MIPS)
55+ eh->name = "MIPS R3000 big-endian";
56+ else if (machine == EM_MIPS_RS3_LE)
57+ eh->name = "MIPS R3000 little-endian";
58+
59+ mips_init_reloc (eh);
60+ HOOK (eh, reloc_simple_type);
61+ HOOK (eh, return_value_location);
62+ HOOK (eh, register_info);
63+
64+ return MODVERSION;
65+}
66Index: elfutils-0.158/backends/mips_regs.c
67===================================================================
68--- /dev/null 1970-01-01 00:00:00.000000000 +0000
69+++ elfutils-0.158/backends/mips_regs.c 2014-04-21 11:13:36.910235965 +0000
70@@ -0,0 +1,104 @@
71+/* Register names and numbers for MIPS DWARF.
72+ Copyright (C) 2006 Red Hat, Inc.
73+ This file is part of Red Hat elfutils.
74+
75+ Red Hat elfutils is free software; you can redistribute it and/or modify
76+ it under the terms of the GNU General Public License as published by the
77+ Free Software Foundation; version 2 of the License.
78+
79+ Red Hat elfutils is distributed in the hope that it will be useful, but
80+ WITHOUT ANY WARRANTY; without even the implied warranty of
81+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
82+ General Public License for more details.
83+
84+ You should have received a copy of the GNU General Public License along
85+ with Red Hat elfutils; if not, write to the Free Software Foundation,
86+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
87+
88+ Red Hat elfutils is an included package of the Open Invention Network.
89+ An included package of the Open Invention Network is a package for which
90+ Open Invention Network licensees cross-license their patents. No patent
91+ license is granted, either expressly or impliedly, by designation as an
92+ included package. Should you wish to participate in the Open Invention
93+ Network licensing program, please visit www.openinventionnetwork.com
94+ <http://www.openinventionnetwork.com>. */
95+
96+#ifdef HAVE_CONFIG_H
97+# include <config.h>
98+#endif
99+
100+#include <string.h>
101+#include <dwarf.h>
102+
103+#define BACKEND mips_
104+#include "libebl_CPU.h"
105+
106+ssize_t
107+mips_register_info (Ebl *ebl __attribute__((unused)),
108+ int regno, char *name, size_t namelen,
109+ const char **prefix, const char **setname,
110+ int *bits, int *type)
111+{
112+ if (name == NULL)
113+ return 66;
114+
115+ if (regno < 0 || regno > 65 || namelen < 4)
116+ return -1;
117+
118+ *prefix = "$";
119+
120+ if (regno < 32)
121+ {
122+ *setname = "integer";
123+ *type = DW_ATE_signed;
124+ *bits = 32;
125+ if (regno < 32 + 10)
126+ {
127+ name[0] = regno + '0';
128+ namelen = 1;
129+ }
130+ else
131+ {
132+ name[0] = (regno / 10) + '0';
133+ name[1] = (regno % 10) + '0';
134+ namelen = 2;
135+ }
136+ }
137+ else if (regno < 64)
138+ {
139+ *setname = "FPU";
140+ *type = DW_ATE_float;
141+ *bits = 32;
142+ name[0] = 'f';
143+ if (regno < 32 + 10)
144+ {
145+ name[1] = (regno - 32) + '0';
146+ namelen = 2;
147+ }
148+ else
149+ {
150+ name[1] = (regno - 32) / 10 + '0';
151+ name[2] = (regno - 32) % 10 + '0';
152+ namelen = 3;
153+ }
154+ }
155+ else if (regno == 64)
156+ {
157+ *type = DW_ATE_signed;
158+ *bits = 32;
159+ name[0] = 'h';
160+ name[1] = 'i';
161+ namelen = 2;
162+ }
163+ else
164+ {
165+ *type = DW_ATE_signed;
166+ *bits = 32;
167+ name[0] = 'l';
168+ name[1] = 'o';
169+ namelen = 2;
170+ }
171+
172+ name[namelen++] = '\0';
173+ return namelen;
174+}
175Index: elfutils-0.158/backends/mips_reloc.def
176===================================================================
177--- /dev/null 1970-01-01 00:00:00.000000000 +0000
178+++ elfutils-0.158/backends/mips_reloc.def 2014-04-21 11:13:36.910235965 +0000
179@@ -0,0 +1,79 @@
180+/* List the relocation types for mips. -*- C -*-
181+ Copyright (C) 2006 Red Hat, Inc.
182+ This file is part of Red Hat elfutils.
183+
184+ Red Hat elfutils is free software; you can redistribute it and/or modify
185+ it under the terms of the GNU General Public License as published by the
186+ Free Software Foundation; version 2 of the License.
187+
188+ Red Hat elfutils is distributed in the hope that it will be useful, but
189+ WITHOUT ANY WARRANTY; without even the implied warranty of
190+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
191+ General Public License for more details.
192+
193+ You should have received a copy of the GNU General Public License along
194+ with Red Hat elfutils; if not, write to the Free Software Foundation,
195+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
196+
197+ Red Hat elfutils is an included package of the Open Invention Network.
198+ An included package of the Open Invention Network is a package for which
199+ Open Invention Network licensees cross-license their patents. No patent
200+ license is granted, either expressly or impliedly, by designation as an
201+ included package. Should you wish to participate in the Open Invention
202+ Network licensing program, please visit www.openinventionnetwork.com
203+ <http://www.openinventionnetwork.com>. */
204+
205+/* NAME, REL|EXEC|DYN */
206+
207+RELOC_TYPE (NONE, 0)
208+RELOC_TYPE (16, 0)
209+RELOC_TYPE (32, 0)
210+RELOC_TYPE (REL32, 0)
211+RELOC_TYPE (26, 0)
212+RELOC_TYPE (HI16, 0)
213+RELOC_TYPE (LO16, 0)
214+RELOC_TYPE (GPREL16, 0)
215+RELOC_TYPE (LITERAL, 0)
216+RELOC_TYPE (GOT16, 0)
217+RELOC_TYPE (PC16, 0)
218+RELOC_TYPE (CALL16, 0)
219+RELOC_TYPE (GPREL32, 0)
220+
221+RELOC_TYPE (SHIFT5, 0)
222+RELOC_TYPE (SHIFT6, 0)
223+RELOC_TYPE (64, 0)
224+RELOC_TYPE (GOT_DISP, 0)
225+RELOC_TYPE (GOT_PAGE, 0)
226+RELOC_TYPE (GOT_OFST, 0)
227+RELOC_TYPE (GOT_HI16, 0)
228+RELOC_TYPE (GOT_LO16, 0)
229+RELOC_TYPE (SUB, 0)
230+RELOC_TYPE (INSERT_A, 0)
231+RELOC_TYPE (INSERT_B, 0)
232+RELOC_TYPE (DELETE, 0)
233+RELOC_TYPE (HIGHER, 0)
234+RELOC_TYPE (HIGHEST, 0)
235+RELOC_TYPE (CALL_HI16, 0)
236+RELOC_TYPE (CALL_LO16, 0)
237+RELOC_TYPE (SCN_DISP, 0)
238+RELOC_TYPE (REL16, 0)
239+RELOC_TYPE (ADD_IMMEDIATE, 0)
240+RELOC_TYPE (PJUMP, 0)
241+RELOC_TYPE (RELGOT, 0)
242+RELOC_TYPE (JALR, 0)
243+RELOC_TYPE (TLS_DTPMOD32, 0)
244+RELOC_TYPE (TLS_DTPREL32, 0)
245+RELOC_TYPE (TLS_DTPMOD64, 0)
246+RELOC_TYPE (TLS_DTPREL64, 0)
247+RELOC_TYPE (TLS_GD, 0)
248+RELOC_TYPE (TLS_LDM, 0)
249+RELOC_TYPE (TLS_DTPREL_HI16, 0)
250+RELOC_TYPE (TLS_DTPREL_LO16, 0)
251+RELOC_TYPE (TLS_GOTTPREL, 0)
252+RELOC_TYPE (TLS_TPREL32, 0)
253+RELOC_TYPE (TLS_TPREL64, 0)
254+RELOC_TYPE (TLS_TPREL_HI16, 0)
255+RELOC_TYPE (TLS_TPREL_LO16, 0)
256+
257+#define NO_COPY_RELOC 1
258+#define NO_RELATIVE_RELOC 1
259Index: elfutils-0.158/backends/mips_retval.c
260===================================================================
261--- /dev/null 1970-01-01 00:00:00.000000000 +0000
262+++ elfutils-0.158/backends/mips_retval.c 2014-04-21 11:13:36.910235965 +0000
263@@ -0,0 +1,321 @@
264+/* Function return value location for Linux/mips ABI.
265+ Copyright (C) 2005 Red Hat, Inc.
266+ This file is part of Red Hat elfutils.
267+
268+ Red Hat elfutils is free software; you can redistribute it and/or modify
269+ it under the terms of the GNU General Public License as published by the
270+ Free Software Foundation; version 2 of the License.
271+
272+ Red Hat elfutils is distributed in the hope that it will be useful, but
273+ WITHOUT ANY WARRANTY; without even the implied warranty of
274+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
275+ General Public License for more details.
276+
277+ You should have received a copy of the GNU General Public License along
278+ with Red Hat elfutils; if not, write to the Free Software Foundation,
279+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
280+
281+ Red Hat elfutils is an included package of the Open Invention Network.
282+ An included package of the Open Invention Network is a package for which
283+ Open Invention Network licensees cross-license their patents. No patent
284+ license is granted, either expressly or impliedly, by designation as an
285+ included package. Should you wish to participate in the Open Invention
286+ Network licensing program, please visit www.openinventionnetwork.com
287+ <http://www.openinventionnetwork.com>. */
288+
289+#ifdef HAVE_CONFIG_H
290+# include <config.h>
291+#endif
292+
293+#include <string.h>
294+#include <assert.h>
295+#include <dwarf.h>
296+#include <elf.h>
297+
298+#include "../libebl/libeblP.h"
299+#include "../libdw/libdwP.h"
300+
301+#define BACKEND mips_
302+#include "libebl_CPU.h"
303+
304+/* The ABI of the file. Also see EF_MIPS_ABI2 above. */
305+#define EF_MIPS_ABI 0x0000F000
306+
307+/* The original o32 abi. */
308+#define E_MIPS_ABI_O32 0x00001000
309+
310+/* O32 extended to work on 64 bit architectures */
311+#define E_MIPS_ABI_O64 0x00002000
312+
313+/* EABI in 32 bit mode */
314+#define E_MIPS_ABI_EABI32 0x00003000
315+
316+/* EABI in 64 bit mode */
317+#define E_MIPS_ABI_EABI64 0x00004000
318+
319+/* All the possible MIPS ABIs. */
320+enum mips_abi
321+ {
322+ MIPS_ABI_UNKNOWN = 0,
323+ MIPS_ABI_N32,
324+ MIPS_ABI_O32,
325+ MIPS_ABI_N64,
326+ MIPS_ABI_O64,
327+ MIPS_ABI_EABI32,
328+ MIPS_ABI_EABI64,
329+ MIPS_ABI_LAST
330+ };
331+
332+/* Find the mips ABI of the current file */
333+enum mips_abi find_mips_abi(Elf *elf)
334+{
335+ GElf_Ehdr ehdr_mem;
336+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
337+
338+ if (ehdr == NULL)
339+ return MIPS_ABI_LAST;
340+
341+ GElf_Word elf_flags = ehdr->e_flags;
342+
343+ /* Check elf_flags to see if it specifies the ABI being used. */
344+ switch ((elf_flags & EF_MIPS_ABI))
345+ {
346+ case E_MIPS_ABI_O32:
347+ return MIPS_ABI_O32;
348+ case E_MIPS_ABI_O64:
349+ return MIPS_ABI_O64;
350+ case E_MIPS_ABI_EABI32:
351+ return MIPS_ABI_EABI32;
352+ case E_MIPS_ABI_EABI64:
353+ return MIPS_ABI_EABI64;
354+ default:
355+ if ((elf_flags & EF_MIPS_ABI2))
356+ return MIPS_ABI_N32;
357+ }
358+
359+ /* GCC creates a pseudo-section whose name describes the ABI. */
360+ size_t shstrndx;
361+ if (elf_getshdrstrndx (elf, &shstrndx) < 0)
362+ return MIPS_ABI_LAST;
363+
364+ const char *name;
365+ Elf_Scn *scn = NULL;
366+ while ((scn = elf_nextscn (elf, scn)) != NULL)
367+ {
368+ GElf_Shdr shdr_mem;
369+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
370+ if (shdr == NULL)
371+ return MIPS_ABI_LAST;
372+
373+ name = elf_strptr (elf, shstrndx, shdr->sh_name) ?: "";
374+ if (strncmp (name, ".mdebug.", 8) != 0)
375+ continue;
376+
377+ if (strcmp (name, ".mdebug.abi32") == 0)
378+ return MIPS_ABI_O32;
379+ else if (strcmp (name, ".mdebug.abiN32") == 0)
380+ return MIPS_ABI_N32;
381+ else if (strcmp (name, ".mdebug.abi64") == 0)
382+ return MIPS_ABI_N64;
383+ else if (strcmp (name, ".mdebug.abiO64") == 0)
384+ return MIPS_ABI_O64;
385+ else if (strcmp (name, ".mdebug.eabi32") == 0)
386+ return MIPS_ABI_EABI32;
387+ else if (strcmp (name, ".mdebug.eabi64") == 0)
388+ return MIPS_ABI_EABI64;
389+ else
390+ return MIPS_ABI_UNKNOWN;
391+ }
392+
393+ return MIPS_ABI_UNKNOWN;
394+}
395+
396+unsigned int
397+mips_abi_regsize (enum mips_abi abi)
398+{
399+ switch (abi)
400+ {
401+ case MIPS_ABI_EABI32:
402+ case MIPS_ABI_O32:
403+ return 4;
404+ case MIPS_ABI_N32:
405+ case MIPS_ABI_N64:
406+ case MIPS_ABI_O64:
407+ case MIPS_ABI_EABI64:
408+ return 8;
409+ case MIPS_ABI_UNKNOWN:
410+ case MIPS_ABI_LAST:
411+ default:
412+ return 0;
413+ }
414+}
415+
416+
417+/* $v0 or pair $v0, $v1 */
418+static const Dwarf_Op loc_intreg_o32[] =
419+ {
420+ { .atom = DW_OP_reg2 }, { .atom = DW_OP_piece, .number = 4 },
421+ { .atom = DW_OP_reg3 }, { .atom = DW_OP_piece, .number = 4 },
422+ };
423+
424+static const Dwarf_Op loc_intreg[] =
425+ {
426+ { .atom = DW_OP_reg2 }, { .atom = DW_OP_piece, .number = 8 },
427+ { .atom = DW_OP_reg3 }, { .atom = DW_OP_piece, .number = 8 },
428+ };
429+#define nloc_intreg 1
430+#define nloc_intregpair 4
431+
432+/* $f0 (float), or pair $f0, $f1 (double).
433+ * f2/f3 are used for COMPLEX (= 2 doubles) returns in Fortran */
434+static const Dwarf_Op loc_fpreg_o32[] =
435+ {
436+ { .atom = DW_OP_regx, .number = 32 }, { .atom = DW_OP_piece, .number = 4 },
437+ { .atom = DW_OP_regx, .number = 33 }, { .atom = DW_OP_piece, .number = 4 },
438+ { .atom = DW_OP_regx, .number = 34 }, { .atom = DW_OP_piece, .number = 4 },
439+ { .atom = DW_OP_regx, .number = 35 }, { .atom = DW_OP_piece, .number = 4 },
440+ };
441+
442+/* $f0, or pair $f0, $f2. */
443+static const Dwarf_Op loc_fpreg[] =
444+ {
445+ { .atom = DW_OP_regx, .number = 32 }, { .atom = DW_OP_piece, .number = 8 },
446+ { .atom = DW_OP_regx, .number = 34 }, { .atom = DW_OP_piece, .number = 8 },
447+ };
448+#define nloc_fpreg 1
449+#define nloc_fpregpair 4
450+#define nloc_fpregquad 8
451+
452+/* The return value is a structure and is actually stored in stack space
453+ passed in a hidden argument by the caller. But, the compiler
454+ helpfully returns the address of that space in $v0. */
455+static const Dwarf_Op loc_aggregate[] =
456+ {
457+ { .atom = DW_OP_breg2, .number = 0 }
458+ };
459+#define nloc_aggregate 1
460+
461+int
462+mips_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
463+{
464+ /* First find the ABI used by the elf object */
465+ enum mips_abi abi = find_mips_abi(functypedie->cu->dbg->elf);
466+
467+ /* Something went seriously wrong while trying to figure out the ABI */
468+ if (abi == MIPS_ABI_LAST)
469+ return -1;
470+
471+ /* We couldn't identify the ABI, but the file seems valid */
472+ if (abi == MIPS_ABI_UNKNOWN)
473+ return -2;
474+
475+ /* Can't handle EABI variants */
476+ if ((abi == MIPS_ABI_EABI32) || (abi == MIPS_ABI_EABI64))
477+ return -2;
478+
479+ unsigned int regsize = mips_abi_regsize (abi);
480+ if (!regsize)
481+ return -2;
482+
483+ /* Start with the function's type, and get the DW_AT_type attribute,
484+ which is the type of the return value. */
485+
486+ Dwarf_Attribute attr_mem;
487+ Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type, &attr_mem);
488+ if (attr == NULL)
489+ /* The function has no return value, like a `void' function in C. */
490+ return 0;
491+
492+ Dwarf_Die die_mem;
493+ Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
494+ int tag = dwarf_tag (typedie);
495+
496+ /* Follow typedefs and qualifiers to get to the actual type. */
497+ while (tag == DW_TAG_typedef
498+ || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
499+ || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
500+ {
501+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
502+ typedie = dwarf_formref_die (attr, &die_mem);
503+ tag = dwarf_tag (typedie);
504+ }
505+
506+ switch (tag)
507+ {
508+ case -1:
509+ return -1;
510+
511+ case DW_TAG_subrange_type:
512+ if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
513+ {
514+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
515+ typedie = dwarf_formref_die (attr, &die_mem);
516+ tag = dwarf_tag (typedie);
517+ }
518+ /* Fall through. */
519+
520+ case DW_TAG_base_type:
521+ case DW_TAG_enumeration_type:
522+ case DW_TAG_pointer_type:
523+ case DW_TAG_ptr_to_member_type:
524+ {
525+ Dwarf_Word size;
526+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
527+ &attr_mem), &size) != 0)
528+ {
529+ if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
530+ size = regsize;
531+ else
532+ return -1;
533+ }
534+ if (tag == DW_TAG_base_type)
535+ {
536+ Dwarf_Word encoding;
537+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
538+ &attr_mem), &encoding) != 0)
539+ return -1;
540+
541+#define ABI_LOC(loc, regsize) ((regsize) == 4 ? (loc ## _o32) : (loc))
542+
543+ if (encoding == DW_ATE_float)
544+ {
545+ *locp = ABI_LOC(loc_fpreg, regsize);
546+ if (size <= regsize)
547+ return nloc_fpreg;
548+
549+ if (size <= 2*regsize)
550+ return nloc_fpregpair;
551+
552+ if (size <= 4*regsize && abi == MIPS_ABI_O32)
553+ return nloc_fpregquad;
554+
555+ goto aggregate;
556+ }
557+ }
558+ *locp = ABI_LOC(loc_intreg, regsize);
559+ if (size <= regsize)
560+ return nloc_intreg;
561+ if (size <= 2*regsize)
562+ return nloc_intregpair;
563+
564+ /* Else fall through. Shouldn't happen though (at least with gcc) */
565+ }
566+
567+ case DW_TAG_structure_type:
568+ case DW_TAG_class_type:
569+ case DW_TAG_union_type:
570+ case DW_TAG_array_type:
571+ aggregate:
572+ /* XXX TODO: Can't handle structure return with other ABI's yet :-/ */
573+ if ((abi != MIPS_ABI_O32) && (abi != MIPS_ABI_O64))
574+ return -2;
575+
576+ *locp = loc_aggregate;
577+ return nloc_aggregate;
578+ }
579+
580+ /* XXX We don't have a good way to return specific errors from ebl calls.
581+ This value means we do not understand the type, but it is well-formed
582+ DWARF and might be valid. */
583+ return -2;
584+}
585Index: elfutils-0.158/backends/mips_symbol.c
586===================================================================
587--- /dev/null 1970-01-01 00:00:00.000000000 +0000
588+++ elfutils-0.158/backends/mips_symbol.c 2014-04-21 11:13:36.910235965 +0000
589@@ -0,0 +1,52 @@
590+/* MIPS specific symbolic name handling.
591+ Copyright (C) 2002, 2003, 2005 Red Hat, Inc.
592+ This file is part of Red Hat elfutils.
593+ Written by Jakub Jelinek <jakub@redhat.com>, 2002.
594+
595+ Red Hat elfutils is free software; you can redistribute it and/or modify
596+ it under the terms of the GNU General Public License as published by the
597+ Free Software Foundation; version 2 of the License.
598+
599+ Red Hat elfutils is distributed in the hope that it will be useful, but
600+ WITHOUT ANY WARRANTY; without even the implied warranty of
601+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
602+ General Public License for more details.
603+
604+ You should have received a copy of the GNU General Public License along
605+ with Red Hat elfutils; if not, write to the Free Software Foundation,
606+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
607+
608+ Red Hat elfutils is an included package of the Open Invention Network.
609+ An included package of the Open Invention Network is a package for which
610+ Open Invention Network licensees cross-license their patents. No patent
611+ license is granted, either expressly or impliedly, by designation as an
612+ included package. Should you wish to participate in the Open Invention
613+ Network licensing program, please visit www.openinventionnetwork.com
614+ <http://www.openinventionnetwork.com>. */
615+
616+#ifdef HAVE_CONFIG_H
617+# include <config.h>
618+#endif
619+
620+#include <elf.h>
621+#include <stddef.h>
622+
623+#define BACKEND mips_
624+#include "libebl_CPU.h"
625+
626+/* Check for the simple reloc types. */
627+Elf_Type
628+mips_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
629+{
630+ switch (type)
631+ {
632+ case R_MIPS_16:
633+ return ELF_T_HALF;
634+ case R_MIPS_32:
635+ return ELF_T_WORD;
636+ case R_MIPS_64:
637+ return ELF_T_XWORD;
638+ default:
639+ return ELF_T_NUM;
640+ }
641+}
642Index: elfutils-0.158/libebl/eblopenbackend.c
643===================================================================
644--- elfutils-0.158.orig/libebl/eblopenbackend.c 2014-04-21 11:13:36.914235875 +0000
645+++ elfutils-0.158/libebl/eblopenbackend.c 2014-04-21 11:13:36.910235965 +0000
646@@ -71,6 +71,8 @@
647 { "sparc", "elf_sparc", "sparc", 5, EM_SPARC, 0, 0 },
648 { "sparc", "elf_sparcv8plus", "sparc", 5, EM_SPARC32PLUS, 0, 0 },
649 { "s390", "ebl_s390", "s390", 4, EM_S390, 0, 0 },
650+ { "mips", "elf_mips", "mips", 4, EM_MIPS, 0, 0 },
651+ { "mips", "elf_mipsel", "mipsel", 4, EM_MIPS_RS3_LE, 0, 0 },
652
653 { "m32", "elf_m32", "m32", 3, EM_M32, 0, 0 },
654 { "m68k", "elf_m68k", "m68k", 4, EM_68K, 0, 0 },
655Index: elfutils-0.158/backends/common-reloc.c
656===================================================================
657--- elfutils-0.158.orig/backends/common-reloc.c 2014-04-21 11:13:36.914235875 +0000
658+++ elfutils-0.158/backends/common-reloc.c 2014-04-21 11:13:36.910235965 +0000
659@@ -112,11 +112,13 @@
660 }
661
662
663+#ifndef NO_COPY_RELOC
664 bool
665 EBLHOOK(copy_reloc_p) (int reloc)
666 {
667 return reloc == R_TYPE (COPY);
668 }
669+#endif
670
671 bool
672 EBLHOOK(none_reloc_p) (int reloc)
673@@ -138,7 +140,9 @@
674 ebl->reloc_type_name = EBLHOOK(reloc_type_name);
675 ebl->reloc_type_check = EBLHOOK(reloc_type_check);
676 ebl->reloc_valid_use = EBLHOOK(reloc_valid_use);
677+#ifndef NO_COPY_RELOC
678 ebl->copy_reloc_p = EBLHOOK(copy_reloc_p);
679+#endif
680 ebl->none_reloc_p = EBLHOOK(none_reloc_p);
681 #ifndef NO_RELATIVE_RELOC
682 ebl->relative_reloc_p = EBLHOOK(relative_reloc_p);
683Index: elfutils-0.158/backends/Makefile.am
684===================================================================
685--- elfutils-0.158.orig/backends/Makefile.am 2014-04-21 11:13:36.914235875 +0000
686+++ elfutils-0.158/backends/Makefile.am 2014-04-21 11:14:10.841468934 +0000
687@@ -33,12 +33,12 @@
688
689
690 modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \
691- tilegx parisc
692+ tilegx parisc mips
693 libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \
694 libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \
695 libebl_aarch64_pic.a libebl_sparc_pic.a libebl_ppc_pic.a \
696 libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a \
697- libebl_parisc_pic.a
698+ libebl_parisc_pic.a libebl_mips_pic.a
699 noinst_LIBRARIES = $(libebl_pic)
700 noinst_DATA = $(libebl_pic:_pic.a=.so)
701
702@@ -121,6 +121,10 @@
703 libebl_parisc_pic_a_SOURCES = $(parisc_SRCS)
704 am_libebl_parisc_pic_a_OBJECTS = $(parisc_SRCS:.c=.os)
705
706+mips_SRCS = mips_init.c mips_symbol.c mips_regs.c mips_retval.c
707+libebl_mips_pic_a_SOURCES = $(mips_SRCS)
708+am_libebl_mips_pic_a_OBJECTS = $(mips_SRCS:.c=.os)
709+
710 libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw)
711 @rm -f $(@:.so=.map)
712 echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: *; };' \
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.158/mips_readelf_w.patch b/meta/recipes-devtools/elfutils/elfutils-0.158/mips_readelf_w.patch
deleted file mode 100644
index 8e669e7199..0000000000
--- a/meta/recipes-devtools/elfutils/elfutils-0.158/mips_readelf_w.patch
+++ /dev/null
@@ -1,22 +0,0 @@
1From: Kurt Roeckx <kurt@roeckx.be>
2Subject: Make readelf -w output debug information on mips
3Bug-Debian: http://bugs.debian.org/662041
4Forwarded: not-needed
5
6Upstreams wants a change where this is handled by a hook that needs
7to be filled in by the backend for the arch.
8
9Index: elfutils-0.153/src/readelf.c
10===================================================================
11--- elfutils-0.153.orig/src/readelf.c 2012-08-10 22:01:55.000000000 +0200
12+++ elfutils-0.153/src/readelf.c 2012-09-18 21:46:27.000000000 +0200
13@@ -7364,7 +7364,8 @@
14 GElf_Shdr shdr_mem;
15 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
16
17- if (shdr != NULL && shdr->sh_type == SHT_PROGBITS)
18+ if (shdr != NULL && (
19+ (shdr->sh_type == SHT_PROGBITS) || (shdr->sh_type == SHT_MIPS_DWARF)))
20 {
21 static const struct
22 {
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.158/redhat-portability.diff b/meta/recipes-devtools/elfutils/elfutils-0.158/redhat-portability.diff
deleted file mode 100644
index 5a75375690..0000000000
--- a/meta/recipes-devtools/elfutils/elfutils-0.158/redhat-portability.diff
+++ /dev/null
@@ -1,955 +0,0 @@
1--- elfutils/backends/ChangeLog
2+++ elfutils/backends/ChangeLog
3@@ -292,6 +292,10 @@
4 * ppc_attrs.c (ppc_check_object_attribute): Handle tag
5 GNU_Power_ABI_Struct_Return.
6
7+2009-01-23 Roland McGrath <roland@redhat.com>
8+
9+ * Makefile.am (libebl_%.so): Use $(LD_AS_NEEDED).
10+
11 2008-10-04 Ulrich Drepper <drepper@redhat.com>
12
13 * i386_reloc.def: Fix entries for TLS_GOTDESC, TLS_DESC_CALL, and
14@@ -619,6 +623,11 @@
15 * sparc_init.c: Likewise.
16 * x86_64_init.c: Likewise.
17
18+2005-11-22 Roland McGrath <roland@redhat.com>
19+
20+ * Makefile.am (LD_AS_NEEDED): New variable, substituted by configure.
21+ (libebl_%.so rule): Use it in place of -Wl,--as-needed.
22+
23 2005-11-19 Roland McGrath <roland@redhat.com>
24
25 * ppc64_reloc.def: REL30 -> ADDR30.
26@@ -641,6 +650,9 @@
27 * Makefile.am (uninstall): Don't try to remove $(pkgincludedir).
28 (CLEANFILES): Add libebl_$(m).so.
29
30+ * Makefile.am (WEXTRA): New variable, substituted by configure.
31+ (AM_CFLAGS): Use it in place of -Wextra.
32+
33 * ppc_reloc.def: Update bits per Alan Modra <amodra@bigpond.net.au>.
34 * ppc64_reloc.def: Likewise.
35
36--- elfutils/backends/Makefile.am
37+++ elfutils/backends/Makefile.am
38@@ -124,7 +124,7 @@ libebl_%.so libebl_%.map: libebl_%_pic.a
39 $(LINK) -shared -o $(@:.map=.so) \
40 -Wl,--whole-archive $< $(cpu_$*) -Wl,--no-whole-archive \
41 -Wl,--version-script,$(@:.so=.map) \
42- -Wl,-z,defs -Wl,--as-needed $(libelf) $(libdw) $(libmudflap)
43+ -Wl,-z,defs $(LD_AS_NEEDED) $(libelf) $(libdw) $(libmudflap)
44 $(textrel_check)
45
46 libebl_i386.so: $(cpu_i386)
47--- elfutils/ChangeLog
48+++ elfutils/ChangeLog
49@@ -118,6 +118,8 @@
50
51 2012-01-24 Mark Wielaard <mjw@redhat.com>
52
53+ * configure.ac: Wrap AC_COMPILE_IFELSE sources in AC_LANG_SOURCE.
54+
55 * COPYING: Fix address. Updated version from gnulib.
56
57 2012-01-23 Mark Wielaard <mjw@redhat.com>
58@@ -136,6 +138,9 @@
59
60 2011-10-08 Mike Frysinger <vapier@gentoo.org>
61
62+ * configure.ac (--disable-werror): Handle it, controlling BUILD_WERROR
63+ automake option.
64+
65 * configure.ac: Fix use of AC_ARG_ENABLE to handle $enableval correctly.
66
67 2011-10-02 Ulrich Drepper <drepper@gmail.com>
68@@ -157,6 +162,10 @@
69
70 * configure.ac (LOCALEDIR, DATADIRNAME): Removed.
71
72+2009-11-22 Roland McGrath <roland@redhat.com>
73+
74+ * configure.ac: Use sed and expr instead of modern bash extensions.
75+
76 2009-09-21 Ulrich Drepper <drepper@redhat.com>
77
78 * configure.ac: Update for more modern autoconf.
79@@ -165,6 +174,10 @@
80
81 * configure.ac (zip_LIBS): Check for liblzma too.
82
83+2009-08-17 Roland McGrath <roland@redhat.com>
84+
85+ * configure.ac: Check for -fgnu89-inline; add it to WEXTRA if it works.
86+
87 2009-04-19 Roland McGrath <roland@redhat.com>
88
89 * configure.ac (eu_version): Round down here, not in version.h macros.
90@@ -176,6 +189,8 @@
91
92 2009-01-23 Roland McGrath <roland@redhat.com>
93
94+ * configure.ac: Check for __builtin_popcount.
95+
96 * configure.ac (zlib check): Check for gzdirect, need zlib >= 1.2.2.3.
97
98 * configure.ac (__thread check): Use AC_LINK_IFELSE, in case of
99@@ -256,6 +271,10 @@
100 * configure.ac: Add dummy automake conditional to get dependencies
101 for non-generic linker right. See src/Makefile.am.
102
103+2005-11-22 Roland McGrath <roland@redhat.com>
104+
105+ * configure.ac: Check for --as-needed linker option.
106+
107 2005-11-18 Roland McGrath <roland@redhat.com>
108
109 * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): New variable.
110@@ -303,6 +322,17 @@
111 * Makefile.am (all_SUBDIRS): Add libdwfl.
112 * configure.ac: Write libdwfl/Makefile.
113
114+2005-05-31 Roland McGrath <roland@redhat.com>
115+
116+ * configure.ac (WEXTRA): Check for -Wextra and set this substitution.
117+
118+ * configure.ac: Check for struct stat st_?tim members.
119+ * src/strip.c (process_file): Use st_?time if st_?tim are not there.
120+
121+ * configure.ac: Check for futimes function.
122+ * src/strip.c (handle_elf) [! HAVE_FUTIMES]: Use utimes instead.
123+ (handle_ar) [! HAVE_FUTIMES]: Likewise.
124+
125 2005-05-19 Roland McGrath <roland@redhat.com>
126
127 * configure.ac [AH_BOTTOM] (INTDECL, _INTDECL): New macros.
128--- elfutils/config/ChangeLog
129+++ elfutils/config/ChangeLog
130@@ -44,6 +44,10 @@
131
132 * known-dwarf.awk: Use gawk.
133
134+2011-10-08 Mike Frysinger <vapier@gentoo.org>
135+
136+ * eu.am [BUILD_WERROR]: Conditionalize -Werror use on this.
137+
138 2010-07-02 Ulrich Drepper <drepper@redhat.com>
139
140 * elfutils.spec.in: Add more BuildRequires.
141--- elfutils/config/eu.am
142+++ elfutils/config/eu.am
143@@ -1,6 +1,6 @@
144 ## Common automake fragments for elfutils subdirectory makefiles.
145 ##
146-## Copyright (C) 2010 Red Hat, Inc.
147+## Copyright (C) 2010-2011 Red Hat, Inc.
148 ##
149 ## This file is part of elfutils.
150 ##
151@@ -29,14 +29,20 @@
152 ## not, see <http://www.gnu.org/licenses/>.
153 ##
154
155+WEXTRA = @WEXTRA@
156+LD_AS_NEEDED = @LD_AS_NEEDED@
157+
158 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"${localedir}"'
159 AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_srcdir)/lib -I..
160 AM_CFLAGS = -std=gnu99 -Wall -Wshadow \
161- $(if $($(*F)_no_Werror),,-Werror) \
162- $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
163+ $(if $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) \
164 $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) \
165 $($(*F)_CFLAGS)
166
167+if BUILD_WERROR
168+AM_CFLAGS += $(if $($(*F)_no_Werror),,-Werror)
169+endif
170+
171 if MUDFLAP
172 AM_CFLAGS += -fmudflap
173 libmudflap = -lmudflap
174--- elfutils/config.h.in
175+++ elfutils/config.h.in
176@@ -6,6 +6,9 @@
177 /* Defined if libdw should support GNU ref_alt FORM, dwz multi files. */
178 #undef ENABLE_DWZ
179
180+/* Have __builtin_popcount. */
181+#undef HAVE_BUILTIN_POPCOUNT
182+
183 /* Define to 1 if you have the <inttypes.h> header file. */
184 #undef HAVE_INTTYPES_H
185
186@@ -102,4 +105,7 @@
187 /* Define for large files, on AIX-style hosts. */
188 #undef _LARGE_FILES
189
190+/* Stubbed out if missing compiler support. */
191+#undef __thread
192+
193 #include <eu-config.h>
194--- elfutils/configure.ac
195+++ elfutils/configure.ac
196@@ -99,6 +99,54 @@ CFLAGS="$old_CFLAGS"])
197 AS_IF([test "x$ac_cv_c99" != xyes],
198 AC_MSG_ERROR([gcc with C99 support required]))
199
200+AC_CACHE_CHECK([for -Wextra option to $CC], ac_cv_cc_wextra, [dnl
201+old_CFLAGS="$CFLAGS"
202+CFLAGS="$CFLAGS -Wextra"
203+AC_COMPILE_IFELSE([AC_LANG_SOURCE([void foo (void) { }])],
204+ ac_cv_cc_wextra=yes, ac_cv_cc_wextra=no)
205+CFLAGS="$old_CFLAGS"])
206+AC_SUBST(WEXTRA)
207+AS_IF([test "x$ac_cv_cc_wextra" = xyes], [WEXTRA=-Wextra], [WEXTRA=-W])
208+
209+AC_CACHE_CHECK([for -fgnu89-inline option to $CC], ac_cv_cc_gnu89_inline, [dnl
210+old_CFLAGS="$CFLAGS"
211+CFLAGS="$CFLAGS -fgnu89-inline -Werror"
212+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
213+void foo (void)
214+{
215+ inline void bar (void) {}
216+ bar ();
217+}
218+extern inline void baz (void) {}
219+])], ac_cv_cc_gnu89_inline=yes, ac_cv_cc_gnu89_inline=no)
220+CFLAGS="$old_CFLAGS"])
221+AS_IF([test "x$ac_cv_cc_gnu89_inline" = xyes],
222+ [WEXTRA="${WEXTRA:+$WEXTRA }-fgnu89-inline"])
223+
224+AC_CACHE_CHECK([for --as-needed linker option],
225+ ac_cv_as_needed, [dnl
226+cat > conftest.c <<EOF
227+int main (void) { return 0; }
228+EOF
229+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
230+ -fPIC -shared -o conftest.so conftest.c
231+ -Wl,--as-needed 1>&AS_MESSAGE_LOG_FD])
232+then
233+ ac_cv_as_needed=yes
234+else
235+ ac_cv_as_needed=no
236+fi
237+rm -f conftest*])
238+AS_IF([test "x$ac_cv_as_needed" = xyes],
239+ [LD_AS_NEEDED=-Wl,--as-needed], [LD_AS_NEEDED=])
240+AC_SUBST(LD_AS_NEEDED)
241+
242+AC_CACHE_CHECK([for __builtin_popcount], ac_cv_popcount, [dnl
243+AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[exit (__builtin_popcount (127));]])],
244+ ac_cv_popcount=yes, ac_cv_popcount=no)])
245+AS_IF([test "x$ac_cv_popcount" = xyes],
246+ [AC_DEFINE([HAVE_BUILTIN_POPCOUNT], [1], [Have __builtin_popcount.])])
247+
248 AC_CACHE_CHECK([for __thread support], ac_cv_tls, [dnl
249 # Use the same flags that we use for our DSOs, so the test is representative.
250 # Some old compiler/linker/libc combinations fail some ways and not others.
251@@ -114,7 +162,10 @@ static __thread int a; int foo (int b) {
252 CFLAGS="$save_CFLAGS"
253 LDFLAGS="$save_LDFLAGS"])
254 AS_IF([test "x$ac_cv_tls" != xyes],
255- AC_MSG_ERROR([__thread support required]))
256+ [AS_IF([test "$use_locks" = yes],
257+ [AC_MSG_ERROR([--enable-thread-safety requires __thread support])],
258+ [AC_DEFINE([__thread], [/* empty: no multi-thread support */],
259+ [Stubbed out if missing compiler support.])])])
260
261 dnl This test must come as early as possible after the compiler configuration
262 dnl tests, because the choice of the file model can (in principle) affect
263@@ -213,6 +264,11 @@ AM_CONDITIONAL(USE_VALGRIND, test "$use_
264 AM_CONDITIONAL(BUILD_STATIC, [dnl
265 test "$use_mudflap" = yes -o "$use_gprof" = yes -o "$use_gcov" = yes])
266
267+AC_ARG_ENABLE([werror],
268+AS_HELP_STRING([--disable-werror],[do not build with -Werror]),
269+ [enable_werror=$enableval], [enable_werror=yes])
270+AM_CONDITIONAL(BUILD_WERROR, test "$enable_werror" = yes)
271+
272 AC_ARG_ENABLE([tests-rpath],
273 AS_HELP_STRING([--enable-tests-rpath],[build $ORIGIN-using rpath into tests]),
274 [tests_use_rpath=$enableval], [tests_use_rpath=no])
275@@ -324,7 +380,7 @@ case "$eu_version" in
276 esac
277
278 # Round up to the next release API (x.y) version.
279-eu_version=$(( (eu_version + 999) / 1000 ))
280+eu_version=`expr \( $eu_version + 999 \) / 1000`
281
282 AC_CHECK_SIZEOF(long)
283
284--- elfutils/lib/ChangeLog
285+++ elfutils/lib/ChangeLog
286@@ -61,6 +61,9 @@
287
288 2009-01-23 Roland McGrath <roland@redhat.com>
289
290+ * eu-config.h [! HAVE_BUILTIN_POPCOUNT]
291+ (__builtin_popcount): New inline function.
292+
293 * eu-config.h: Add multiple inclusion protection.
294
295 2009-01-17 Ulrich Drepper <drepper@redhat.com>
296@@ -117,6 +120,11 @@
297 * Makefile.am (libeu_a_SOURCES): Add it.
298 * system.h: Declare crc32_file.
299
300+2005-02-07 Roland McGrath <roland@redhat.com>
301+
302+ * Makefile.am (WEXTRA): New variable, substituted by configure.
303+ (AM_CFLAGS): Use it in place of -Wextra.
304+
305 2005-04-30 Ulrich Drepper <drepper@redhat.com>
306
307 * Makefile.am: Use -ffunction-sections for xmalloc.c.
308--- elfutils/lib/eu-config.h
309+++ elfutils/lib/eu-config.h
310@@ -162,6 +162,17 @@ asm (".section predict_data, \"aw\"; .pr
311 /* This macro is used by the tests conditionalize for standalone building. */
312 #define ELFUTILS_HEADER(name) <lib##name.h>
313
314+#ifndef HAVE_BUILTIN_POPCOUNT
315+# define __builtin_popcount hakmem_popcount
316+static inline unsigned int __attribute__ ((unused))
317+hakmem_popcount (unsigned int x)
318+{
319+ /* HAKMEM 169 */
320+ unsigned int n = x - ((x >> 1) & 033333333333) - ((x >> 2) & 011111111111);
321+ return ((n + (n >> 3)) & 030707070707) % 63;
322+}
323+#endif /* HAVE_BUILTIN_POPCOUNT */
324+
325
326 #ifdef SHARED
327 # define OLD_VERSION(name, version) \
328--- elfutils/libasm/ChangeLog
329+++ elfutils/libasm/ChangeLog
330@@ -75,6 +75,11 @@
331 * asm_error.c: Add new error ASM_E_IOERROR.
332 * libasmP.h: Add ASM_E_IOERROR definition.
333
334+2005-05-31 Roland McGrath <roland@redhat.com>
335+
336+ * Makefile.am (WEXTRA): New variable, substituted by configure.
337+ (AM_CFLAGS): Use it in place of -Wextra.
338+
339 2005-02-15 Ulrich Drepper <drepper@redhat.com>
340
341 * Makefile.am (AM_CFLAGS): Add -Wunused -Wextra -Wformat=2.
342--- elfutils/libcpu/ChangeLog
343+++ elfutils/libcpu/ChangeLog
344@@ -47,6 +47,9 @@
345
346 2009-01-23 Roland McGrath <roland@redhat.com>
347
348+ * i386_disasm.c (i386_disasm): Add abort after assert-constant for old
349+ compilers that don't realize it's noreturn.
350+
351 * Makefile.am (i386_parse_CFLAGS): Use quotes around command
352 substitution that can produce leading whitespace.
353
354@@ -376,6 +379,11 @@
355 * defs/i386.doc: New file.
356 * defs/x86_64: New file.
357
358+2005-04-04 Roland McGrath <roland@redhat.com>
359+
360+ * Makefile.am (WEXTRA): New variable, substituted by configure.
361+ (AM_CFLAGS): Use it instead of -Wextra.
362+
363 2005-02-15 Ulrich Drepper <drepper@redhat.com>
364
365 * Makefile (AM_CFLAGS): Add -Wunused -Wextra -Wformat=2.
366--- elfutils/libcpu/i386_disasm.c
367+++ elfutils/libcpu/i386_disasm.c
368@@ -822,6 +822,7 @@ i386_disasm (const uint8_t **startp, con
369
370 default:
371 assert (! "INVALID not handled");
372+ abort ();
373 }
374 }
375 else
376--- elfutils/libdw/ChangeLog
377+++ elfutils/libdw/ChangeLog
378@@ -346,6 +346,10 @@
379
380 * Makefile.am (known-dwarf.h): Run gawk on config/known-dwarf.awk.
381
382+2011-07-20 Mark Wielaard <mjw@redhat.com>
383+
384+ * dwarf_begin_elf.c: Add fallback for be64toh if not defined.
385+
386 2011-07-14 Mark Wielaard <mjw@redhat.com>
387
388 * libdw.h (dwarf_offdie): Fix documentation to mention .debug_info.
389@@ -705,6 +709,10 @@
390
391 * dwarf_hasattr_integrate.c: Integrate DW_AT_specification too.
392
393+2009-08-17 Roland McGrath <roland@redhat.com>
394+
395+ * libdw.h: Disable extern inlines for GCC 4.2.
396+
397 2009-08-10 Roland McGrath <roland@redhat.com>
398
399 * dwarf_getscopevar.c: Use dwarf_diename.
400@@ -1473,6 +1481,11 @@
401
402 2005-05-31 Roland McGrath <roland@redhat.com>
403
404+ * Makefile.am (WEXTRA): New variable, substituted by configure.
405+ (AM_CFLAGS): Use it in place of -Wextra.
406+
407+2005-05-31 Roland McGrath <roland@redhat.com>
408+
409 * dwarf_formref_die.c (dwarf_formref_die): Add CU header offset to
410 formref offset.
411
412--- elfutils/libdw/dwarf_begin_elf.c
413+++ elfutils/libdw/dwarf_begin_elf.c
414@@ -48,6 +48,14 @@
415 #if USE_ZLIB
416 # include <endian.h>
417 # define crc32 loser_crc32
418+# ifndef be64toh
419+# include <byteswap.h>
420+# if __BYTE_ORDER == __LITTLE_ENDIAN
421+# define be64toh(x) bswap_64 (x)
422+# else
423+# define be64toh(x) (x)
424+# endif
425+# endif
426 # include <zlib.h>
427 # undef crc32
428 #endif
429--- elfutils/libdw/libdw.h
430+++ elfutils/libdw/libdw.h
431@@ -879,7 +879,7 @@ extern Dwarf_OOM dwarf_new_oom_handler (
432
433
434 /* Inline optimizations. */
435-#ifdef __OPTIMIZE__
436+#if defined __OPTIMIZE__ && !(__GNUC__ == 4 && __GNUC_MINOR__ == 2)
437 /* Return attribute code of given attribute. */
438 __libdw_extern_inline unsigned int
439 dwarf_whatattr (Dwarf_Attribute *attr)
440--- elfutils/libdwfl/ChangeLog
441+++ elfutils/libdwfl/ChangeLog
442@@ -283,6 +283,21 @@
443 (dwfl_module_addrsym) (i_to_symfile): New function.
444 (dwfl_module_addrsym) (search_table): Use it.
445
446+2013-11-09 Jan Kratochvil <jan.kratochvil@redhat.com>
447+
448+ Older OS compatibility bits.
449+ * linux-core-attach.c (be64toh, le64toh, be32toh, le32toh): Provide
450+ fallbacks if not defined by system.
451+
452+2013-11-09 Jan Kratochvil <jan.kratochvil@redhat.com>
453+
454+ Handle T-stopped detach for old kernels.
455+ * linux-pid-attach.c (struct pid_arg): New field stopped.
456+ (ptrace_attach): New parameter stoppedp. Set it appropriately.
457+ (pid_set_initial_registers): Pass the new field.
458+ (pid_thread_detach): Handle the case of STOPPED for old kernels.
459+ (__libdwfl_attach_state_for_pid): Initialize STOPPED.
460+
461 2013-11-07 Jan Kratochvil <jan.kratochvil@redhat.com>
462 Mark Wielaard <mjw@redhat.com>
463
464@@ -2048,6 +2063,11 @@
465
466 2005-07-21 Roland McGrath <roland@redhat.com>
467
468+ * Makefile.am (WEXTRA): New variable, substituted by configure.
469+ (AM_CFLAGS): Use it in place of -Wextra.
470+
471+2005-07-21 Roland McGrath <roland@redhat.com>
472+
473 * Makefile.am (noinst_HEADERS): Add loc2c.c.
474
475 * test2.c (main): Check sscanf result to quiet warning.
476--- elfutils/libdwfl/linux-core-attach.c
477+++ elfutils/libdwfl/linux-core-attach.c
478@@ -29,6 +29,35 @@
479 #include "libdwflP.h"
480 #include <fcntl.h>
481 #include "system.h"
482+#include <endian.h>
483+#include <byteswap.h>
484+#if __BYTE_ORDER == __LITTLE_ENDIAN
485+# ifndef be64toh
486+# define be64toh(x) bswap_64 (x)
487+# endif
488+# ifndef le64toh
489+# define le64toh(x) (x)
490+# endif
491+# ifndef be32toh
492+# define be32toh(x) bswap_32 (x)
493+# endif
494+# ifndef le32toh
495+# define le32toh(x) (x)
496+# endif
497+#else
498+# ifndef be64toh
499+# define be64toh(x) (x)
500+# endif
501+# ifndef le64toh
502+# define le64toh(x) bswap_64 (x)
503+# endif
504+# ifndef be32toh
505+# define be32toh(x) (x)
506+# endif
507+# ifndef le32toh
508+# define le32toh(x) bswap_32 (x)
509+# endif
510+#endif
511
512 #ifndef MIN
513 # define MIN(a, b) ((a) < (b) ? (a) : (b))
514--- elfutils/libdwfl/linux-pid-attach.c
515+++ elfutils/libdwfl/linux-pid-attach.c
516@@ -268,13 +268,24 @@ pid_thread_detach (Dwfl_Thread *thread,
517 pid_arg->tid_attached = 0;
518 if (! pid_arg->assume_ptrace_stopped)
519 {
520+ // Older kernels (tested kernel-2.6.18-348.12.1.el5.x86_64) need special
521+ // handling of the detachment to keep the process State: T (stopped).
522+ if (pid_arg->tid_was_stopped)
523+ syscall (__NR_tkill, tid, SIGSTOP);
524 /* This handling is needed only on older Linux kernels such as
525- 2.6.32-358.23.2.el6.ppc64. Later kernels such as
526- 3.11.7-200.fc19.x86_64 remember the T (stopped) state
527- themselves and no longer need to pass SIGSTOP during
528- PTRACE_DETACH. */
529+ 2.6.32-358.23.2.el6.ppc64. Later kernels such as 3.11.7-200.fc19.x86_64
530+ remember the T (stopped) state themselves and no longer need to pass
531+ SIGSTOP during PTRACE_DETACH. */
532 ptrace (PTRACE_DETACH, tid, NULL,
533 (void *) (intptr_t) (pid_arg->tid_was_stopped ? SIGSTOP : 0));
534+ if (pid_arg->tid_was_stopped)
535+ {
536+ // Wait till the SIGSTOP settles down.
537+ int i;
538+ for (i = 0; i < 100000; i++)
539+ if (linux_proc_pid_is_stopped (tid))
540+ break;
541+ }
542 }
543 }
544
545--- elfutils/libebl/ChangeLog
546+++ elfutils/libebl/ChangeLog
547@@ -738,6 +738,11 @@
548 * Makefile.am (libebl_*_so_SOURCES): Set to $(*_SRCS) so dependency
549 tracking works right.
550
551+2005-05-31 Roland McGrath <roland@redhat.com>
552+
553+ * Makefile.am (WEXTRA): New variable, substituted by configure.
554+ (AM_CFLAGS): Use it in place of -Wextra.
555+
556 2005-05-21 Ulrich Drepper <drepper@redhat.com>
557
558 * libebl_x86_64.map: Add x86_64_core_note.
559--- elfutils/libelf/ChangeLog
560+++ elfutils/libelf/ChangeLog
561@@ -85,6 +85,11 @@
562
563 * elf-knowledge.h (SECTION_STRIP_P): Remove < SHT_NUM check.
564
565+2011-03-10 Roland McGrath <roland@redhat.com>
566+
567+ * gnuhash_xlate.h (elf_cvt_gnuhash): Avoid post-increment in bswap_32
568+ argument, since some implementations are buggy macros.
569+
570 2011-02-26 Mark Wielaard <mjw@redhat.com>
571
572 * elf_end.c (elf_end): Call rwlock_unlock before rwlock_fini.
573@@ -762,6 +767,11 @@
574
575 * elf.h: Update from glibc.
576
577+2005-05-31 Roland McGrath <roland@redhat.com>
578+
579+ * Makefile.am (WEXTRA): New variable, substituted by configure.
580+ (AM_CFLAGS): Use it in place of -Wextra.
581+
582 2005-05-08 Roland McGrath <roland@redhat.com>
583
584 * elf_begin.c (read_file) [_MUDFLAP]: Don't use mmap for now.
585--- elfutils/libelf/common.h
586+++ elfutils/libelf/common.h
587@@ -139,7 +139,7 @@ libelf_release_all (Elf *elf)
588 (Var) = (sizeof (Var) == 1 \
589 ? (unsigned char) (Var) \
590 : (sizeof (Var) == 2 \
591- ? bswap_16 (Var) \
592+ ? (unsigned short int) bswap_16 (Var) \
593 : (sizeof (Var) == 4 \
594 ? bswap_32 (Var) \
595 : bswap_64 (Var))))
596@@ -148,7 +148,7 @@ libelf_release_all (Elf *elf)
597 (Dst) = (sizeof (Var) == 1 \
598 ? (unsigned char) (Var) \
599 : (sizeof (Var) == 2 \
600- ? bswap_16 (Var) \
601+ ? (unsigned short int) bswap_16 (Var) \
602 : (sizeof (Var) == 4 \
603 ? bswap_32 (Var) \
604 : bswap_64 (Var))))
605--- elfutils/libelf/gnuhash_xlate.h
606+++ elfutils/libelf/gnuhash_xlate.h
607@@ -1,5 +1,5 @@
608 /* Conversion functions for versioning information.
609- Copyright (C) 2006, 2007 Red Hat, Inc.
610+ Copyright (C) 2006-2011 Red Hat, Inc.
611 This file is part of elfutils.
612 Written by Ulrich Drepper <drepper@redhat.com>, 2006.
613
614@@ -68,7 +68,9 @@ elf_cvt_gnuhash (void *dest, const void
615 dest32 = (Elf32_Word *) &dest64[bitmask_words];
616 while (len >= 4)
617 {
618- *dest32++ = bswap_32 (*src32++);
619+ *dest32 = bswap_32 (*src32);
620+ ++dest32;
621+ ++src32;
622 len -= 4;
623 }
624 }
625--- elfutils/src/addr2line.c
626+++ elfutils/src/addr2line.c
627@@ -540,10 +540,10 @@ handle_address (const char *string, Dwfl
628 bool parsed = false;
629 int i, j;
630 char *name = NULL;
631- if (sscanf (string, "(%m[^)])%" PRIiMAX "%n", &name, &addr, &i) == 2
632+ if (sscanf (string, "(%a[^)])%" PRIiMAX "%n", &name, &addr, &i) == 2
633 && string[i] == '\0')
634 parsed = adjust_to_section (name, &addr, dwfl);
635- switch (sscanf (string, "%m[^-+]%n%" PRIiMAX "%n", &name, &i, &addr, &j))
636+ switch (sscanf (string, "%a[^-+]%n%" PRIiMAX "%n", &name, &i, &addr, &j))
637 {
638 default:
639 break;
640--- elfutils/src/ChangeLog
641+++ elfutils/src/ChangeLog
642@@ -964,8 +964,16 @@
643 * readelf.c (attr_callback): Use print_block only when we don't use
644 print_ops.
645
646+2009-08-17 Roland McGrath <roland@redhat.com>
647+
648+ * ld.h: Disable extern inlines for GCC 4.2.
649+
650 2009-08-14 Roland McGrath <roland@redhat.com>
651
652+ * strings.c (read_block): Conditionalize posix_fadvise use
653+ on [POSIX_FADV_SEQUENTIAL].
654+ From Petr Salinger <Petr.Salinger@seznam.cz>.
655+
656 * ar.c (do_oper_extract): Use pathconf instead of statfs.
657
658 2009-08-01 Ulrich Drepper <drepper@redhat.com>
659@@ -1129,6 +1137,8 @@
660 * readelf.c (print_debug_frame_section): Use t instead of j formats
661 for ptrdiff_t OFFSET.
662
663+ * addr2line.c (handle_address): Use %a instead of %m for compatibility.
664+
665 2009-01-21 Ulrich Drepper <drepper@redhat.com>
666
667 * elflint.c (check_program_header): Fix typo in .eh_frame_hdr section
668@@ -1312,6 +1322,11 @@
669 that matches its PT_LOAD's p_flags &~ PF_W. On sparc, PF_X really
670 is valid in RELRO.
671
672+2008-03-01 Roland McGrath <roland@redhat.com>
673+
674+ * readelf.c (dump_archive_index): Tweak portability hack
675+ to match [__GNUC__ < 4] too.
676+
677 2008-02-29 Roland McGrath <roland@redhat.com>
678
679 * readelf.c (print_attributes): Add a cast.
680@@ -1563,6 +1578,8 @@
681
682 * readelf.c (hex_dump): Fix rounding error in whitespace calculation.
683
684+ * Makefile.am (readelf_no_Werror): New variable.
685+
686 2007-10-15 Roland McGrath <roland@redhat.com>
687
688 * make-debug-archive.in: New file.
689@@ -2002,6 +2019,10 @@
690 * elflint.c (valid_e_machine): Add EM_ALPHA.
691 Reported by Christian Aichinger <Greek0@gmx.net>.
692
693+ * strings.c (map_file): Define POSIX_MADV_SEQUENTIAL to
694+ MADV_SEQUENTIAL if undefined. Don't call posix_madvise
695+ if neither is defined.
696+
697 2006-08-08 Ulrich Drepper <drepper@redhat.com>
698
699 * elflint.c (check_dynamic): Don't require DT_HASH for DT_SYMTAB.
700@@ -2078,6 +2099,10 @@
701 * Makefile.am: Add hacks to create dependency files for non-generic
702 linker.
703
704+2006-04-05 Roland McGrath <roland@redhat.com>
705+
706+ * strings.c (MAP_POPULATE): Define to 0 if undefined.
707+
708 2006-06-12 Ulrich Drepper <drepper@redhat.com>
709
710 * ldgeneric.c (ld_generic_generate_sections): Don't create .interp
711@@ -2426,6 +2451,11 @@
712 * readelf.c (print_debug_loc_section): Fix indentation for larger
713 address size.
714
715+2005-05-31 Roland McGrath <roland@redhat.com>
716+
717+ * Makefile.am (WEXTRA): New variable, substituted by configure.
718+ (AM_CFLAGS): Use it in place of -Wextra.
719+
720 2005-05-30 Roland McGrath <roland@redhat.com>
721
722 * readelf.c (print_debug_line_section): Print section offset of each
723--- elfutils/src/findtextrel.c
724+++ elfutils/src/findtextrel.c
725@@ -496,7 +496,11 @@ ptrcompare (const void *p1, const void *
726
727
728 static void
729-check_rel (size_t nsegments, struct segments segments[nsegments],
730+check_rel (size_t nsegments, struct segments segments[
731+#if __GNUC__ >= 4
732+ nsegments
733+#endif
734+ ],
735 GElf_Addr addr, Elf *elf, Elf_Scn *symscn, Dwarf *dw,
736 const char *fname, bool more_than_one, void **knownsrcs)
737 {
738--- elfutils/src/ld.h
739+++ elfutils/src/ld.h
740@@ -1114,6 +1114,7 @@ extern bool dynamically_linked_p (void);
741
742 /* Checked whether the symbol is undefined and referenced from a DSO. */
743 extern bool linked_from_dso_p (struct scninfo *scninfo, size_t symidx);
744+#if defined __OPTIMIZE__ && !(__GNUC__ == 4 && __GNUC_MINOR__ == 2)
745 #ifdef __GNUC_STDC_INLINE__
746 __attribute__ ((__gnu_inline__))
747 #endif
748@@ -1131,5 +1132,6 @@ linked_from_dso_p (struct scninfo *scnin
749
750 return sym->defined && sym->in_dso;
751 }
752+#endif /* Optimizing and not GCC 4.2. */
753
754 #endif /* ld.h */
755--- elfutils/src/Makefile.am
756+++ elfutils/src/Makefile.am
757@@ -95,6 +95,9 @@ addr2line_no_Wformat = yes
758 # XXX While the file is not finished, don't warn about this
759 ldgeneric_no_Wunused = yes
760
761+# Buggy old compilers.
762+readelf_no_Werror = yes
763+
764 readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
765 nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl \
766 $(demanglelib)
767--- elfutils/src/readelf.c
768+++ elfutils/src/readelf.c
769@@ -4171,10 +4171,12 @@ listptr_base (struct listptr *p)
770 return base;
771 }
772
773+static const char *listptr_name;
774+
775 static int
776-compare_listptr (const void *a, const void *b, void *arg)
777+compare_listptr (const void *a, const void *b)
778 {
779- const char *name = arg;
780+ const char *const name = listptr_name;
781 struct listptr *p1 = (void *) a;
782 struct listptr *p2 = (void *) b;
783
784@@ -4263,8 +4265,11 @@ static void
785 sort_listptr (struct listptr_table *table, const char *name)
786 {
787 if (table->n > 0)
788- qsort_r (table->table, table->n, sizeof table->table[0],
789- &compare_listptr, (void *) name);
790+ {
791+ listptr_name = name;
792+ qsort (table->table, table->n, sizeof table->table[0],
793+ &compare_listptr);
794+ }
795 }
796
797 static bool
798@@ -9151,7 +9156,7 @@ dump_archive_index (Elf *elf, const char
799 if (unlikely (elf_rand (elf, as_off) == 0)
800 || unlikely ((subelf = elf_begin (-1, ELF_C_READ_MMAP, elf))
801 == NULL))
802-#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 7)
803+#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 7) || __GNUC__ < 4
804 while (1)
805 #endif
806 error (EXIT_FAILURE, 0,
807--- elfutils/src/strings.c
808+++ elfutils/src/strings.c
809@@ -43,6 +43,10 @@
810
811 #include <system.h>
812
813+#ifndef MAP_POPULATE
814+# define MAP_POPULATE 0
815+#endif
816+
817
818 /* Prototypes of local functions. */
819 static int read_fd (int fd, const char *fname, off64_t fdlen);
820@@ -483,8 +487,13 @@ map_file (int fd, off64_t start_off, off
821 fd, start_off);
822 if (mem != MAP_FAILED)
823 {
824+#if !defined POSIX_MADV_SEQUENTIAL && defined MADV_SEQUENTIAL
825+# define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL
826+#endif
827+#ifdef POSIX_MADV_SEQUENTIAL
828 /* We will go through the mapping sequentially. */
829 (void) posix_madvise (mem, map_size, POSIX_MADV_SEQUENTIAL);
830+#endif
831 break;
832 }
833 if (errno != EINVAL && errno != ENOMEM)
834@@ -576,9 +585,11 @@ read_block (int fd, const char *fname, o
835 elfmap_off = from & ~(ps - 1);
836 elfmap_base = elfmap = map_file (fd, elfmap_off, fdlen, &elfmap_size);
837
838+#ifdef POSIX_FADV_SEQUENTIAL
839 if (unlikely (elfmap == MAP_FAILED))
840 /* Let the kernel know we are going to read everything in sequence. */
841 (void) posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL);
842+#endif
843 }
844
845 if (unlikely (elfmap == MAP_FAILED))
846--- elfutils/src/strip.c
847+++ elfutils/src/strip.c
848@@ -45,6 +45,12 @@
849 #include <libebl.h>
850 #include <system.h>
851
852+#ifdef HAVE_FUTIMES
853+# define FUTIMES(fd, fname, tvp) futimes (fd, tvp)
854+#else
855+# define FUTIMES(fd, fname, tvp) utimes (fname, tvp)
856+#endif
857+
858 typedef uint8_t GElf_Byte;
859
860 /* Name and version of program. */
861@@ -318,8 +324,18 @@ process_file (const char *fname)
862
863 /* If we have to preserve the timestamp, we need it in the
864 format utimes() understands. */
865+#ifdef HAVE_STRUCT_STAT_ST_ATIM
866 TIMESPEC_TO_TIMEVAL (&tv[0], &pre_st.st_atim);
867+#else
868+ tv[0].tv_sec = pre_st.st_atime;
869+ tv[0].tv_usec = 0;
870+#endif
871+#ifdef HAVE_STRUCT_STAT_ST_MTIM
872 TIMESPEC_TO_TIMEVAL (&tv[1], &pre_st.st_mtim);
873+#else
874+ tv[1].tv_sec = pre_st.st_atime;
875+ tv[1].tv_usec = 0;
876+#endif
877 }
878
879 /* Open the file. */
880@@ -2060,7 +2076,7 @@ while computing checksum for debug infor
881 /* If requested, preserve the timestamp. */
882 if (tvp != NULL)
883 {
884- if (futimes (fd, tvp) != 0)
885+ if (FUTIMES (fd, output_fname, tvp) != 0)
886 {
887 error (0, errno, gettext ("\
888 cannot set access and modification date of '%s'"),
889@@ -2117,7 +2133,7 @@ handle_ar (int fd, Elf *elf, const char
890
891 if (tvp != NULL)
892 {
893- if (unlikely (futimes (fd, tvp) != 0))
894+ if (unlikely (FUTIMES (fd, fname, tvp) != 0))
895 {
896 error (0, errno, gettext ("\
897 cannot set access and modification date of '%s'"), fname);
898--- elfutils/tests/backtrace.c
899+++ elfutils/tests/backtrace.c
900@@ -36,6 +36,7 @@
901 #include <fcntl.h>
902 #include <string.h>
903 #include <argp.h>
904+#include <sys/syscall.h>
905 #include ELFUTILS_HEADER(dwfl)
906
907 static int
908--- elfutils/tests/ChangeLog
909+++ elfutils/tests/ChangeLog
910@@ -123,6 +123,13 @@
911
912 2013-12-02 Jan Kratochvil <jan.kratochvil@redhat.com>
913
914+ Handle T-stopped detach for old kernels.
915+ * backtrace.c: Include sys/syscall.h.
916+ (linux_proc_pid_is_stopped): New function.
917+ (ptrace_detach_stopped): Handle old kernels.
918+
919+2013-12-02 Jan Kratochvil <jan.kratochvil@redhat.com>
920+
921 * Makefile.am (check_PROGRAMS): Add backtrace, backtrace-child,
922 backtrace-data and backtrace-dwarf.
923 (BUILT_SOURCES, clean-local, backtrace-child-biarch): New.
924@@ -987,6 +994,8 @@
925
926 2008-01-21 Roland McGrath <roland@redhat.com>
927
928+ * line2addr.c (main): Revert last change.
929+
930 * testfile45.S.bz2: Add tests for cltq, cqto.
931 * testfile45.expect.bz2: Adjust.
932
933@@ -1695,6 +1704,11 @@
934 * Makefile.am (TESTS): Add run-elflint-test.sh.
935 (EXTRA_DIST): Add run-elflint-test.sh and testfile18.bz2.
936
937+2005-05-31 Roland McGrath <roland@redhat.com>
938+
939+ * Makefile.am (WEXTRA): New variable, substituted by configure.
940+ (AM_CFLAGS): Use it in place of -Wextra.
941+
942 2005-05-24 Ulrich Drepper <drepper@redhat.com>
943
944 * get-files.c (main): Use correct format specifier.
945--- elfutils/tests/line2addr.c
946+++ elfutils/tests/line2addr.c
947@@ -124,7 +124,7 @@ main (int argc, char *argv[])
948 {
949 struct args a = { .arg = argv[cnt] };
950
951- switch (sscanf (a.arg, "%m[^:]:%d", &a.file, &a.line))
952+ switch (sscanf (a.arg, "%a[^:]:%d", &a.file, &a.line))
953 {
954 default:
955 case 0:
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.158/redhat-robustify.diff b/meta/recipes-devtools/elfutils/elfutils-0.158/redhat-robustify.diff
deleted file mode 100644
index f358a85466..0000000000
--- a/meta/recipes-devtools/elfutils/elfutils-0.158/redhat-robustify.diff
+++ /dev/null
@@ -1,1756 +0,0 @@
1--- elfutils/libdwfl/ChangeLog
2+++ elfutils/libdwfl/ChangeLog
3@@ -680,6 +680,11 @@
4 * dwfl_module_getdwarf.c (open_elf): Clear errno before CBFAIL.
5 Reported by Kurt Roeckx <kurt@roeckx.be>.
6
7+2011-03-23 Petr Machata <pmachata@redhat.com>
8+
9+ * relocate.c (relocate_section): Use gelf_fsize instead of relying
10+ on shdr->sh_entsize.
11+
12 2011-02-11 Roland McGrath <roland@redhat.com>
13
14 * linux-kernel-modules.c (try_kernel_name): Try .gz, .bz2, .xz
15--- elfutils/libdwfl/relocate.c
16+++ elfutils/libdwfl/relocate.c
17@@ -1,5 +1,5 @@
18 /* Relocate debug information.
19- Copyright (C) 2005-2010 Red Hat, Inc.
20+ Copyright (C) 2005-2011 Red Hat, Inc.
21 This file is part of elfutils.
22
23 This file is free software; you can redistribute it and/or modify
24@@ -456,7 +456,10 @@ relocate_section (Dwfl_Module *mod, Elf
25 }
26 }
27
28- size_t nrels = shdr->sh_size / shdr->sh_entsize;
29+ size_t sh_entsize
30+ = gelf_fsize (relocated, shdr->sh_type == SHT_REL ? ELF_T_REL : ELF_T_RELA,
31+ 1, EV_CURRENT);
32+ size_t nrels = shdr->sh_size / sh_entsize;
33 size_t complete = 0;
34 if (shdr->sh_type == SHT_REL)
35 for (size_t relidx = 0; !result && relidx < nrels; ++relidx)
36@@ -558,7 +561,7 @@ relocate_section (Dwfl_Module *mod, Elf
37 nrels = next;
38 }
39
40- shdr->sh_size = reldata->d_size = nrels * shdr->sh_entsize;
41+ shdr->sh_size = reldata->d_size = nrels * sh_entsize;
42 gelf_update_shdr (scn, shdr);
43 }
44
45--- elfutils/libelf/ChangeLog
46+++ elfutils/libelf/ChangeLog
47@@ -754,10 +754,53 @@
48 If section content hasn't been read yet, do it before looking for the
49 block size. If no section data present, infer size of section header.
50
51+2005-05-14 Jakub Jelinek <jakub@redhat.com>
52+
53+ * libelfP.h (INVALID_NDX): Define.
54+ * gelf_getdyn.c (gelf_getdyn): Use it. Remove ndx < 0 test if any.
55+ * gelf_getlib.c (gelf_getlib): Likewise.
56+ * gelf_getmove.c (gelf_getmove): Likewise.
57+ * gelf_getrel.c (gelf_getrel): Likewise.
58+ * gelf_getrela.c (gelf_getrela): Likewise.
59+ * gelf_getsym.c (gelf_getsym): Likewise.
60+ * gelf_getsyminfo.c (gelf_getsyminfo): Likewise.
61+ * gelf_getsymshndx.c (gelf_getsymshndx): Likewise.
62+ * gelf_getversym.c (gelf_getversym): Likewise.
63+ * gelf_update_dyn.c (gelf_update_dyn): Likewise.
64+ * gelf_update_lib.c (gelf_update_lib): Likewise.
65+ * gelf_update_move.c (gelf_update_move): Likewise.
66+ * gelf_update_rel.c (gelf_update_rel): Likewise.
67+ * gelf_update_rela.c (gelf_update_rela): Likewise.
68+ * gelf_update_sym.c (gelf_update_sym): Likewise.
69+ * gelf_update_syminfo.c (gelf_update_syminfo): Likewise.
70+ * gelf_update_symshndx.c (gelf_update_symshndx): Likewise.
71+ * gelf_update_versym.c (gelf_update_versym): Likewise.
72+ * elf_newscn.c (elf_newscn): Check for overflow.
73+ * elf32_updatefile.c (__elfw2(LIBELFBITS,updatemmap)): Likewise.
74+ (__elfw2(LIBELFBITS,updatefile)): Likewise.
75+ * elf_begin.c (file_read_elf): Likewise.
76+ * elf32_newphdr.c (elfw2(LIBELFBITS,newphdr)): Likewise.
77+ * elf_getarsym.c (elf_getarsym): Likewise.
78+ * elf32_getshdr.c (elfw2(LIBELFBITS,getshdr)): Likewise.
79 2005-05-11 Ulrich Drepper <drepper@redhat.com>
80
81 * elf.h: Update again.
82
83+2005-05-17 Jakub Jelinek <jakub@redhat.com>
84+
85+ * elf32_getphdr.c (elfw2(LIBELFBITS,getphdr)): Check if program header
86+ table fits into object's bounds.
87+ * elf_getshstrndx.c (elf_getshstrndx): Add elf->start_offset to
88+ elf->map_address. Check if first section header fits into object's
89+ bounds.
90+ * elf32_getshdr.c (elfw2(LIBELFBITS,getshdr)):
91+ Check if section header table fits into object's bounds.
92+ * elf_begin.c (get_shnum): Ensure section headers fits into
93+ object's bounds.
94+ (file_read_elf): Make sure scncnt is small enough to allocate both
95+ ElfXX_Shdr and Elf_Scn array. Make sure section and program header
96+ tables fit into object's bounds. Avoid memory leak on failure.
97+
98 2005-05-09 Ulrich Drepper <drepper@redhat.com>
99
100 * elf.h: Update from glibc.
101--- elfutils/libelf/elf32_getphdr.c
102+++ elfutils/libelf/elf32_getphdr.c
103@@ -93,6 +93,16 @@ __elfw2(LIBELFBITS,getphdr_wrlock) (elf)
104
105 if (elf->map_address != NULL)
106 {
107+ /* First see whether the information in the ELF header is
108+ valid and it does not ask for too much. */
109+ if (unlikely (ehdr->e_phoff >= elf->maximum_size)
110+ || unlikely (elf->maximum_size - ehdr->e_phoff < size))
111+ {
112+ /* Something is wrong. */
113+ __libelf_seterrno (ELF_E_INVALID_PHDR);
114+ goto out;
115+ }
116+
117 /* All the data is already mapped. Use it. */
118 void *file_phdr = ((char *) elf->map_address
119 + elf->start_offset + ehdr->e_phoff);
120--- elfutils/libelf/elf32_getshdr.c
121+++ elfutils/libelf/elf32_getshdr.c
122@@ -60,7 +60,8 @@ load_shdr_wrlock (Elf_Scn *scn)
123 goto out;
124
125 size_t shnum;
126- if (__elf_getshdrnum_rdlock (elf, &shnum) != 0)
127+ if (__elf_getshdrnum_rdlock (elf, &shnum) != 0
128+ || shnum > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Shdr)))
129 goto out;
130 size_t size = shnum * sizeof (ElfW2(LIBELFBITS,Shdr));
131
132@@ -77,6 +78,16 @@ load_shdr_wrlock (Elf_Scn *scn)
133
134 if (elf->map_address != NULL)
135 {
136+ /* First see whether the information in the ELF header is
137+ valid and it does not ask for too much. */
138+ if (unlikely (ehdr->e_shoff >= elf->maximum_size)
139+ || unlikely (elf->maximum_size - ehdr->e_shoff < size))
140+ {
141+ /* Something is wrong. */
142+ __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER);
143+ goto free_and_out;
144+ }
145+
146 ElfW2(LIBELFBITS,Shdr) *notcvt;
147
148 /* All the data is already mapped. If we could use it
149--- elfutils/libelf/elf32_newphdr.c
150+++ elfutils/libelf/elf32_newphdr.c
151@@ -114,6 +114,12 @@ elfw2(LIBELFBITS,newphdr) (elf, count)
152 || count == PN_XNUM
153 || elf->state.ELFW(elf,LIBELFBITS).phdr == NULL)
154 {
155+ if (unlikely (count > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Phdr))))
156+ {
157+ result = NULL;
158+ goto out;
159+ }
160+
161 /* Allocate a new program header with the appropriate number of
162 elements. */
163 result = (ElfW2(LIBELFBITS,Phdr) *)
164--- elfutils/libelf/elf32_updatefile.c
165+++ elfutils/libelf/elf32_updatefile.c
166@@ -202,6 +202,9 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf
167 /* Write all the sections. Well, only those which are modified. */
168 if (shnum > 0)
169 {
170+ if (unlikely (shnum > SIZE_MAX / sizeof (Elf_Scn *)))
171+ return 1;
172+
173 Elf_ScnList *list = &elf->state.ELFW(elf,LIBELFBITS).scns;
174 Elf_Scn **scns = (Elf_Scn **) alloca (shnum * sizeof (Elf_Scn *));
175 char *const shdr_start = ((char *) elf->map_address + elf->start_offset
176@@ -624,6 +627,10 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf
177 /* Write all the sections. Well, only those which are modified. */
178 if (shnum > 0)
179 {
180+ if (unlikely (shnum > SIZE_MAX / (sizeof (Elf_Scn *)
181+ + sizeof (ElfW2(LIBELFBITS,Shdr)))))
182+ return 1;
183+
184 off_t shdr_offset = elf->start_offset + ehdr->e_shoff;
185 #if EV_NUM != 2
186 xfct_t shdr_fctp = __elf_xfctstom[__libelf_version - 1][EV_CURRENT - 1][ELFW(ELFCLASS, LIBELFBITS) - 1][ELF_T_SHDR];
187--- elfutils/libelf/elf_begin.c
188+++ elfutils/libelf/elf_begin.c
189@@ -144,7 +144,8 @@ get_shnum (void *map_address, unsigned c
190
191 if (unlikely (result == 0) && ehdr.e32->e_shoff != 0)
192 {
193- if (ehdr.e32->e_shoff + sizeof (Elf32_Shdr) > maxsize)
194+ if (unlikely (ehdr.e32->e_shoff >= maxsize)
195+ || unlikely (maxsize - ehdr.e32->e_shoff < sizeof (Elf32_Shdr)))
196 /* Cannot read the first section header. */
197 return 0;
198
199@@ -192,7 +193,8 @@ get_shnum (void *map_address, unsigned c
200
201 if (unlikely (result == 0) && ehdr.e64->e_shoff != 0)
202 {
203- if (ehdr.e64->e_shoff + sizeof (Elf64_Shdr) > maxsize)
204+ if (unlikely (ehdr.e64->e_shoff >= maxsize)
205+ || unlikely (ehdr.e64->e_shoff + sizeof (Elf64_Shdr) > maxsize))
206 /* Cannot read the first section header. */
207 return 0;
208
209@@ -264,6 +266,15 @@ file_read_elf (int fildes, void *map_add
210 /* Could not determine the number of sections. */
211 return NULL;
212
213+ /* Check for too many sections. */
214+ if (e_ident[EI_CLASS] == ELFCLASS32)
215+ {
216+ if (scncnt > SIZE_MAX / (sizeof (Elf_Scn) + sizeof (Elf32_Shdr)))
217+ return NULL;
218+ }
219+ else if (scncnt > SIZE_MAX / (sizeof (Elf_Scn) + sizeof (Elf64_Shdr)))
220+ return NULL;
221+
222 /* We can now allocate the memory. Even if there are no section headers,
223 we allocate space for a zeroth section in case we need it later. */
224 const size_t scnmax = (scncnt ?: (cmd == ELF_C_RDWR || cmd == ELF_C_RDWR_MMAP)
225@@ -303,6 +314,16 @@ file_read_elf (int fildes, void *map_add
226 {
227 /* We can use the mmapped memory. */
228 elf->state.elf32.ehdr = ehdr;
229+
230+ if (unlikely (ehdr->e_shoff >= maxsize)
231+ || unlikely (maxsize - ehdr->e_shoff
232+ < scncnt * sizeof (Elf32_Shdr)))
233+ {
234+ free_and_out:
235+ free (elf);
236+ __libelf_seterrno (ELF_E_INVALID_FILE);
237+ return NULL;
238+ }
239 elf->state.elf32.shdr
240 = (Elf32_Shdr *) ((char *) ehdr + ehdr->e_shoff);
241
242@@ -389,6 +410,11 @@ file_read_elf (int fildes, void *map_add
243 {
244 /* We can use the mmapped memory. */
245 elf->state.elf64.ehdr = ehdr;
246+
247+ if (unlikely (ehdr->e_shoff >= maxsize)
248+ || unlikely (ehdr->e_shoff
249+ + scncnt * sizeof (Elf32_Shdr) > maxsize))
250+ goto free_and_out;
251 elf->state.elf64.shdr
252 = (Elf64_Shdr *) ((char *) ehdr + ehdr->e_shoff);
253
254--- elfutils/libelf/elf_getarsym.c
255+++ elfutils/libelf/elf_getarsym.c
256@@ -183,6 +183,9 @@ elf_getarsym (elf, ptr)
257 size_t index_size = atol (tmpbuf);
258
259 if (SARMAG + sizeof (struct ar_hdr) + index_size > elf->maximum_size
260+#if SIZE_MAX <= 4294967295U
261+ || n >= SIZE_MAX / sizeof (Elf_Arsym)
262+#endif
263 || n * w > index_size)
264 {
265 /* This index table cannot be right since it does not fit into
266--- elfutils/libelf/elf_getshdrstrndx.c
267+++ elfutils/libelf/elf_getshdrstrndx.c
268@@ -104,10 +104,25 @@ elf_getshdrstrndx (elf, dst)
269 if (elf->map_address != NULL
270 && elf->state.elf32.ehdr->e_ident[EI_DATA] == MY_ELFDATA
271 && (ALLOW_UNALIGNED
272- || (((size_t) ((char *) elf->map_address + offset))
273+ || (((size_t) ((char *) elf->map_address
274+ + elf->start_offset + offset))
275 & (__alignof__ (Elf32_Shdr) - 1)) == 0))
276- /* We can directly access the memory. */
277- num = ((Elf32_Shdr *) (elf->map_address + offset))->sh_link;
278+ {
279+ /* First see whether the information in the ELF header is
280+ valid and it does not ask for too much. */
281+ if (unlikely (elf->maximum_size - offset
282+ < sizeof (Elf32_Shdr)))
283+ {
284+ /* Something is wrong. */
285+ __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER);
286+ result = -1;
287+ goto out;
288+ }
289+
290+ /* We can directly access the memory. */
291+ num = ((Elf32_Shdr *) (elf->map_address + elf->start_offset
292+ + offset))->sh_link;
293+ }
294 else
295 {
296 /* We avoid reading in all the section headers. Just read
297@@ -142,10 +157,25 @@ elf_getshdrstrndx (elf, dst)
298 if (elf->map_address != NULL
299 && elf->state.elf64.ehdr->e_ident[EI_DATA] == MY_ELFDATA
300 && (ALLOW_UNALIGNED
301- || (((size_t) ((char *) elf->map_address + offset))
302+ || (((size_t) ((char *) elf->map_address
303+ + elf->start_offset + offset))
304 & (__alignof__ (Elf64_Shdr) - 1)) == 0))
305- /* We can directly access the memory. */
306- num = ((Elf64_Shdr *) (elf->map_address + offset))->sh_link;
307+ {
308+ /* First see whether the information in the ELF header is
309+ valid and it does not ask for too much. */
310+ if (unlikely (elf->maximum_size - offset
311+ < sizeof (Elf64_Shdr)))
312+ {
313+ /* Something is wrong. */
314+ __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER);
315+ result = -1;
316+ goto out;
317+ }
318+
319+ /* We can directly access the memory. */
320+ num = ((Elf64_Shdr *) (elf->map_address + elf->start_offset
321+ + offset))->sh_link;
322+ }
323 else
324 {
325 /* We avoid reading in all the section headers. Just read
326--- elfutils/libelf/elf_newscn.c
327+++ elfutils/libelf/elf_newscn.c
328@@ -83,10 +83,18 @@ elf_newscn (elf)
329 else
330 {
331 /* We must allocate a new element. */
332- Elf_ScnList *newp;
333+ Elf_ScnList *newp = NULL;
334
335 assert (elf->state.elf.scnincr > 0);
336
337+ if (
338+#if SIZE_MAX <= 4294967295U
339+ likely (elf->state.elf.scnincr
340+ < SIZE_MAX / 2 / sizeof (Elf_Scn) - sizeof (Elf_ScnList))
341+#else
342+ 1
343+#endif
344+ )
345 newp = (Elf_ScnList *) calloc (sizeof (Elf_ScnList)
346 + ((elf->state.elf.scnincr *= 2)
347 * sizeof (Elf_Scn)), 1);
348--- elfutils/libelf/gelf_getdyn.c
349+++ elfutils/libelf/gelf_getdyn.c
350@@ -1,5 +1,5 @@
351 /* Get information from dynamic table at the given index.
352- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
353+ Copyright (C) 2000-2009 Red Hat, Inc.
354 This file is part of elfutils.
355 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
356
357@@ -72,7 +72,7 @@ gelf_getdyn (data, ndx, dst)
358 table entries has to be adopted. The user better has provided
359 a buffer where we can store the information. While copying the
360 data we are converting the format. */
361- if (unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size))
362+ if (INVALID_NDX (ndx, Elf32_Dyn, &data_scn->d))
363 {
364 __libelf_seterrno (ELF_E_INVALID_INDEX);
365 goto out;
366@@ -93,7 +93,7 @@ gelf_getdyn (data, ndx, dst)
367
368 /* The data is already in the correct form. Just make sure the
369 index is OK. */
370- if (unlikely ((ndx + 1) * sizeof (GElf_Dyn) > data_scn->d.d_size))
371+ if (INVALID_NDX (ndx, GElf_Dyn, &data_scn->d))
372 {
373 __libelf_seterrno (ELF_E_INVALID_INDEX);
374 goto out;
375--- elfutils/libelf/gelf_getlib.c
376+++ elfutils/libelf/gelf_getlib.c
377@@ -1,5 +1,5 @@
378 /* Get library from table at the given index.
379- Copyright (C) 2004 Red Hat, Inc.
380+ Copyright (C) 2004-2009 Red Hat, Inc.
381 This file is part of elfutils.
382 Written by Ulrich Drepper <drepper@redhat.com>, 2004.
383
384@@ -65,7 +65,7 @@ gelf_getlib (data, ndx, dst)
385 /* The data is already in the correct form. Just make sure the
386 index is OK. */
387 GElf_Lib *result = NULL;
388- if (unlikely ((ndx + 1) * sizeof (GElf_Lib) > data->d_size))
389+ if (INVALID_NDX (ndx, GElf_Lib, data))
390 __libelf_seterrno (ELF_E_INVALID_INDEX);
391 else
392 {
393--- elfutils/libelf/gelf_getmove.c
394+++ elfutils/libelf/gelf_getmove.c
395@@ -1,5 +1,5 @@
396 /* Get move structure at the given index.
397- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
398+ Copyright (C) 2000-2009 Red Hat, Inc.
399 This file is part of elfutils.
400 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
401
402@@ -62,7 +62,7 @@ gelf_getmove (data, ndx, dst)
403
404 /* The data is already in the correct form. Just make sure the
405 index is OK. */
406- if (unlikely ((ndx + 1) * sizeof (GElf_Move) > data->d_size))
407+ if (INVALID_NDX (ndx, GElf_Move, data))
408 {
409 __libelf_seterrno (ELF_E_INVALID_INDEX);
410 goto out;
411--- elfutils/libelf/gelf_getrela.c
412+++ elfutils/libelf/gelf_getrela.c
413@@ -1,5 +1,5 @@
414 /* Get RELA relocation information at given index.
415- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
416+ Copyright (C) 2000-2009 Red Hat, Inc.
417 This file is part of elfutils.
418 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
419
420@@ -50,12 +50,6 @@ gelf_getrela (data, ndx, dst)
421 if (data_scn == NULL)
422 return NULL;
423
424- if (unlikely (ndx < 0))
425- {
426- __libelf_seterrno (ELF_E_INVALID_INDEX);
427- return NULL;
428- }
429-
430 if (unlikely (data_scn->d.d_type != ELF_T_RELA))
431 {
432 __libelf_seterrno (ELF_E_INVALID_HANDLE);
433@@ -72,7 +66,7 @@ gelf_getrela (data, ndx, dst)
434 if (scn->elf->class == ELFCLASS32)
435 {
436 /* We have to convert the data. */
437- if (unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size))
438+ if (INVALID_NDX (ndx, Elf32_Rela, &data_scn->d))
439 {
440 __libelf_seterrno (ELF_E_INVALID_INDEX);
441 result = NULL;
442@@ -93,7 +87,7 @@ gelf_getrela (data, ndx, dst)
443 {
444 /* Simply copy the data after we made sure we are actually getting
445 correct data. */
446- if (unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size))
447+ if (INVALID_NDX (ndx, Elf64_Rela, &data_scn->d))
448 {
449 __libelf_seterrno (ELF_E_INVALID_INDEX);
450 result = NULL;
451--- elfutils/libelf/gelf_getrel.c
452+++ elfutils/libelf/gelf_getrel.c
453@@ -1,5 +1,5 @@
454 /* Get REL relocation information at given index.
455- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
456+ Copyright (C) 2000-2009 Red Hat, Inc.
457 This file is part of elfutils.
458 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
459
460@@ -50,12 +50,6 @@ gelf_getrel (data, ndx, dst)
461 if (data_scn == NULL)
462 return NULL;
463
464- if (unlikely (ndx < 0))
465- {
466- __libelf_seterrno (ELF_E_INVALID_INDEX);
467- return NULL;
468- }
469-
470 if (unlikely (data_scn->d.d_type != ELF_T_REL))
471 {
472 __libelf_seterrno (ELF_E_INVALID_HANDLE);
473@@ -72,7 +66,7 @@ gelf_getrel (data, ndx, dst)
474 if (scn->elf->class == ELFCLASS32)
475 {
476 /* We have to convert the data. */
477- if (unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size))
478+ if (INVALID_NDX (ndx, Elf32_Rel, &data_scn->d))
479 {
480 __libelf_seterrno (ELF_E_INVALID_INDEX);
481 result = NULL;
482@@ -92,7 +86,7 @@ gelf_getrel (data, ndx, dst)
483 {
484 /* Simply copy the data after we made sure we are actually getting
485 correct data. */
486- if (unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size))
487+ if (INVALID_NDX (ndx, Elf64_Rel, &data_scn->d))
488 {
489 __libelf_seterrno (ELF_E_INVALID_INDEX);
490 result = NULL;
491--- elfutils/libelf/gelf_getsym.c
492+++ elfutils/libelf/gelf_getsym.c
493@@ -1,5 +1,5 @@
494 /* Get symbol information from symbol table at the given index.
495- Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
496+ Copyright (C) 1999-2009 Red Hat, Inc.
497 This file is part of elfutils.
498 Written by Ulrich Drepper <drepper@redhat.com>, 1999.
499
500@@ -69,7 +69,7 @@ gelf_getsym (data, ndx, dst)
501 table entries has to be adopted. The user better has provided
502 a buffer where we can store the information. While copying the
503 data we are converting the format. */
504- if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data->d_size))
505+ if (INVALID_NDX (ndx, Elf32_Sym, data))
506 {
507 __libelf_seterrno (ELF_E_INVALID_INDEX);
508 goto out;
509@@ -98,7 +98,7 @@ gelf_getsym (data, ndx, dst)
510
511 /* The data is already in the correct form. Just make sure the
512 index is OK. */
513- if (unlikely ((ndx + 1) * sizeof (GElf_Sym) > data->d_size))
514+ if (INVALID_NDX (ndx, GElf_Sym, data))
515 {
516 __libelf_seterrno (ELF_E_INVALID_INDEX);
517 goto out;
518--- elfutils/libelf/gelf_getsyminfo.c
519+++ elfutils/libelf/gelf_getsyminfo.c
520@@ -1,5 +1,5 @@
521 /* Get additional symbol information from symbol table at the given index.
522- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
523+ Copyright (C) 2000-2009 Red Hat, Inc.
524 This file is part of elfutils.
525 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
526
527@@ -63,7 +63,7 @@ gelf_getsyminfo (data, ndx, dst)
528
529 /* The data is already in the correct form. Just make sure the
530 index is OK. */
531- if (unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data->d_size))
532+ if (INVALID_NDX (ndx, GElf_Syminfo, data))
533 {
534 __libelf_seterrno (ELF_E_INVALID_INDEX);
535 goto out;
536--- elfutils/libelf/gelf_getsymshndx.c
537+++ elfutils/libelf/gelf_getsymshndx.c
538@@ -1,6 +1,6 @@
539 /* Get symbol information and separate section index from symbol table
540 at the given index.
541- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
542+ Copyright (C) 2000-2009 Red Hat, Inc.
543 This file is part of elfutils.
544 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
545
546@@ -69,7 +69,7 @@ gelf_getsymshndx (symdata, shndxdata, nd
547 section index table. */
548 if (likely (shndxdata_scn != NULL))
549 {
550- if (unlikely ((ndx + 1) * sizeof (Elf32_Word) > shndxdata_scn->d.d_size))
551+ if (INVALID_NDX (ndx, Elf32_Word, &shndxdata_scn->d))
552 {
553 __libelf_seterrno (ELF_E_INVALID_INDEX);
554 goto out;
555@@ -89,7 +89,7 @@ gelf_getsymshndx (symdata, shndxdata, nd
556 table entries has to be adopted. The user better has provided
557 a buffer where we can store the information. While copying the
558 data we are converting the format. */
559- if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata->d_size))
560+ if (INVALID_NDX (ndx, Elf32_Sym, symdata))
561 {
562 __libelf_seterrno (ELF_E_INVALID_INDEX);
563 goto out;
564@@ -118,7 +118,7 @@ gelf_getsymshndx (symdata, shndxdata, nd
565
566 /* The data is already in the correct form. Just make sure the
567 index is OK. */
568- if (unlikely ((ndx + 1) * sizeof (GElf_Sym) > symdata->d_size))
569+ if (INVALID_NDX (ndx, GElf_Sym, symdata))
570 {
571 __libelf_seterrno (ELF_E_INVALID_INDEX);
572 goto out;
573--- elfutils/libelf/gelf_getversym.c
574+++ elfutils/libelf/gelf_getversym.c
575@@ -1,5 +1,5 @@
576 /* Get symbol version information at the given index.
577- Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
578+ Copyright (C) 1999-2009 Red Hat, Inc.
579 This file is part of elfutils.
580 Written by Ulrich Drepper <drepper@redhat.com>, 1999.
581
582@@ -71,7 +71,7 @@ gelf_getversym (data, ndx, dst)
583
584 /* The data is already in the correct form. Just make sure the
585 index is OK. */
586- if (unlikely ((ndx + 1) * sizeof (GElf_Versym) > data->d_size))
587+ if (INVALID_NDX (ndx, GElf_Versym, data))
588 {
589 __libelf_seterrno (ELF_E_INVALID_INDEX);
590 result = NULL;
591--- elfutils/libelf/gelf_update_dyn.c
592+++ elfutils/libelf/gelf_update_dyn.c
593@@ -1,5 +1,5 @@
594 /* Update information in dynamic table at the given index.
595- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
596+ Copyright (C) 2000-2009 Red Hat, Inc.
597 This file is part of elfutils.
598 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
599
600@@ -50,12 +50,6 @@ gelf_update_dyn (data, ndx, src)
601 if (data == NULL)
602 return 0;
603
604- if (unlikely (ndx < 0))
605- {
606- __libelf_seterrno (ELF_E_INVALID_INDEX);
607- return 0;
608- }
609-
610 if (unlikely (data_scn->d.d_type != ELF_T_DYN))
611 {
612 /* The type of the data better should match. */
613@@ -81,7 +75,7 @@ gelf_update_dyn (data, ndx, src)
614 }
615
616 /* Check whether we have to resize the data buffer. */
617- if (unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size))
618+ if (INVALID_NDX (ndx, Elf32_Dyn, &data_scn->d))
619 {
620 __libelf_seterrno (ELF_E_INVALID_INDEX);
621 goto out;
622@@ -95,7 +89,7 @@ gelf_update_dyn (data, ndx, src)
623 else
624 {
625 /* Check whether we have to resize the data buffer. */
626- if (unlikely ((ndx + 1) * sizeof (Elf64_Dyn) > data_scn->d.d_size))
627+ if (INVALID_NDX (ndx, Elf64_Dyn, &data_scn->d))
628 {
629 __libelf_seterrno (ELF_E_INVALID_INDEX);
630 goto out;
631--- elfutils/libelf/gelf_update_lib.c
632+++ elfutils/libelf/gelf_update_lib.c
633@@ -1,5 +1,5 @@
634 /* Update library in table at the given index.
635- Copyright (C) 2004 Red Hat, Inc.
636+ Copyright (C) 2004-2009 Red Hat, Inc.
637 This file is part of elfutils.
638 Written by Ulrich Drepper <drepper@redhat.com>, 2004.
639
640@@ -47,12 +47,6 @@ gelf_update_lib (data, ndx, src)
641 if (data == NULL)
642 return 0;
643
644- if (unlikely (ndx < 0))
645- {
646- __libelf_seterrno (ELF_E_INVALID_INDEX);
647- return 0;
648- }
649-
650 Elf_Data_Scn *data_scn = (Elf_Data_Scn *) data;
651 if (unlikely (data_scn->d.d_type != ELF_T_LIB))
652 {
653@@ -66,7 +60,7 @@ gelf_update_lib (data, ndx, src)
654
655 /* Check whether we have to resize the data buffer. */
656 int result = 0;
657- if (unlikely ((ndx + 1) * sizeof (Elf64_Lib) > data_scn->d.d_size))
658+ if (INVALID_NDX (ndx, Elf64_Lib, &data_scn->d))
659 __libelf_seterrno (ELF_E_INVALID_INDEX);
660 else
661 {
662--- elfutils/libelf/gelf_update_move.c
663+++ elfutils/libelf/gelf_update_move.c
664@@ -1,5 +1,5 @@
665 /* Update move structure at the given index.
666- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
667+ Copyright (C) 2000-2009 Red Hat, Inc.
668 This file is part of elfutils.
669 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
670
671@@ -54,8 +54,7 @@ gelf_update_move (data, ndx, src)
672 assert (sizeof (GElf_Move) == sizeof (Elf64_Move));
673
674 /* Check whether we have to resize the data buffer. */
675- if (unlikely (ndx < 0)
676- || unlikely ((ndx + 1) * sizeof (GElf_Move) > data_scn->d.d_size))
677+ if (INVALID_NDX (ndx, GElf_Move, &data_scn->d))
678 {
679 __libelf_seterrno (ELF_E_INVALID_INDEX);
680 return 0;
681--- elfutils/libelf/gelf_update_rela.c
682+++ elfutils/libelf/gelf_update_rela.c
683@@ -1,5 +1,5 @@
684 /* Update RELA relocation information at given index.
685- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
686+ Copyright (C) 2000-2009 Red Hat, Inc.
687 This file is part of elfutils.
688 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
689
690@@ -47,12 +47,6 @@ gelf_update_rela (Elf_Data *dst, int ndx
691 if (dst == NULL)
692 return 0;
693
694- if (unlikely (ndx < 0))
695- {
696- __libelf_seterrno (ELF_E_INVALID_INDEX);
697- return 0;
698- }
699-
700 if (unlikely (data_scn->d.d_type != ELF_T_RELA))
701 {
702 /* The type of the data better should match. */
703@@ -80,7 +74,7 @@ gelf_update_rela (Elf_Data *dst, int ndx
704 }
705
706 /* Check whether we have to resize the data buffer. */
707- if (unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size))
708+ if (INVALID_NDX (ndx, Elf32_Rela, &data_scn->d))
709 {
710 __libelf_seterrno (ELF_E_INVALID_INDEX);
711 goto out;
712@@ -96,7 +90,7 @@ gelf_update_rela (Elf_Data *dst, int ndx
713 else
714 {
715 /* Check whether we have to resize the data buffer. */
716- if (unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size))
717+ if (INVALID_NDX (ndx, Elf64_Rela, &data_scn->d))
718 {
719 __libelf_seterrno (ELF_E_INVALID_INDEX);
720 goto out;
721--- elfutils/libelf/gelf_update_rel.c
722+++ elfutils/libelf/gelf_update_rel.c
723@@ -1,5 +1,5 @@
724 /* Update REL relocation information at given index.
725- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
726+ Copyright (C) 2000-2009 Red Hat, Inc.
727 This file is part of elfutils.
728 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
729
730@@ -47,12 +47,6 @@ gelf_update_rel (Elf_Data *dst, int ndx,
731 if (dst == NULL)
732 return 0;
733
734- if (unlikely (ndx < 0))
735- {
736- __libelf_seterrno (ELF_E_INVALID_INDEX);
737- return 0;
738- }
739-
740 if (unlikely (data_scn->d.d_type != ELF_T_REL))
741 {
742 /* The type of the data better should match. */
743@@ -78,7 +72,7 @@ gelf_update_rel (Elf_Data *dst, int ndx,
744 }
745
746 /* Check whether we have to resize the data buffer. */
747- if (unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size))
748+ if (INVALID_NDX (ndx, Elf32_Rel, &data_scn->d))
749 {
750 __libelf_seterrno (ELF_E_INVALID_INDEX);
751 goto out;
752@@ -93,7 +87,7 @@ gelf_update_rel (Elf_Data *dst, int ndx,
753 else
754 {
755 /* Check whether we have to resize the data buffer. */
756- if (unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size))
757+ if (INVALID_NDX (ndx, Elf64_Rel, &data_scn->d))
758 {
759 __libelf_seterrno (ELF_E_INVALID_INDEX);
760 goto out;
761--- elfutils/libelf/gelf_update_sym.c
762+++ elfutils/libelf/gelf_update_sym.c
763@@ -1,5 +1,5 @@
764 /* Update symbol information in symbol table at the given index.
765- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
766+ Copyright (C) 2000-2009 Red Hat, Inc.
767 This file is part of elfutils.
768 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
769
770@@ -51,12 +51,6 @@ gelf_update_sym (data, ndx, src)
771 if (data == NULL)
772 return 0;
773
774- if (unlikely (ndx < 0))
775- {
776- __libelf_seterrno (ELF_E_INVALID_INDEX);
777- return 0;
778- }
779-
780 if (unlikely (data_scn->d.d_type != ELF_T_SYM))
781 {
782 /* The type of the data better should match. */
783@@ -81,7 +75,7 @@ gelf_update_sym (data, ndx, src)
784 }
785
786 /* Check whether we have to resize the data buffer. */
787- if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data_scn->d.d_size))
788+ if (INVALID_NDX (ndx, Elf32_Sym, &data_scn->d))
789 {
790 __libelf_seterrno (ELF_E_INVALID_INDEX);
791 goto out;
792@@ -104,7 +98,7 @@ gelf_update_sym (data, ndx, src)
793 else
794 {
795 /* Check whether we have to resize the data buffer. */
796- if (unlikely ((ndx + 1) * sizeof (Elf64_Sym) > data_scn->d.d_size))
797+ if (INVALID_NDX (ndx, Elf64_Sym, &data_scn->d))
798 {
799 __libelf_seterrno (ELF_E_INVALID_INDEX);
800 goto out;
801--- elfutils/libelf/gelf_update_syminfo.c
802+++ elfutils/libelf/gelf_update_syminfo.c
803@@ -1,5 +1,5 @@
804 /* Update additional symbol information in symbol table at the given index.
805- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
806+ Copyright (C) 2000-2009 Red Hat, Inc.
807 This file is part of elfutils.
808 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
809
810@@ -51,12 +51,6 @@ gelf_update_syminfo (data, ndx, src)
811 if (data == NULL)
812 return 0;
813
814- if (unlikely (ndx < 0))
815- {
816- __libelf_seterrno (ELF_E_INVALID_INDEX);
817- return 0;
818- }
819-
820 if (unlikely (data_scn->d.d_type != ELF_T_SYMINFO))
821 {
822 /* The type of the data better should match. */
823@@ -72,7 +66,7 @@ gelf_update_syminfo (data, ndx, src)
824 rwlock_wrlock (scn->elf->lock);
825
826 /* Check whether we have to resize the data buffer. */
827- if (unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data_scn->d.d_size))
828+ if (INVALID_NDX (ndx, GElf_Syminfo, &data_scn->d))
829 {
830 __libelf_seterrno (ELF_E_INVALID_INDEX);
831 goto out;
832--- elfutils/libelf/gelf_update_symshndx.c
833+++ elfutils/libelf/gelf_update_symshndx.c
834@@ -1,6 +1,6 @@
835 /* Update symbol information and section index in symbol table at the
836 given index.
837- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
838+ Copyright (C) 2000-2009 Red Hat, Inc.
839 This file is part of elfutils.
840 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
841
842@@ -56,12 +56,6 @@ gelf_update_symshndx (symdata, shndxdata
843 if (symdata == NULL)
844 return 0;
845
846- if (unlikely (ndx < 0))
847- {
848- __libelf_seterrno (ELF_E_INVALID_INDEX);
849- return 0;
850- }
851-
852 if (unlikely (symdata_scn->d.d_type != ELF_T_SYM))
853 {
854 /* The type of the data better should match. */
855@@ -107,7 +101,7 @@ gelf_update_symshndx (symdata, shndxdata
856 }
857
858 /* Check whether we have to resize the data buffer. */
859- if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata_scn->d.d_size))
860+ if (INVALID_NDX (ndx, Elf32_Sym, &symdata_scn->d))
861 {
862 __libelf_seterrno (ELF_E_INVALID_INDEX);
863 goto out;
864@@ -130,7 +124,7 @@ gelf_update_symshndx (symdata, shndxdata
865 else
866 {
867 /* Check whether we have to resize the data buffer. */
868- if (unlikely ((ndx + 1) * sizeof (Elf64_Sym) > symdata_scn->d.d_size))
869+ if (INVALID_NDX (ndx, Elf64_Sym, &symdata_scn->d))
870 {
871 __libelf_seterrno (ELF_E_INVALID_INDEX);
872 goto out;
873--- elfutils/libelf/gelf_update_versym.c
874+++ elfutils/libelf/gelf_update_versym.c
875@@ -1,5 +1,5 @@
876 /* Update symbol version information.
877- Copyright (C) 2001, 2002 Red Hat, Inc.
878+ Copyright (C) 2001-2009 Red Hat, Inc.
879 This file is part of elfutils.
880 Written by Ulrich Drepper <drepper@redhat.com>, 2001.
881
882@@ -54,8 +54,7 @@ gelf_update_versym (data, ndx, src)
883 assert (sizeof (GElf_Versym) == sizeof (Elf64_Versym));
884
885 /* Check whether we have to resize the data buffer. */
886- if (unlikely (ndx < 0)
887- || unlikely ((ndx + 1) * sizeof (GElf_Versym) > data_scn->d.d_size))
888+ if (INVALID_NDX (ndx, GElf_Versym, &data_scn->d))
889 {
890 __libelf_seterrno (ELF_E_INVALID_INDEX);
891 return 0;
892--- elfutils/libelf/libelfP.h
893+++ elfutils/libelf/libelfP.h
894@@ -587,4 +587,8 @@ extern uint32_t __libelf_crc32 (uint32_t
895 /* Align offset to 4 bytes as needed for note name and descriptor data. */
896 #define NOTE_ALIGN(n) (((n) + 3) & -4U)
897
898+/* Convenience macro. */
899+#define INVALID_NDX(ndx, type, data) \
900+ unlikely ((data)->d_size / sizeof (type) <= (unsigned int) (ndx))
901+
902 #endif /* libelfP.h */
903--- elfutils/src/ChangeLog
904+++ elfutils/src/ChangeLog
905@@ -702,6 +702,12 @@
906
907 * readelf.c (dwarf_attr_string): Grok DW_AT_GNU_odr_signature.
908
909+2011-03-23 Petr Machata <pmachata@redhat.com>
910+
911+ * readelf.c (handle_dynamic, handle_relocs_rel)
912+ (handle_relocs_rela, handle_versym, print_liblist):
913+ Use gelf_fsize instead of relying on shdr->sh_entsize.
914+
915 2011-02-11 Roland McGrath <roland@redhat.com>
916
917 * elfcmp.c (verbose): New variable.
918@@ -2414,6 +2420,16 @@
919 object symbols or symbols with unknown type.
920 (check_rel): Likewise.
921
922+2005-06-09 Roland McGrath <roland@redhat.com>
923+
924+ * readelf.c (handle_dynamic, handle_symtab): Check for bogus sh_link.
925+ (handle_verneed, handle_verdef, handle_versym, handle_hash): Likewise.
926+ (handle_scngrp): Check for bogus sh_info.
927+
928+ * strip.c (handle_elf): Check for bogus values in sh_link, sh_info,
929+ st_shndx, e_shstrndx, and SHT_GROUP or SHT_SYMTAB_SHNDX data.
930+ Don't use assert on input values, instead bail with "illformed" error.
931+
932 2005-06-08 Roland McGrath <roland@redhat.com>
933
934 * readelf.c (print_ops): Add consts.
935@@ -2459,6 +2475,19 @@
936
937 * readelf.c (dwarf_tag_string): Add new tags.
938
939+2005-05-17 Jakub Jelinek <jakub@redhat.com>
940+
941+ * elflint.c (check_hash): Don't check entries beyond end of section.
942+ (check_note): Don't crash if gelf_rawchunk fails.
943+ (section_name): Return <invalid> if gelf_getshdr returns NULL.
944+
945+2005-05-14 Jakub Jelinek <jakub@redhat.com>
946+
947+ * elflint.c (section_name): Return "<invalid>" instead of
948+ crashing on invalid section name.
949+ (check_symtab, is_rel_dyn, check_rela, check_rel, check_dynamic,
950+ check_symtab_shndx, check_hash, check_versym): Robustify.
951+
952 2005-05-08 Roland McGrath <roland@redhat.com>
953
954 * strip.c (handle_elf): Don't translate hash and versym data formats,
955--- elfutils/src/elflint.c
956+++ elfutils/src/elflint.c
957@@ -123,6 +123,10 @@ static uint32_t shstrndx;
958 /* Array to count references in section groups. */
959 static int *scnref;
960
961+/* Numbers of sections and program headers. */
962+static unsigned int shnum;
963+static unsigned int phnum;
964+
965
966 int
967 main (int argc, char *argv[])
968@@ -311,10 +315,19 @@ section_name (Ebl *ebl, int idx)
969 {
970 GElf_Shdr shdr_mem;
971 GElf_Shdr *shdr;
972+ const char *ret;
973+
974+ if ((unsigned int) idx > shnum)
975+ return "<invalid>";
976
977 shdr = gelf_getshdr (elf_getscn (ebl->elf, idx), &shdr_mem);
978+ if (shdr == NULL)
979+ return "<invalid>";
980
981- return elf_strptr (ebl->elf, shstrndx, shdr->sh_name);
982+ ret = elf_strptr (ebl->elf, shstrndx, shdr->sh_name);
983+ if (ret == NULL)
984+ return "<invalid>";
985+ return ret;
986 }
987
988
989@@ -337,11 +350,6 @@ static const int valid_e_machine[] =
990 (sizeof (valid_e_machine) / sizeof (valid_e_machine[0]))
991
992
993-/* Numbers of sections and program headers. */
994-static unsigned int shnum;
995-static unsigned int phnum;
996-
997-
998 static void
999 check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size)
1000 {
1001@@ -625,7 +633,8 @@ section [%2d] '%s': symbol table cannot
1002 }
1003 }
1004
1005- if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_SYM, 1, EV_CURRENT))
1006+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_SYM, 1, EV_CURRENT);
1007+ if (shdr->sh_entsize != sh_entsize)
1008 ERROR (gettext ("\
1009 section [%2u] '%s': entry size is does not match ElfXX_Sym\n"),
1010 idx, section_name (ebl, idx));
1011@@ -663,7 +672,7 @@ section [%2d] '%s': XINDEX for zeroth en
1012 xndxscnidx, section_name (ebl, xndxscnidx));
1013 }
1014
1015- for (size_t cnt = 1; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1016+ for (size_t cnt = 1; cnt < shdr->sh_size / sh_entsize; ++cnt)
1017 {
1018 sym = gelf_getsymshndx (data, xndxdata, cnt, &sym_mem, &xndx);
1019 if (sym == NULL)
1020@@ -683,7 +692,8 @@ section [%2d] '%s': symbol %zu: invalid
1021 else
1022 {
1023 name = elf_strptr (ebl->elf, shdr->sh_link, sym->st_name);
1024- assert (name != NULL);
1025+ assert (name != NULL
1026+ || strshdr->sh_type != SHT_STRTAB);
1027 }
1028
1029 if (sym->st_shndx == SHN_XINDEX)
1030@@ -1040,9 +1050,11 @@ is_rel_dyn (Ebl *ebl, const GElf_Ehdr *e
1031 {
1032 GElf_Shdr rcshdr_mem;
1033 const GElf_Shdr *rcshdr = gelf_getshdr (scn, &rcshdr_mem);
1034- assert (rcshdr != NULL);
1035
1036- if (rcshdr->sh_type == SHT_DYNAMIC)
1037+ if (rcshdr == NULL)
1038+ break;
1039+
1040+ if (rcshdr->sh_type == SHT_DYNAMIC && rcshdr->sh_entsize)
1041 {
1042 /* Found the dynamic section. Look through it. */
1043 Elf_Data *d = elf_getdata (scn, NULL);
1044@@ -1052,7 +1064,9 @@ is_rel_dyn (Ebl *ebl, const GElf_Ehdr *e
1045 {
1046 GElf_Dyn dyn_mem;
1047 GElf_Dyn *dyn = gelf_getdyn (d, cnt, &dyn_mem);
1048- assert (dyn != NULL);
1049+
1050+ if (dyn == NULL)
1051+ break;
1052
1053 if (dyn->d_tag == DT_RELCOUNT)
1054 {
1055@@ -1066,7 +1080,9 @@ section [%2d] '%s': DT_RELCOUNT used for
1056 /* Does the number specified number of relative
1057 relocations exceed the total number of
1058 relocations? */
1059- if (dyn->d_un.d_val > shdr->sh_size / shdr->sh_entsize)
1060+ if (shdr->sh_entsize != 0
1061+ && dyn->d_un.d_val > (shdr->sh_size
1062+ / shdr->sh_entsize))
1063 ERROR (gettext ("\
1064 section [%2d] '%s': DT_RELCOUNT value %d too high for this section\n"),
1065 idx, section_name (ebl, idx),
1066@@ -1226,7 +1242,8 @@ section [%2d] '%s': no relocations for m
1067 }
1068 }
1069
1070- if (shdr->sh_entsize != gelf_fsize (ebl->elf, reltype, 1, EV_CURRENT))
1071+ size_t sh_entsize = gelf_fsize (ebl->elf, reltype, 1, EV_CURRENT);
1072+ if (shdr->sh_entsize != sh_entsize)
1073 ERROR (gettext (reltype == ELF_T_RELA ? "\
1074 section [%2d] '%s': section entry size does not match ElfXX_Rela\n" : "\
1075 section [%2d] '%s': section entry size does not match ElfXX_Rel\n"),
1076@@ -1449,7 +1466,8 @@ check_rela (Ebl *ebl, GElf_Ehdr *ehdr, G
1077 Elf_Data *symdata = elf_getdata (symscn, NULL);
1078 enum load_state state = state_undecided;
1079
1080- for (size_t cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1081+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_RELA, 1, EV_CURRENT);
1082+ for (size_t cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt)
1083 {
1084 GElf_Rela rela_mem;
1085 GElf_Rela *rela = gelf_getrela (data, cnt, &rela_mem);
1086@@ -1499,7 +1517,8 @@ check_rel (Ebl *ebl, GElf_Ehdr *ehdr, GE
1087 Elf_Data *symdata = elf_getdata (symscn, NULL);
1088 enum load_state state = state_undecided;
1089
1090- for (size_t cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1091+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_REL, 1, EV_CURRENT);
1092+ for (size_t cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt)
1093 {
1094 GElf_Rel rel_mem;
1095 GElf_Rel *rel = gelf_getrel (data, cnt, &rel_mem);
1096@@ -1598,7 +1617,8 @@ section [%2d] '%s': referenced as string
1097 shdr->sh_link, section_name (ebl, shdr->sh_link),
1098 idx, section_name (ebl, idx));
1099
1100- if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_DYN, 1, EV_CURRENT))
1101+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_DYN, 1, EV_CURRENT);
1102+ if (shdr->sh_entsize != sh_entsize)
1103 ERROR (gettext ("\
1104 section [%2d] '%s': section entry size does not match ElfXX_Dyn\n"),
1105 idx, section_name (ebl, idx));
1106@@ -1608,7 +1628,7 @@ section [%2d] '%s': section entry size d
1107 idx, section_name (ebl, idx));
1108
1109 bool non_null_warned = false;
1110- for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1111+ for (cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt)
1112 {
1113 GElf_Dyn dyn_mem;
1114 GElf_Dyn *dyn = gelf_getdyn (data, cnt, &dyn_mem);
1115@@ -1880,6 +1900,8 @@ section [%2d] '%s': entry size does not
1116 idx, section_name (ebl, idx));
1117
1118 if (symshdr != NULL
1119+ && shdr->sh_entsize
1120+ && symshdr->sh_entsize
1121 && (shdr->sh_size / shdr->sh_entsize
1122 < symshdr->sh_size / symshdr->sh_entsize))
1123 ERROR (gettext ("\
1124@@ -1906,6 +1928,12 @@ section [%2d] '%s': extended section ind
1125 }
1126
1127 Elf_Data *data = elf_getdata (elf_getscn (ebl->elf, idx), NULL);
1128+ if (data == NULL)
1129+ {
1130+ ERROR (gettext ("section [%2d] '%s': cannot get section data\n"),
1131+ idx, section_name (ebl, idx));
1132+ return;
1133+ }
1134
1135 if (*((Elf32_Word *) data->d_buf) != 0)
1136 ERROR (gettext ("symbol 0 should have zero extended section index\n"));
1137@@ -1948,7 +1976,7 @@ section [%2d] '%s': hash table section i
1138
1139 size_t maxidx = nchain;
1140
1141- if (symshdr != NULL)
1142+ if (symshdr != NULL && symshdr->sh_entsize != 0)
1143 {
1144 size_t symsize = symshdr->sh_size / symshdr->sh_entsize;
1145
1146@@ -1959,18 +1987,28 @@ section [%2d] '%s': hash table section i
1147 maxidx = symsize;
1148 }
1149
1150+ Elf32_Word *buf = (Elf32_Word *) data->d_buf;
1151+ Elf32_Word *end = (Elf32_Word *) ((char *) data->d_buf + shdr->sh_size);
1152 size_t cnt;
1153 for (cnt = 2; cnt < 2 + nbucket; ++cnt)
1154- if (((Elf32_Word *) data->d_buf)[cnt] >= maxidx)
1155+ {
1156+ if (buf + cnt >= end)
1157+ break;
1158+ else if (buf[cnt] >= maxidx)
1159 ERROR (gettext ("\
1160 section [%2d] '%s': hash bucket reference %zu out of bounds\n"),
1161 idx, section_name (ebl, idx), cnt - 2);
1162+ }
1163
1164 for (; cnt < 2 + nbucket + nchain; ++cnt)
1165- if (((Elf32_Word *) data->d_buf)[cnt] >= maxidx)
1166+ {
1167+ if (buf + cnt >= end)
1168+ break;
1169+ else if (buf[cnt] >= maxidx)
1170 ERROR (gettext ("\
1171 section [%2d] '%s': hash chain reference %zu out of bounds\n"),
1172 idx, section_name (ebl, idx), cnt - 2 - nbucket);
1173+ }
1174 }
1175
1176
1177@@ -2000,18 +2038,28 @@ section [%2d] '%s': hash table section i
1178 maxidx = symsize;
1179 }
1180
1181+ Elf64_Xword *buf = (Elf64_Xword *) data->d_buf;
1182+ Elf64_Xword *end = (Elf64_Xword *) ((char *) data->d_buf + shdr->sh_size);
1183 size_t cnt;
1184 for (cnt = 2; cnt < 2 + nbucket; ++cnt)
1185- if (((Elf64_Xword *) data->d_buf)[cnt] >= maxidx)
1186+ {
1187+ if (buf + cnt >= end)
1188+ break;
1189+ else if (buf[cnt] >= maxidx)
1190 ERROR (gettext ("\
1191 section [%2d] '%s': hash bucket reference %zu out of bounds\n"),
1192 idx, section_name (ebl, idx), cnt - 2);
1193+ }
1194
1195 for (; cnt < 2 + nbucket + nchain; ++cnt)
1196- if (((Elf64_Xword *) data->d_buf)[cnt] >= maxidx)
1197+ {
1198+ if (buf + cnt >= end)
1199+ break;
1200+ else if (buf[cnt] >= maxidx)
1201 ERROR (gettext ("\
1202 section [%2d] '%s': hash chain reference %" PRIu64 " out of bounds\n"),
1203- idx, section_name (ebl, idx), (uint64_t) (cnt - 2 - nbucket));
1204+ idx, section_name (ebl, idx), (uint64_t) cnt - 2 - nbucket);
1205+ }
1206 }
1207
1208
1209@@ -2036,7 +2084,7 @@ section [%2d] '%s': bitmask size not pow
1210 if (shdr->sh_size < (4 + bitmask_words + nbuckets) * sizeof (Elf32_Word))
1211 {
1212 ERROR (gettext ("\
1213-section [%2d] '%s': hash table section is too small (is %ld, expected at least%ld)\n"),
1214+section [%2d] '%s': hash table section is too small (is %ld, expected at least %ld)\n"),
1215 idx, section_name (ebl, idx), (long int) shdr->sh_size,
1216 (long int) ((4 + bitmask_words + nbuckets) * sizeof (Elf32_Word)));
1217 return;
1218@@ -2708,8 +2756,9 @@ section [%2d] '%s' refers in sh_link to
1219
1220 /* The number of elements in the version symbol table must be the
1221 same as the number of symbols. */
1222- if (shdr->sh_size / shdr->sh_entsize
1223- != symshdr->sh_size / symshdr->sh_entsize)
1224+ if (shdr->sh_entsize && symshdr->sh_entsize
1225+ && (shdr->sh_size / shdr->sh_entsize
1226+ != symshdr->sh_size / symshdr->sh_entsize))
1227 ERROR (gettext ("\
1228 section [%2d] '%s' has different number of entries than symbol table [%2d] '%s'\n"),
1229 idx, section_name (ebl, idx),
1230--- elfutils/src/readelf.c
1231+++ elfutils/src/readelf.c
1232@@ -1364,6 +1364,8 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, G
1233 Elf32_Word *grpref = (Elf32_Word *) data->d_buf;
1234
1235 GElf_Sym sym_mem;
1236+ GElf_Sym *sym = gelf_getsym (symdata, shdr->sh_info, &sym_mem);
1237+
1238 printf ((grpref[0] & GRP_COMDAT)
1239 ? ngettext ("\
1240 \nCOMDAT section group [%2zu] '%s' with signature '%s' contains %zu entry:\n",
1241@@ -1376,8 +1378,8 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, G
1242 data->d_size / sizeof (Elf32_Word) - 1),
1243 elf_ndxscn (scn),
1244 elf_strptr (ebl->elf, shstrndx, shdr->sh_name),
1245- elf_strptr (ebl->elf, symshdr->sh_link,
1246- gelf_getsym (symdata, shdr->sh_info, &sym_mem)->st_name)
1247+ (sym == NULL ? NULL
1248+ : elf_strptr (ebl->elf, symshdr->sh_link, sym->st_name))
1249 ?: gettext ("<INVALID SYMBOL>"),
1250 data->d_size / sizeof (Elf32_Word) - 1);
1251
1252@@ -1528,10 +1530,12 @@ static void
1253 handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr)
1254 {
1255 int class = gelf_getclass (ebl->elf);
1256- GElf_Shdr glink;
1257+ GElf_Shdr glink_mem;
1258+ GElf_Shdr *glink;
1259 Elf_Data *data;
1260 size_t cnt;
1261 size_t shstrndx;
1262+ size_t sh_entsize;
1263
1264 /* Get the data of the section. */
1265 data = elf_getdata (scn, NULL);
1266@@ -1543,21 +1547,26 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn,
1267 error (EXIT_FAILURE, 0,
1268 gettext ("cannot get section header string table index"));
1269
1270+ sh_entsize = gelf_fsize (ebl->elf, ELF_T_DYN, 1, EV_CURRENT);
1271+
1272+ glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &glink_mem);
1273+ if (glink == NULL)
1274+ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
1275+ elf_ndxscn (scn));
1276+
1277 printf (ngettext ("\
1278 \nDynamic segment contains %lu entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n",
1279 "\
1280 \nDynamic segment contains %lu entries:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n",
1281- shdr->sh_size / shdr->sh_entsize),
1282- (unsigned long int) (shdr->sh_size / shdr->sh_entsize),
1283+ shdr->sh_size / sh_entsize),
1284+ (unsigned long int) (shdr->sh_size / sh_entsize),
1285 class == ELFCLASS32 ? 10 : 18, shdr->sh_addr,
1286 shdr->sh_offset,
1287 (int) shdr->sh_link,
1288- elf_strptr (ebl->elf, shstrndx,
1289- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1290- &glink)->sh_name));
1291+ elf_strptr (ebl->elf, shstrndx, glink->sh_name));
1292 fputs_unlocked (gettext (" Type Value\n"), stdout);
1293
1294- for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1295+ for (cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt)
1296 {
1297 GElf_Dyn dynmem;
1298 GElf_Dyn *dyn = gelf_getdyn (data, cnt, &dynmem);
1299@@ -1706,7 +1715,8 @@ static void
1300 handle_relocs_rel (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr)
1301 {
1302 int class = gelf_getclass (ebl->elf);
1303- int nentries = shdr->sh_size / shdr->sh_entsize;
1304+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_REL, 1, EV_CURRENT);
1305+ int nentries = shdr->sh_size / sh_entsize;
1306
1307 /* Get the data of the section. */
1308 Elf_Data *data = elf_getdata (scn, NULL);
1309@@ -1892,7 +1902,8 @@ static void
1310 handle_relocs_rela (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr)
1311 {
1312 int class = gelf_getclass (ebl->elf);
1313- int nentries = shdr->sh_size / shdr->sh_entsize;
1314+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_RELA, 1, EV_CURRENT);
1315+ int nentries = shdr->sh_size / sh_entsize;
1316
1317 /* Get the data of the section. */
1318 Elf_Data *data = elf_getdata (scn, NULL);
1319@@ -2139,6 +2150,13 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G
1320 error (EXIT_FAILURE, 0,
1321 gettext ("cannot get section header string table index"));
1322
1323+ GElf_Shdr glink_mem;
1324+ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1325+ &glink_mem);
1326+ if (glink == NULL)
1327+ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
1328+ elf_ndxscn (scn));
1329+
1330 /* Now we can compute the number of entries in the section. */
1331 unsigned int nsyms = data->d_size / (class == ELFCLASS32
1332 ? sizeof (Elf32_Sym)
1333@@ -2149,15 +2167,12 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G
1334 nsyms),
1335 (unsigned int) elf_ndxscn (scn),
1336 elf_strptr (ebl->elf, shstrndx, shdr->sh_name), nsyms);
1337- GElf_Shdr glink;
1338 printf (ngettext (" %lu local symbol String table: [%2u] '%s'\n",
1339 " %lu local symbols String table: [%2u] '%s'\n",
1340 shdr->sh_info),
1341 (unsigned long int) shdr->sh_info,
1342 (unsigned int) shdr->sh_link,
1343- elf_strptr (ebl->elf, shstrndx,
1344- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1345- &glink)->sh_name));
1346+ elf_strptr (ebl->elf, shstrndx, glink->sh_name));
1347
1348 fputs_unlocked (class == ELFCLASS32
1349 ? gettext ("\
1350@@ -2393,7 +2408,13 @@ handle_verneed (Ebl *ebl, Elf_Scn *scn,
1351 error (EXIT_FAILURE, 0,
1352 gettext ("cannot get section header string table index"));
1353
1354- GElf_Shdr glink;
1355+ GElf_Shdr glink_mem;
1356+ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1357+ &glink_mem);
1358+ if (glink == NULL)
1359+ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
1360+ elf_ndxscn (scn));
1361+
1362 printf (ngettext ("\
1363 \nVersion needs section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n",
1364 "\
1365@@ -2404,9 +2425,7 @@ handle_verneed (Ebl *ebl, Elf_Scn *scn,
1366 class == ELFCLASS32 ? 10 : 18, shdr->sh_addr,
1367 shdr->sh_offset,
1368 (unsigned int) shdr->sh_link,
1369- elf_strptr (ebl->elf, shstrndx,
1370- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1371- &glink)->sh_name));
1372+ elf_strptr (ebl->elf, shstrndx, glink->sh_name));
1373
1374 unsigned int offset = 0;
1375 for (int cnt = shdr->sh_info; --cnt >= 0; )
1376@@ -2459,8 +2478,14 @@ handle_verdef (Ebl *ebl, Elf_Scn *scn, G
1377 error (EXIT_FAILURE, 0,
1378 gettext ("cannot get section header string table index"));
1379
1380+ GElf_Shdr glink_mem;
1381+ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1382+ &glink_mem);
1383+ if (glink == NULL)
1384+ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
1385+ elf_ndxscn (scn));
1386+
1387 int class = gelf_getclass (ebl->elf);
1388- GElf_Shdr glink;
1389 printf (ngettext ("\
1390 \nVersion definition section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n",
1391 "\
1392@@ -2472,9 +2497,7 @@ handle_verdef (Ebl *ebl, Elf_Scn *scn, G
1393 class == ELFCLASS32 ? 10 : 18, shdr->sh_addr,
1394 shdr->sh_offset,
1395 (unsigned int) shdr->sh_link,
1396- elf_strptr (ebl->elf, shstrndx,
1397- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1398- &glink)->sh_name));
1399+ elf_strptr (ebl->elf, shstrndx, glink->sh_name));
1400
1401 unsigned int offset = 0;
1402 for (int cnt = shdr->sh_info; --cnt >= 0; )
1403@@ -2736,25 +2759,30 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, G
1404 filename = NULL;
1405 }
1406
1407+ GElf_Shdr glink_mem;
1408+ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1409+ &glink_mem);
1410+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_HALF, 1, EV_CURRENT);
1411+ if (glink == NULL)
1412+ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
1413+ elf_ndxscn (scn));
1414+
1415 /* Print the header. */
1416- GElf_Shdr glink;
1417 printf (ngettext ("\
1418 \nVersion symbols section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'",
1419 "\
1420 \nVersion symbols section [%2u] '%s' contains %d entries:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'",
1421- shdr->sh_size / shdr->sh_entsize),
1422+ shdr->sh_size / sh_entsize),
1423 (unsigned int) elf_ndxscn (scn),
1424 elf_strptr (ebl->elf, shstrndx, shdr->sh_name),
1425- (int) (shdr->sh_size / shdr->sh_entsize),
1426+ (int) (shdr->sh_size / sh_entsize),
1427 class == ELFCLASS32 ? 10 : 18, shdr->sh_addr,
1428 shdr->sh_offset,
1429 (unsigned int) shdr->sh_link,
1430- elf_strptr (ebl->elf, shstrndx,
1431- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1432- &glink)->sh_name));
1433+ elf_strptr (ebl->elf, shstrndx, glink->sh_name));
1434
1435 /* Now we can finally look at the actual contents of this section. */
1436- for (unsigned int cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1437+ for (unsigned int cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt)
1438 {
1439 if (cnt % 2 == 0)
1440 printf ("\n %4d:", cnt);
1441@@ -2803,7 +2831,17 @@ print_hash_info (Ebl *ebl, Elf_Scn *scn,
1442 for (Elf32_Word cnt = 0; cnt < nbucket; ++cnt)
1443 ++counts[lengths[cnt]];
1444
1445- GElf_Shdr glink;
1446+ GElf_Shdr glink_mem;
1447+ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf,
1448+ shdr->sh_link),
1449+ &glink_mem);
1450+ if (glink == NULL)
1451+ {
1452+ error (0, 0, gettext ("invalid sh_link value in section %Zu"),
1453+ elf_ndxscn (scn));
1454+ return;
1455+ }
1456+
1457 printf (ngettext ("\
1458 \nHistogram for bucket list length in section [%2u] '%s' (total of %d bucket):\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n",
1459 "\
1460@@ -2816,9 +2854,7 @@ print_hash_info (Ebl *ebl, Elf_Scn *scn,
1461 shdr->sh_addr,
1462 shdr->sh_offset,
1463 (unsigned int) shdr->sh_link,
1464- elf_strptr (ebl->elf, shstrndx,
1465- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1466- &glink)->sh_name));
1467+ elf_strptr (ebl->elf, shstrndx, glink->sh_name));
1468
1469 if (extrastr != NULL)
1470 fputs (extrastr, stdout);
1471@@ -3078,7 +3114,8 @@ print_liblist (Ebl *ebl)
1472
1473 if (shdr != NULL && shdr->sh_type == SHT_GNU_LIBLIST)
1474 {
1475- int nentries = shdr->sh_size / shdr->sh_entsize;
1476+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_LIB, 1, EV_CURRENT);
1477+ int nentries = shdr->sh_size / sh_entsize;
1478 printf (ngettext ("\
1479 \nLibrary list section [%2zu] '%s' at offset %#0" PRIx64 " contains %d entry:\n",
1480 "\
1481@@ -4398,6 +4435,16 @@ print_decoded_aranges_section (Ebl *ebl,
1482 return;
1483 }
1484
1485+ GElf_Shdr glink_mem;
1486+ GElf_Shdr *glink;
1487+ glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &glink_mem);
1488+ if (glink == NULL)
1489+ {
1490+ error (0, 0, gettext ("invalid sh_link value in section %Zu"),
1491+ elf_ndxscn (scn));
1492+ return;
1493+ }
1494+
1495 printf (ngettext ("\
1496 \nDWARF section [%2zu] '%s' at offset %#" PRIx64 " contains %zu entry:\n",
1497 "\
1498--- elfutils/src/strip.c
1499+++ elfutils/src/strip.c
1500@@ -565,6 +565,11 @@ handle_elf (int fd, Elf *elf, const char
1501 goto fail_close;
1502 }
1503
1504+ if (shstrndx >= shnum)
1505+ goto illformed;
1506+
1507+#define elf_assert(test) do { if (!(test)) goto illformed; } while (0)
1508+
1509 /* Storage for section information. We leave room for two more
1510 entries since we unconditionally create a section header string
1511 table. Maybe some weird tool created an ELF file without one.
1512@@ -586,7 +591,7 @@ handle_elf (int fd, Elf *elf, const char
1513 {
1514 /* This should always be true (i.e., there should not be any
1515 holes in the numbering). */
1516- assert (elf_ndxscn (scn) == cnt);
1517+ elf_assert (elf_ndxscn (scn) == cnt);
1518
1519 shdr_info[cnt].scn = scn;
1520
1521@@ -599,6 +604,7 @@ handle_elf (int fd, Elf *elf, const char
1522 shdr_info[cnt].shdr.sh_name);
1523 if (shdr_info[cnt].name == NULL)
1524 {
1525+ illformed:
1526 error (0, 0, gettext ("illformed file '%s'"), fname);
1527 goto fail_close;
1528 }
1529@@ -608,6 +614,8 @@ handle_elf (int fd, Elf *elf, const char
1530
1531 /* Remember the shdr.sh_link value. */
1532 shdr_info[cnt].old_sh_link = shdr_info[cnt].shdr.sh_link;
1533+ if (shdr_info[cnt].old_sh_link >= shnum)
1534+ goto illformed;
1535
1536 /* Sections in files other than relocatable object files which
1537 are not loaded can be freely moved by us. In relocatable
1538@@ -620,7 +628,7 @@ handle_elf (int fd, Elf *elf, const char
1539 appropriate reference. */
1540 if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX))
1541 {
1542- assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0);
1543+ elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0);
1544 shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx = cnt;
1545 }
1546 else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GROUP))
1547@@ -637,7 +645,12 @@ handle_elf (int fd, Elf *elf, const char
1548 for (inner = 1;
1549 inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word);
1550 ++inner)
1551+ {
1552+ if (grpref[inner] < shnum)
1553 shdr_info[grpref[inner]].group_idx = cnt;
1554+ else
1555+ goto illformed;
1556+ }
1557
1558 if (inner == 1 || (inner == 2 && (grpref[0] & GRP_COMDAT) == 0))
1559 /* If the section group contains only one element and this
1560@@ -648,7 +661,7 @@ handle_elf (int fd, Elf *elf, const char
1561 }
1562 else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym))
1563 {
1564- assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0);
1565+ elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0);
1566 shdr_info[shdr_info[cnt].shdr.sh_link].version_idx = cnt;
1567 }
1568
1569@@ -656,7 +669,7 @@ handle_elf (int fd, Elf *elf, const char
1570 discarded right away. */
1571 if ((shdr_info[cnt].shdr.sh_flags & SHF_GROUP) != 0)
1572 {
1573- assert (shdr_info[cnt].group_idx != 0);
1574+ elf_assert (shdr_info[cnt].group_idx != 0);
1575
1576 if (shdr_info[shdr_info[cnt].group_idx].idx == 0)
1577 {
1578@@ -732,10 +745,14 @@ handle_elf (int fd, Elf *elf, const char
1579 {
1580 /* If a relocation section is marked as being removed make
1581 sure the section it is relocating is removed, too. */
1582- if ((shdr_info[cnt].shdr.sh_type == SHT_REL
1583+ if (shdr_info[cnt].shdr.sh_type == SHT_REL
1584 || shdr_info[cnt].shdr.sh_type == SHT_RELA)
1585- && shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0)
1586- shdr_info[cnt].idx = 1;
1587+ {
1588+ if (shdr_info[cnt].shdr.sh_info >= shnum)
1589+ goto illformed;
1590+ else if (shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0)
1591+ shdr_info[cnt].idx = 1;
1592+ }
1593
1594 /* If a group section is marked as being removed make
1595 sure all the sections it contains are being removed, too. */
1596@@ -779,7 +796,7 @@ handle_elf (int fd, Elf *elf, const char
1597 if (shdr_info[cnt].symtab_idx != 0
1598 && shdr_info[shdr_info[cnt].symtab_idx].data == NULL)
1599 {
1600- assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB);
1601+ elf_assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB);
1602
1603 shdr_info[shdr_info[cnt].symtab_idx].data
1604 = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
1605@@ -819,6 +836,9 @@ handle_elf (int fd, Elf *elf, const char
1606 else if (scnidx == SHN_XINDEX)
1607 scnidx = xndx;
1608
1609+ if (scnidx >= shnum)
1610+ goto illformed;
1611+
1612 if (shdr_info[scnidx].idx == 0)
1613 /* This symbol table has a real symbol in
1614 a discarded section. So preserve the
1615@@ -849,12 +869,16 @@ handle_elf (int fd, Elf *elf, const char
1616 }
1617
1618 /* Handle references through sh_info. */
1619- if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)
1620- && shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0)
1621+ if (SH_INFO_LINK_P (&shdr_info[cnt].shdr))
1622+ {
1623+ if (shdr_info[cnt].shdr.sh_info >= shnum)
1624+ goto illformed;
1625+ else if ( shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0)
1626 {
1627 shdr_info[shdr_info[cnt].shdr.sh_info].idx = 1;
1628 changes |= shdr_info[cnt].shdr.sh_info < cnt;
1629 }
1630+ }
1631
1632 /* Mark the section as investigated. */
1633 shdr_info[cnt].idx = 2;
1634@@ -995,7 +1019,7 @@ handle_elf (int fd, Elf *elf, const char
1635 error (EXIT_FAILURE, 0, gettext ("while generating output file: %s"),
1636 elf_errmsg (-1));
1637
1638- assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
1639+ elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
1640
1641 /* Add this name to the section header string table. */
1642 shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0);
1643@@ -1032,7 +1056,7 @@ handle_elf (int fd, Elf *elf, const char
1644 error (EXIT_FAILURE, 0,
1645 gettext ("while create section header section: %s"),
1646 elf_errmsg (-1));
1647- assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
1648+ elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
1649
1650 shdr_info[cnt].data = elf_newdata (shdr_info[cnt].newscn);
1651 if (shdr_info[cnt].data == NULL)
1652@@ -1089,7 +1113,7 @@ handle_elf (int fd, Elf *elf, const char
1653 error (EXIT_FAILURE, 0,
1654 gettext ("while create section header section: %s"),
1655 elf_errmsg (-1));
1656- assert (elf_ndxscn (shdr_info[cnt].newscn) == idx);
1657+ elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == idx);
1658
1659 /* Finalize the string table and fill in the correct indices in the
1660 section headers. */
1661@@ -1179,20 +1203,20 @@ handle_elf (int fd, Elf *elf, const char
1662 shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
1663 NULL);
1664
1665- assert ((versiondata->d_size / sizeof (Elf32_Word))
1666+ elf_assert ((versiondata->d_size / sizeof (Elf32_Word))
1667 >= shdr_info[cnt].data->d_size / elsize);
1668 }
1669
1670 if (shdr_info[cnt].version_idx != 0)
1671 {
1672- assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM);
1673+ elf_assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM);
1674 /* This section has associated version
1675 information. We have to modify that
1676 information, too. */
1677 versiondata = elf_getdata (shdr_info[shdr_info[cnt].version_idx].scn,
1678 NULL);
1679
1680- assert ((versiondata->d_size / sizeof (GElf_Versym))
1681+ elf_assert ((versiondata->d_size / sizeof (GElf_Versym))
1682 >= shdr_info[cnt].data->d_size / elsize);
1683 }
1684
1685@@ -1247,7 +1271,7 @@ handle_elf (int fd, Elf *elf, const char
1686 sec = shdr_info[sym->st_shndx].idx;
1687 else
1688 {
1689- assert (shndxdata != NULL);
1690+ elf_assert (shndxdata != NULL);
1691
1692 sec = shdr_info[xshndx].idx;
1693 }
1694@@ -1268,7 +1292,7 @@ handle_elf (int fd, Elf *elf, const char
1695 nxshndx = sec;
1696 }
1697
1698- assert (sec < SHN_LORESERVE || shndxdata != NULL);
1699+ elf_assert (sec < SHN_LORESERVE || shndxdata != NULL);
1700
1701 if ((inner != destidx || nshndx != sym->st_shndx
1702 || (shndxdata != NULL && nxshndx != xshndx))
1703@@ -1295,9 +1319,11 @@ handle_elf (int fd, Elf *elf, const char
1704 {
1705 size_t sidx = (sym->st_shndx != SHN_XINDEX
1706 ? sym->st_shndx : xshndx);
1707- assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION
1708- || (shdr_info[sidx].shdr.sh_type == SHT_GROUP
1709- && shdr_info[sidx].shdr.sh_info == inner));
1710+ elf_assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION
1711+ || ((shdr_info[sidx].shdr.sh_type
1712+ == SHT_GROUP)
1713+ && (shdr_info[sidx].shdr.sh_info
1714+ == inner)));
1715 }
1716 }
1717
1718@@ -1485,11 +1511,11 @@ handle_elf (int fd, Elf *elf, const char
1719 {
1720 GElf_Sym sym_mem;
1721 GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem);
1722- assert (sym != NULL);
1723+ elf_assert (sym != NULL);
1724
1725 const char *name = elf_strptr (elf, strshndx,
1726 sym->st_name);
1727- assert (name != NULL);
1728+ elf_assert (name != NULL);
1729 size_t hidx = elf_hash (name) % nbucket;
1730
1731 if (bucket[hidx] == 0)
1732@@ -1508,8 +1534,8 @@ handle_elf (int fd, Elf *elf, const char
1733 else
1734 {
1735 /* Alpha and S390 64-bit use 64-bit SHT_HASH entries. */
1736- assert (shdr_info[cnt].shdr.sh_entsize
1737- == sizeof (Elf64_Xword));
1738+ elf_assert (shdr_info[cnt].shdr.sh_entsize
1739+ == sizeof (Elf64_Xword));
1740
1741 Elf64_Xword *bucket = (Elf64_Xword *) hashd->d_buf;
1742
1743@@ -1539,11 +1565,11 @@ handle_elf (int fd, Elf *elf, const char
1744 {
1745 GElf_Sym sym_mem;
1746 GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem);
1747- assert (sym != NULL);
1748+ elf_assert (sym != NULL);
1749
1750 const char *name = elf_strptr (elf, strshndx,
1751 sym->st_name);
1752- assert (name != NULL);
1753+ elf_assert (name != NULL);
1754 size_t hidx = elf_hash (name) % nbucket;
1755
1756 if (bucket[hidx] == 0)
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.158/scanf-format.patch b/meta/recipes-devtools/elfutils/elfutils-0.158/scanf-format.patch
deleted file mode 100644
index c08519cf53..0000000000
--- a/meta/recipes-devtools/elfutils/elfutils-0.158/scanf-format.patch
+++ /dev/null
@@ -1,40 +0,0 @@
1From: Kurt Roeckx <kurt@roeckx.be>
2Subject: Use %m[ instead of %a[ in scanf()
3
4%a was a gnu extention, but C99 made this a float. So it got
5changed to %m (supported by glibc 2.7), but %a[ and %as are
6still supported by glibc. The portability branch changed this
7from %m to %a again since that's supported by more versions of
8glibc. However gcc gives a warning about this using -Wformat
9and we have a new enough libc to use %m.
10
11Index: elfutils-0.153/src/addr2line.c
12===================================================================
13--- elfutils-0.153.orig/src/addr2line.c 2012-02-24 22:29:50.000000000 +0000
14+++ elfutils-0.153/src/addr2line.c 2012-02-24 22:29:52.000000000 +0000
15@@ -455,10 +455,10 @@
16 bool parsed = false;
17 int i, j;
18 char *name = NULL;
19- if (sscanf (string, "(%a[^)])%" PRIiMAX "%n", &name, &addr, &i) == 2
20+ if (sscanf (string, "(%m[^)])%" PRIiMAX "%n", &name, &addr, &i) == 2
21 && string[i] == '\0')
22 parsed = adjust_to_section (name, &addr, dwfl);
23- switch (sscanf (string, "%a[^-+]%n%" PRIiMAX "%n", &name, &i, &addr, &j))
24+ switch (sscanf (string, "%m[^-+]%n%" PRIiMAX "%n", &name, &i, &addr, &j))
25 {
26 default:
27 break;
28Index: elfutils-0.153/tests/line2addr.c
29===================================================================
30--- elfutils-0.153.orig/tests/line2addr.c 2012-02-24 22:29:50.000000000 +0000
31+++ elfutils-0.153/tests/line2addr.c 2012-02-24 22:29:52.000000000 +0000
32@@ -132,7 +132,7 @@
33 {
34 struct args a = { .arg = argv[cnt] };
35
36- switch (sscanf (a.arg, "%a[^:]:%d", &a.file, &a.line))
37+ switch (sscanf (a.arg, "%m[^:]:%d", &a.file, &a.line))
38 {
39 default:
40 case 0:
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.158/testsuite-ignore-elflint.diff b/meta/recipes-devtools/elfutils/elfutils-0.158/testsuite-ignore-elflint.diff
deleted file mode 100644
index eae5796de3..0000000000
--- a/meta/recipes-devtools/elfutils/elfutils-0.158/testsuite-ignore-elflint.diff
+++ /dev/null
@@ -1,39 +0,0 @@
1On many architectures this test fails because binaries/libs produced by
2binutils don't pass elflint. However elfutils shouldn't FTBFS because of this.
3
4So we run the tests on all archs to see what breaks, but if it breaks we ignore
5the result (exitcode 77 means: this test was skipped).
6
7Index: elfutils-0.156/tests/run-elflint-self.sh
8===================================================================
9--- elfutils-0.156.orig/tests/run-elflint-self.sh 2013-07-28 14:35:36.000000000 +0200
10+++ elfutils-0.156/tests/run-elflint-self.sh 2013-07-28 14:36:10.000000000 +0200
11@@ -18,4 +18,4 @@
12
13 . $srcdir/test-subr.sh
14
15-testrun_on_self ${abs_top_builddir}/src/elflint --quiet --gnu-ld
16+testrun_on_self_skip ${abs_top_builddir}/src/elflint --quiet --gnu-ld
17Index: elfutils-0.156/tests/test-subr.sh
18===================================================================
19--- elfutils-0.156.orig/tests/test-subr.sh 2013-07-28 14:35:36.000000000 +0200
20+++ elfutils-0.156/tests/test-subr.sh 2013-07-28 14:35:36.000000000 +0200
21@@ -149,3 +149,18 @@
22 # Only exit if something failed
23 if test $exit_status != 0; then exit $exit_status; fi
24 }
25+
26+# Same as testrun_on_self(), but skip on failure.
27+testrun_on_self_skip()
28+{
29+ exit_status=0
30+
31+ for file in $self_test_files; do
32+ testrun $* $file \
33+ || { echo "*** failure in $* $file"; exit_status=77; }
34+ done
35+
36+ # Only exit if something failed
37+ if test $exit_status != 0; then exit $exit_status; fi
38+}
39+
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.158/unwind_non_linux.patch b/meta/recipes-devtools/elfutils/elfutils-0.158/unwind_non_linux.patch
deleted file mode 100644
index 870ec23703..0000000000
--- a/meta/recipes-devtools/elfutils/elfutils-0.158/unwind_non_linux.patch
+++ /dev/null
@@ -1,256 +0,0 @@
1From 02cefdaa6429e620d6457fdb3ad9934f194c5a93 Mon Sep 17 00:00:00 2001
2From: Kurt Roeckx <kurt@roeckx.be>
3Date: Tue, 22 Apr 2014 21:46:22 +0200
4Subject: [PATCH] Unwinding is only supported on Linux
5
6Index: elfutils-0.158/backends/i386_initreg.c
7===================================================================
8--- elfutils-0.158.orig/backends/i386_initreg.c 2014-05-01 17:11:18.870616302 +0000
9+++ elfutils-0.158/backends/i386_initreg.c 2014-05-01 17:11:18.866616384 +0000
10@@ -44,7 +44,7 @@
11 ebl_tid_registers_t *setfunc __attribute__ ((unused)),
12 void *arg __attribute__ ((unused)))
13 {
14-#if !defined __i386__ && !defined __x86_64__
15+#if (!defined __i386__ && !defined __x86_64__) || !defined(__linux__)
16 return false;
17 #else /* __i386__ || __x86_64__ */
18 struct user_regs_struct user_regs;
19Index: elfutils-0.158/backends/x86_64_initreg.c
20===================================================================
21--- elfutils-0.158.orig/backends/x86_64_initreg.c 2014-05-01 17:11:18.870616302 +0000
22+++ elfutils-0.158/backends/x86_64_initreg.c 2014-05-01 17:11:18.866616384 +0000
23@@ -44,7 +44,7 @@
24 ebl_tid_registers_t *setfunc __attribute__ ((unused)),
25 void *arg __attribute__ ((unused)))
26 {
27-#ifndef __x86_64__
28+#if !defined(__x86_64__) || !defined(__linux__)
29 return false;
30 #else /* __x86_64__ */
31 struct user_regs_struct user_regs;
32Index: elfutils-0.158/libdwfl/linux-pid-attach.c
33===================================================================
34--- elfutils-0.158.orig/libdwfl/linux-pid-attach.c 2014-05-01 17:11:18.870616302 +0000
35+++ elfutils-0.158/libdwfl/linux-pid-attach.c 2014-05-01 17:12:47.980766442 +0000
36@@ -37,6 +37,8 @@
37 # define MAX(a, b) ((a) > (b) ? (a) : (b))
38 #endif
39
40+#ifdef __linux__
41+
42 struct pid_arg
43 {
44 DIR *dir;
45@@ -358,3 +360,87 @@
46 return 0;
47 }
48 INTDEF (dwfl_linux_proc_attach)
49+
50+#else /* __linux__ */
51+
52+static pid_t
53+pid_next_thread (Dwfl *dwfl __attribute__ ((unused)),
54+ void *dwfl_arg __attribute__ ((unused)),
55+ void **thread_argp __attribute__ ((unused)))
56+{
57+ errno = ENOSYS;
58+ __libdwfl_seterrno (DWFL_E_ERRNO);
59+ return -1;
60+}
61+
62+static bool
63+pid_getthread (Dwfl *dwfl __attribute__ ((unused)),
64+ pid_t tid __attribute__ ((unused)),
65+ void *dwfl_arg __attribute__ ((unused)),
66+ void **thread_argp __attribute__ ((unused)))
67+{
68+ errno = ENOSYS;
69+ __libdwfl_seterrno (DWFL_E_ERRNO);
70+ return false;
71+}
72+
73+static bool
74+pid_memory_read (Dwfl *dwfl __attribute__ ((unused)),
75+ Dwarf_Addr addr __attribute__ ((unused)),
76+ Dwarf_Word *result __attribute__ ((unused)),
77+ void *arg __attribute__ ((unused)))
78+{
79+ errno = ENOSYS;
80+ __libdwfl_seterrno (DWFL_E_ERRNO);
81+ return false;
82+}
83+
84+static bool
85+pid_set_initial_registers (Dwfl_Thread *thread __attribute__ ((unused)),
86+ void *thread_arg __attribute__ ((unused)))
87+{
88+ errno = ENOSYS;
89+ __libdwfl_seterrno (DWFL_E_ERRNO);
90+ return false;
91+}
92+
93+static void
94+pid_detach (Dwfl *dwfl __attribute__ ((unused)),
95+ void *dwfl_arg __attribute__ ((unused)))
96+{
97+}
98+
99+static void
100+pid_thread_detach (Dwfl_Thread *thread __attribute__ ((unused)),
101+ void *thread_arg __attribute__ ((unused)))
102+{
103+}
104+
105+static const Dwfl_Thread_Callbacks pid_thread_callbacks =
106+{
107+ pid_next_thread,
108+ pid_getthread,
109+ pid_memory_read,
110+ pid_set_initial_registers,
111+ pid_detach,
112+ pid_thread_detach,
113+};
114+
115+int
116+dwfl_linux_proc_attach (Dwfl *dwfl __attribute__ ((unused)),
117+ pid_t pid __attribute__ ((unused)),
118+ bool assume_ptrace_stopped __attribute__ ((unused)))
119+{
120+ return ENOSYS;
121+}
122+INTDEF (dwfl_linux_proc_attach)
123+
124+struct __libdwfl_pid_arg *
125+internal_function
126+__libdwfl_get_pid_arg (Dwfl *dwfl __attribute__ ((unused)))
127+{
128+ return NULL;
129+}
130+
131+#endif /* ! __linux __ */
132+
133Index: elfutils-0.158/tests/backtrace-child.c
134===================================================================
135--- elfutils-0.158.orig/tests/backtrace-child.c 2014-05-01 17:11:18.870616302 +0000
136+++ elfutils-0.158/tests/backtrace-child.c 2014-05-01 17:11:18.866616384 +0000
137@@ -79,6 +79,18 @@
138 #include <stdio.h>
139 #include <unistd.h>
140
141+#ifndef __linux__
142+
143+int
144+main (int argc __attribute__ ((unused)), char **argv)
145+{
146+ fprintf (stderr, "%s: Unwinding not supported for this architecture\n",
147+ argv[0]);
148+ return 77;
149+}
150+
151+#else /* __linux__ */
152+
153 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
154 #define NOINLINE_NOCLONE __attribute__ ((noinline, noclone))
155 #else
156@@ -221,3 +233,6 @@
157 /* Not reached. */
158 abort ();
159 }
160+
161+#endif /* ! __linux__ */
162+
163Index: elfutils-0.158/tests/backtrace-data.c
164===================================================================
165--- elfutils-0.158.orig/tests/backtrace-data.c 2014-05-01 17:11:18.870616302 +0000
166+++ elfutils-0.158/tests/backtrace-data.c 2014-05-01 17:11:18.866616384 +0000
167@@ -40,7 +40,7 @@
168 #include <string.h>
169 #include ELFUTILS_HEADER(dwfl)
170
171-#ifndef __x86_64__
172+#if !defined(__x86_64__) || !defined(__linux__)
173
174 int
175 main (int argc __attribute__ ((unused)), char **argv)
176@@ -50,7 +50,7 @@
177 return 77;
178 }
179
180-#else /* __x86_64__ */
181+#else /* __x86_64__ && __linux__ */
182
183 /* The only arch specific code is set_initial_registers. */
184
185Index: elfutils-0.158/tests/backtrace-dwarf.c
186===================================================================
187--- elfutils-0.158.orig/tests/backtrace-dwarf.c 2014-05-01 17:11:18.870616302 +0000
188+++ elfutils-0.158/tests/backtrace-dwarf.c 2014-05-01 17:11:18.866616384 +0000
189@@ -25,6 +25,18 @@
190 #include <sys/ptrace.h>
191 #include ELFUTILS_HEADER(dwfl)
192
193+#ifndef __linux__
194+
195+int
196+main (int argc __attribute__ ((unused)), char **argv)
197+{
198+ fprintf (stderr, "%s: Unwinding not supported for this architecture\n",
199+ argv[0]);
200+ return 77;
201+}
202+
203+#else /* __linux__ */
204+
205 static void cleanup_13_abort (void);
206 #define main cleanup_13_main
207 #include "cleanup-13.c"
208@@ -148,3 +160,6 @@
209 /* There is an exit (0) call if we find the "main" frame, */
210 error (1, 0, "dwfl_getthreads: %s", dwfl_errmsg (-1));
211 }
212+
213+#endif /* ! __linux__ */
214+
215Index: elfutils-0.158/tests/backtrace-subr.sh
216===================================================================
217--- elfutils-0.158.orig/tests/backtrace-subr.sh 2014-05-01 17:11:18.870616302 +0000
218+++ elfutils-0.158/tests/backtrace-subr.sh 2014-05-01 17:11:18.866616384 +0000
219@@ -84,6 +84,7 @@
220 echo ./backtrace ./backtrace.$arch.{exec,core}
221 testrun ${abs_builddir}/backtrace -e ./backtrace.$arch.exec --core=./backtrace.$arch.core 1>backtrace.$arch.bt 2>backtrace.$arch.err || true
222 cat backtrace.$arch.{bt,err}
223+ check_unsupported backtrace.$arch.err backtrace.$arch.core
224 check_all backtrace.$arch.{bt,err} backtrace.$arch.core
225 }
226
227Index: elfutils-0.158/tests/backtrace.c
228===================================================================
229--- elfutils-0.158.orig/tests/backtrace.c 2014-05-01 17:11:18.870616302 +0000
230+++ elfutils-0.158/tests/backtrace.c 2014-05-01 17:11:18.866616384 +0000
231@@ -39,6 +39,18 @@
232 #include <sys/syscall.h>
233 #include ELFUTILS_HEADER(dwfl)
234
235+#ifndef __linux__
236+
237+int
238+main (int argc __attribute__ ((unused)), char **argv)
239+{
240+ fprintf (stderr, "%s: Unwinding not supported for this architecture\n",
241+ argv[0]);
242+ return 77;
243+}
244+
245+#else /* __linux__ */
246+
247 static int
248 dump_modules (Dwfl_Module *mod, void **userdata __attribute__ ((unused)),
249 const char *name, Dwarf_Addr start,
250@@ -452,3 +464,6 @@
251 dwfl_end (dwfl);
252 return 0;
253 }
254+
255+#endif /* ! __linux__ */
256+