summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/elfutils/elfutils-0.148
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/elfutils/elfutils-0.148')
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.148/arm_backend.diff449
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.148/elf_additions.diff71
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.148/elfutils-ar-c-fix-num-passed-to-memset.patch23
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.148/elfutils-fsize.patch39
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.148/fix-build-gcc-4.8.patch57
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.148/fix_for_gcc-4.7.patch73
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.148/hppa_backend.diff801
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.148/m68k_backend.diff309
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.148/mips_backend.diff713
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.148/nm-Fix-size-passed-to-snprintf-for-invalid-sh_name-case.patch27
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.148/redhat-portability.diff756
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.148/redhat-robustify.diff1709
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.148/remove-unused.patch154
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.148/testsuite-ignore-elflint.diff21
14 files changed, 5202 insertions, 0 deletions
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.148/arm_backend.diff b/meta/recipes-devtools/elfutils/elfutils-0.148/arm_backend.diff
new file mode 100644
index 0000000000..d4e4675ad5
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/elfutils-0.148/arm_backend.diff
@@ -0,0 +1,449 @@
1Upstream-Status: Backport
2
3Index: elfutils-0.146/backends/arm_init.c
4===================================================================
5--- elfutils-0.146.orig/backends/arm_init.c 2009-04-21 14:50:01.000000000 +0000
6+++ elfutils-0.146/backends/arm_init.c 2010-04-24 10:11:13.000000000 +0000
7@@ -32,21 +32,32 @@
8 #define RELOC_PREFIX R_ARM_
9 #include "libebl_CPU.h"
10
11+#include "libebl_arm.h"
12+
13 /* This defines the common reloc hooks based on arm_reloc.def. */
14 #include "common-reloc.c"
15
16
17 const char *
18 arm_init (elf, machine, eh, ehlen)
19- Elf *elf __attribute__ ((unused));
20+ Elf *elf;
21 GElf_Half machine __attribute__ ((unused));
22 Ebl *eh;
23 size_t ehlen;
24 {
25+ int soft_float = 0;
26+
27 /* Check whether the Elf_BH object has a sufficent size. */
28 if (ehlen < sizeof (Ebl))
29 return NULL;
30
31+ if (elf) {
32+ GElf_Ehdr ehdr_mem;
33+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
34+ if (ehdr && (ehdr->e_flags & EF_ARM_SOFT_FLOAT))
35+ soft_float = 1;
36+ }
37+
38 /* We handle it. */
39 eh->name = "ARM";
40 arm_init_reloc (eh);
41@@ -58,7 +69,10 @@
42 HOOK (eh, core_note);
43 HOOK (eh, auxv_info);
44 HOOK (eh, check_object_attribute);
45- HOOK (eh, return_value_location);
46+ if (soft_float)
47+ eh->return_value_location = arm_return_value_location_soft;
48+ else
49+ eh->return_value_location = arm_return_value_location_hard;
50
51 return MODVERSION;
52 }
53Index: elfutils-0.146/backends/arm_regs.c
54===================================================================
55--- elfutils-0.146.orig/backends/arm_regs.c 2009-04-21 14:50:01.000000000 +0000
56+++ elfutils-0.146/backends/arm_regs.c 2010-04-24 10:11:13.000000000 +0000
57@@ -28,6 +28,7 @@
58 #endif
59
60 #include <string.h>
61+#include <stdio.h>
62 #include <dwarf.h>
63
64 #define BACKEND arm_
65@@ -58,7 +59,15 @@
66 namelen = 2;
67 break;
68
69- case 10 ... 12:
70+ case 10 ... 11:
71+ name[0] = 'r';
72+ name[1] = '1';
73+ name[2] = regno % 10 + '0';
74+ namelen = 3;
75+ break;
76+
77+ case 12:
78+ *type = DW_ATE_unsigned;
79 name[0] = 'r';
80 name[1] = '1';
81 name[2] = regno % 10 + '0';
82@@ -73,6 +82,9 @@
83 break;
84
85 case 16 + 0 ... 16 + 7:
86+ /* AADWARF says that there are no registers in that range,
87+ * but gcc maps FPA registers here
88+ */
89 regno += 96 - 16;
90 /* Fall through. */
91 case 96 + 0 ... 96 + 7:
92@@ -84,11 +96,139 @@
93 namelen = 2;
94 break;
95
96+ case 64 + 0 ... 64 + 9:
97+ *setname = "VFP";
98+ *bits = 32;
99+ *type = DW_ATE_float;
100+ name[0] = 's';
101+ name[1] = regno - 64 + '0';
102+ namelen = 2;
103+ break;
104+
105+ case 64 + 10 ... 64 + 31:
106+ *setname = "VFP";
107+ *bits = 32;
108+ *type = DW_ATE_float;
109+ name[0] = 's';
110+ name[1] = (regno - 64) / 10 + '0';
111+ name[2] = (regno - 64) % 10 + '0';
112+ namelen = 3;
113+ break;
114+
115+ case 104 + 0 ... 104 + 7:
116+ /* XXX TODO:
117+ * This can be either intel wireless MMX general purpose/control
118+ * registers or xscale accumulator, which have different usage.
119+ * We only have the intel wireless MMX here now.
120+ * The name needs to be changed for the xscale accumulator too. */
121+ *setname = "MMX";
122+ *type = DW_ATE_unsigned;
123+ *bits = 32;
124+ memcpy(name, "wcgr", 4);
125+ name[4] = regno - 104 + '0';
126+ namelen = 5;
127+ break;
128+
129+ case 112 + 0 ... 112 + 9:
130+ *setname = "MMX";
131+ *type = DW_ATE_unsigned;
132+ *bits = 64;
133+ name[0] = 'w';
134+ name[1] = 'r';
135+ name[2] = regno - 112 + '0';
136+ namelen = 3;
137+ break;
138+
139+ case 112 + 10 ... 112 + 15:
140+ *setname = "MMX";
141+ *type = DW_ATE_unsigned;
142+ *bits = 64;
143+ name[0] = 'w';
144+ name[1] = 'r';
145+ name[2] = '1';
146+ name[3] = regno - 112 - 10 + '0';
147+ namelen = 4;
148+ break;
149+
150 case 128:
151+ *setname = "special";
152 *type = DW_ATE_unsigned;
153 return stpcpy (name, "spsr") + 1 - name;
154
155+ case 129:
156+ *setname = "special";
157+ *type = DW_ATE_unsigned;
158+ return stpcpy(name, "spsr_fiq") + 1 - name;
159+
160+ case 130:
161+ *setname = "special";
162+ *type = DW_ATE_unsigned;
163+ return stpcpy(name, "spsr_irq") + 1 - name;
164+
165+ case 131:
166+ *setname = "special";
167+ *type = DW_ATE_unsigned;
168+ return stpcpy(name, "spsr_abt") + 1 - name;
169+
170+ case 132:
171+ *setname = "special";
172+ *type = DW_ATE_unsigned;
173+ return stpcpy(name, "spsr_und") + 1 - name;
174+
175+ case 133:
176+ *setname = "special";
177+ *type = DW_ATE_unsigned;
178+ return stpcpy(name, "spsr_svc") + 1 - name;
179+
180+ case 144 ... 150:
181+ *setname = "integer";
182+ *type = DW_ATE_signed;
183+ *bits = 32;
184+ return sprintf(name, "r%d_usr", regno - 144 + 8) + 1;
185+
186+ case 151 ... 157:
187+ *setname = "integer";
188+ *type = DW_ATE_signed;
189+ *bits = 32;
190+ return sprintf(name, "r%d_fiq", regno - 151 + 8) + 1;
191+
192+ case 158 ... 159:
193+ *setname = "integer";
194+ *type = DW_ATE_signed;
195+ *bits = 32;
196+ return sprintf(name, "r%d_irq", regno - 158 + 13) + 1;
197+
198+ case 160 ... 161:
199+ *setname = "integer";
200+ *type = DW_ATE_signed;
201+ *bits = 32;
202+ return sprintf(name, "r%d_abt", regno - 160 + 13) + 1;
203+
204+ case 162 ... 163:
205+ *setname = "integer";
206+ *type = DW_ATE_signed;
207+ *bits = 32;
208+ return sprintf(name, "r%d_und", regno - 162 + 13) + 1;
209+
210+ case 164 ... 165:
211+ *setname = "integer";
212+ *type = DW_ATE_signed;
213+ *bits = 32;
214+ return sprintf(name, "r%d_svc", regno - 164 + 13) + 1;
215+
216+ case 192 ... 199:
217+ *setname = "MMX";
218+ *bits = 32;
219+ *type = DW_ATE_unsigned;
220+ name[0] = 'w';
221+ name[1] = 'c';
222+ name[2] = regno - 192 + '0';
223+ namelen = 3;
224+ break;
225+
226 case 256 + 0 ... 256 + 9:
227+ /* XXX TODO: Neon also uses those registers and can contain
228+ * both float and integers */
229 *setname = "VFP";
230 *type = DW_ATE_float;
231 *bits = 64;
232Index: elfutils-0.146/backends/arm_retval.c
233===================================================================
234--- elfutils-0.146.orig/backends/arm_retval.c 2010-01-12 16:57:54.000000000 +0000
235+++ elfutils-0.146/backends/arm_retval.c 2010-04-24 10:11:13.000000000 +0000
236@@ -45,6 +45,13 @@
237 #define nloc_intreg 1
238 #define nloc_intregs(n) (2 * (n))
239
240+/* f1 */ /* XXX TODO: f0 can also have number 96 if program was compiled with -mabi=aapcs */
241+static const Dwarf_Op loc_fpreg[] =
242+ {
243+ { .atom = DW_OP_reg16 },
244+ };
245+#define nloc_fpreg 1
246+
247 /* The return value is a structure and is actually stored in stack space
248 passed in a hidden argument by the caller. But, the compiler
249 helpfully returns the address of that space in r0. */
250@@ -55,8 +62,9 @@
251 #define nloc_aggregate 1
252
253
254-int
255-arm_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
256+static int
257+arm_return_value_location_ (Dwarf_Die *functypedie, const Dwarf_Op **locp,
258+ int soft_float)
259 {
260 /* Start with the function's type, and get the DW_AT_type attribute,
261 which is the type of the return value. */
262@@ -109,14 +117,31 @@
263 else
264 return -1;
265 }
266+ if (tag == DW_TAG_base_type)
267+ {
268+ Dwarf_Word encoding;
269+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
270+ &attr_mem), &encoding) != 0)
271+ return -1;
272+
273+ if ((encoding == DW_ATE_float) && !soft_float)
274+ {
275+ *locp = loc_fpreg;
276+ if (size <= 8)
277+ return nloc_fpreg;
278+ goto aggregate;
279+ }
280+ }
281 if (size <= 16)
282 {
283 intreg:
284 *locp = loc_intreg;
285 return size <= 4 ? nloc_intreg : nloc_intregs ((size + 3) / 4);
286 }
287+ /* fall through. */
288
289 aggregate:
290+ /* XXX TODO sometimes aggregates are returned in r0 (-mabi=aapcs) */
291 *locp = loc_aggregate;
292 return nloc_aggregate;
293
294@@ -135,3 +160,18 @@
295 DWARF and might be valid. */
296 return -2;
297 }
298+
299+/* return location for -mabi=apcs-gnu -msoft-float */
300+int
301+arm_return_value_location_soft (Dwarf_Die *functypedie, const Dwarf_Op **locp)
302+{
303+ return arm_return_value_location_ (functypedie, locp, 1);
304+}
305+
306+/* return location for -mabi=apcs-gnu -mhard-float (current default) */
307+int
308+arm_return_value_location_hard (Dwarf_Die *functypedie, const Dwarf_Op **locp)
309+{
310+ return arm_return_value_location_ (functypedie, locp, 0);
311+}
312+
313Index: elfutils-0.146/libelf/elf.h
314===================================================================
315--- elfutils-0.146.orig/libelf/elf.h 2010-04-24 10:11:11.000000000 +0000
316+++ elfutils-0.146/libelf/elf.h 2010-04-24 10:11:13.000000000 +0000
317@@ -2290,6 +2290,9 @@
318 #define EF_ARM_EABI_VER4 0x04000000
319 #define EF_ARM_EABI_VER5 0x05000000
320
321+/* EI_OSABI values */
322+#define ELFOSABI_ARM_AEABI 64 /* Contains symbol versioning. */
323+
324 /* Additional symbol types for Thumb. */
325 #define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */
326 #define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */
327@@ -2307,12 +2310,19 @@
328
329 /* Processor specific values for the Phdr p_type field. */
330 #define PT_ARM_EXIDX (PT_LOPROC + 1) /* ARM unwind segment. */
331+#define PT_ARM_UNWIND PT_ARM_EXIDX
332
333 /* Processor specific values for the Shdr sh_type field. */
334 #define SHT_ARM_EXIDX (SHT_LOPROC + 1) /* ARM unwind section. */
335 #define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) /* Preemption details. */
336 #define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) /* ARM attributes section. */
337
338+/* Processor specific values for the Dyn d_tag field. */
339+#define DT_ARM_RESERVED1 (DT_LOPROC + 0)
340+#define DT_ARM_SYMTABSZ (DT_LOPROC + 1)
341+#define DT_ARM_PREEMTMAB (DT_LOPROC + 2)
342+#define DT_ARM_RESERVED2 (DT_LOPROC + 3)
343+#define DT_ARM_NUM 4
344
345 /* ARM relocs. */
346
347@@ -2344,12 +2354,75 @@
348 #define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */
349 #define R_ARM_GOT32 26 /* 32 bit GOT entry */
350 #define R_ARM_PLT32 27 /* 32 bit PLT address */
351+#define R_ARM_CALL 28
352+#define R_ARM_JUMP24 29
353+#define R_ARM_THM_JUMP24 30
354+#define R_ARM_BASE_ABS 31
355 #define R_ARM_ALU_PCREL_7_0 32
356 #define R_ARM_ALU_PCREL_15_8 33
357 #define R_ARM_ALU_PCREL_23_15 34
358 #define R_ARM_LDR_SBREL_11_0 35
359 #define R_ARM_ALU_SBREL_19_12 36
360 #define R_ARM_ALU_SBREL_27_20 37
361+#define R_ARM_TARGET1 38
362+#define R_ARM_SBREL31 39
363+#define R_ARM_V4BX 40
364+#define R_ARM_TARGET2 41
365+#define R_ARM_PREL31 42
366+#define R_ARM_MOVW_ABS_NC 43
367+#define R_ARM_MOVT_ABS 44
368+#define R_ARM_MOVW_PREL_NC 45
369+#define R_ARM_MOVT_PREL 46
370+#define R_ARM_THM_MOVW_ABS_NC 47
371+#define R_ARM_THM_MOVT_ABS 48
372+#define R_ARM_THM_MOVW_PREL_NC 49
373+#define R_ARM_THM_MOVT_PREL 50
374+#define R_ARM_THM_JUMP19 51
375+#define R_ARM_THM_JUMP6 52
376+#define R_ARM_THM_ALU_PREL_11_0 53
377+#define R_ARM_THM_PC12 54
378+#define R_ARM_ABS32_NOI 55
379+#define R_ARM_REL32_NOI 56
380+#define R_ARM_ALU_PC_G0_NC 57
381+#define R_ARM_ALU_PC_G0 58
382+#define R_ARM_ALU_PC_G1_NC 59
383+#define R_ARM_ALU_PC_G1 60
384+#define R_ARM_ALU_PC_G2 61
385+#define R_ARM_LDR_PC_G1 62
386+#define R_ARM_LDR_PC_G2 63
387+#define R_ARM_LDRS_PC_G0 64
388+#define R_ARM_LDRS_PC_G1 65
389+#define R_ARM_LDRS_PC_G2 66
390+#define R_ARM_LDC_PC_G0 67
391+#define R_ARM_LDC_PC_G1 68
392+#define R_ARM_LDC_PC_G2 69
393+#define R_ARM_ALU_SB_G0_NC 70
394+#define R_ARM_ALU_SB_G0 71
395+#define R_ARM_ALU_SB_G1_NC 72
396+#define R_ARM_ALU_SB_G1 73
397+#define R_ARM_ALU_SB_G2 74
398+#define R_ARM_LDR_SB_G0 75
399+#define R_ARM_LDR_SB_G1 76
400+#define R_ARM_LDR_SB_G2 77
401+#define R_ARM_LDRS_SB_G0 78
402+#define R_ARM_LDRS_SB_G1 79
403+#define R_ARM_LDRS_SB_G2 80
404+#define R_ARM_LDC_G0 81
405+#define R_ARM_LDC_G1 82
406+#define R_ARM_LDC_G2 83
407+#define R_ARM_MOVW_BREL_NC 84
408+#define R_ARM_MOVT_BREL 85
409+#define R_ARM_MOVW_BREL 86
410+#define R_ARM_THM_MOVW_BREL_NC 87
411+#define R_ARM_THM_MOVT_BREL 88
412+#define R_ARM_THM_MOVW_BREL 89
413+/* 90-93 unallocated */
414+#define R_ARM_PLT32_ABS 94
415+#define R_ARM_GOT_ABS 95
416+#define R_ARM_GOT_PREL 96
417+#define R_ARM_GOT_BREL12 97
418+#define R_ARM_GOTOFF12 98
419+#define R_ARM_GOTRELAX 99
420 #define R_ARM_GNU_VTENTRY 100
421 #define R_ARM_GNU_VTINHERIT 101
422 #define R_ARM_THM_PC11 102 /* thumb unconditional branch */
423@@ -2364,6 +2437,12 @@
424 static TLS block offset */
425 #define R_ARM_TLS_LE32 108 /* 32 bit offset relative to static
426 TLS block */
427+#define R_ARM_TLS_LDO12 109
428+#define R_ARM_TLS_LE12 110
429+#define R_ARM_TLS_IE12GP 111
430+/* 112 - 127 private range */
431+#define R_ARM_ME_TOO 128 /* obsolete */
432+
433 #define R_ARM_RXPC25 249
434 #define R_ARM_RSBREL32 250
435 #define R_ARM_THM_RPC22 251
436Index: elfutils-0.146/backends/libebl_arm.h
437===================================================================
438--- /dev/null 1970-01-01 00:00:00.000000000 +0000
439+++ elfutils-0.146/backends/libebl_arm.h 2010-04-24 10:11:13.000000000 +0000
440@@ -0,0 +1,9 @@
441+#ifndef _LIBEBL_ARM_H
442+#define _LIBEBL_ARM_H 1
443+
444+#include <libdw.h>
445+
446+extern int arm_return_value_location_soft(Dwarf_Die *, const Dwarf_Op **locp);
447+extern int arm_return_value_location_hard(Dwarf_Die *, const Dwarf_Op **locp);
448+
449+#endif
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.148/elf_additions.diff b/meta/recipes-devtools/elfutils/elfutils-0.148/elf_additions.diff
new file mode 100644
index 0000000000..5baa709000
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/elfutils-0.148/elf_additions.diff
@@ -0,0 +1,71 @@
1Upstream-Status: Backport
2
3Index: elfutils-0.146/libelf/elf.h
4===================================================================
5--- elfutils-0.146.orig/libelf/elf.h 2010-04-24 10:13:50.000000000 +0000
6+++ elfutils-0.146/libelf/elf.h 2010-04-24 10:22:43.000000000 +0000
7@@ -143,6 +143,7 @@
8 #define ELFOSABI_HPUX 1 /* HP-UX */
9 #define ELFOSABI_NETBSD 2 /* NetBSD. */
10 #define ELFOSABI_LINUX 3 /* Linux. */
11+#define ELFOSABI_HURD 4 /* GNU/Hurd */
12 #define ELFOSABI_SOLARIS 6 /* Sun Solaris. */
13 #define ELFOSABI_AIX 7 /* IBM AIX. */
14 #define ELFOSABI_IRIX 8 /* SGI Irix. */
15@@ -150,8 +151,13 @@
16 #define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */
17 #define ELFOSABI_MODESTO 11 /* Novell Modesto. */
18 #define ELFOSABI_OPENBSD 12 /* OpenBSD. */
19+#define ELFOSABI_OPENVMS 13 /* OpenVMS */
20+#define ELFOSABI_NSK 14 /* Hewlett-Packard Non-Stop Kernel */
21+#define ELFOSABI_AROS 15 /* Amiga Research OS */
22+/* 64-255 Architecture-specific value range */
23 #define ELFOSABI_ARM_AEABI 64 /* ARM EABI */
24 #define ELFOSABI_ARM 97 /* ARM */
25+/* This is deprecated? It's not in the latest version anymore. */
26 #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
27
28 #define EI_ABIVERSION 8 /* ABI version */
29@@ -206,7 +212,7 @@
30 #define EM_H8_300H 47 /* Hitachi H8/300H */
31 #define EM_H8S 48 /* Hitachi H8S */
32 #define EM_H8_500 49 /* Hitachi H8/500 */
33-#define EM_IA_64 50 /* Intel Merced */
34+#define EM_IA_64 50 /* Intel IA64 */
35 #define EM_MIPS_X 51 /* Stanford MIPS-X */
36 #define EM_COLDFIRE 52 /* Motorola Coldfire */
37 #define EM_68HC12 53 /* Motorola M68HC12 */
38@@ -220,7 +226,8 @@
39 #define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
40 #define EM_X86_64 62 /* AMD x86-64 architecture */
41 #define EM_PDSP 63 /* Sony DSP Processor */
42-
43+#define EM_PDP10 64 /* Digital Equipment Corp. PDP-10 */
44+#define EM_PDP11 65 /* Digital Equipment Corp. PDP-11 */
45 #define EM_FX66 66 /* Siemens FX66 microcontroller */
46 #define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
47 #define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
48@@ -250,7 +257,22 @@
49 #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
50 #define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
51 #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
52-#define EM_NUM 95
53+#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */
54+#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Processor */
55+#define EM_NS32K 97 /* National Semiconductor 32000 series */
56+#define EM_TPC 98 /* Tenor Network TPC processor */
57+#define EM_SNP1K 99 /* Trebia SNP 1000 processor */
58+#define EM_ST200 100 /* STMicroelectronics (www.st.com) ST200 microcontroller */
59+#define EM_IP2K 101 /* Ubicom IP2XXX microcontroller family */
60+#define EM_MAX 102 /* MAX Processor */
61+#define EM_CR 103 /* National Semiconductor CompactRISC */
62+#define EM_F2MC16 104 /* Fujitsu F2MC16 */
63+#define EM_MSP430 105 /* TI msp430 micro controller */
64+#define EM_BLACKFIN 106 /* Analog Devices Blackfin (DSP) processor */
65+#define EM_SE_C33 107 /* S1C33 Family of Seiko Epson processors */
66+#define EM_SEP 108 /* Sharp embedded microprocessor */
67+#define EM_ARCA 109 /* Arca RISC Microprocessor */
68+#define EM_NUM 110
69
70 /* If it is necessary to assign new unofficial EM_* values, please
71 pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.148/elfutils-ar-c-fix-num-passed-to-memset.patch b/meta/recipes-devtools/elfutils/elfutils-0.148/elfutils-ar-c-fix-num-passed-to-memset.patch
new file mode 100644
index 0000000000..b619619ec0
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/elfutils-0.148/elfutils-ar-c-fix-num-passed-to-memset.patch
@@ -0,0 +1,23 @@
1Upstream-Status: Backport
2
3ar.c (do_oper_delete): Fix num passed to memset
4native build failed as following on Fedora18+:
5ar.c: In function 'do_oper_delete':
6ar.c:918:31: error: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess]
7 memset (found, '\0', sizeof (found));
8 ^
9The original commit is http://git.fedorahosted.org/cgit/elfutils.git/commit/src/ar.c?id=1a4d0668d18bf1090c5c08cdb5cb3ba2b8eb5410
10
11Signed-off-by: Zhenhua Luo <zhenhua.luo@freescale.com>
12
13--- elfutils-0.148/src/ar.c.org 2013-03-12 21:12:17.928281375 -0500
14+++ elfutils-0.148/src/ar.c 2013-03-12 21:15:30.053285271 -0500
15@@ -915,7 +915,7 @@
16 long int instance)
17 {
18 bool *found = alloca (sizeof (bool) * argc);
19- memset (found, '\0', sizeof (found));
20+ memset (found, '\0', sizeof (bool) * argc);
21
22 /* List of the files we keep. */
23 struct armem *to_copy = NULL;
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.148/elfutils-fsize.patch b/meta/recipes-devtools/elfutils/elfutils-0.148/elfutils-fsize.patch
new file mode 100644
index 0000000000..0ff353d0de
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/elfutils-0.148/elfutils-fsize.patch
@@ -0,0 +1,39 @@
1Upstream-Status: Backport
2
3The ELF_T_LIB and ELF_T_GNUHASH sizes were missing from fsize table.
4
5This could cause a failure in the elf*_xlatetof function.
6
7diff -ur elfutils-0.148.orig/libelf/exttypes.h elfutils-0.148/libelf/exttypes.h
8--- elfutils-0.148.orig/libelf/exttypes.h 2009-01-08 12:56:37.000000000 -0800
9+++ elfutils-0.148/libelf/exttypes.h 2010-08-18 14:00:33.000000000 -0700
10@@ -94,6 +94,7 @@
11 Vernaux32 (Ext_);
12 Syminfo32 (Ext_);
13 Move32 (Ext_);
14+Lib32 (Ext_);
15 auxv_t32 (Ext_);
16
17 Ehdr64 (Ext_);
18@@ -110,6 +111,7 @@
19 Vernaux64 (Ext_);
20 Syminfo64 (Ext_);
21 Move64 (Ext_);
22+Lib64 (Ext_);
23 auxv_t64 (Ext_);
24
25 #undef START
26diff -ur elfutils-0.148.orig/libelf/gelf_fsize.c elfutils-0.148/libelf/gelf_fsize.c
27--- elfutils-0.148.orig/libelf/gelf_fsize.c 2009-01-08 12:56:37.000000000 -0800
28+++ elfutils-0.148/libelf/gelf_fsize.c 2010-08-18 14:11:57.000000000 -0700
29@@ -87,7 +87,9 @@
30 [ELF_T_NHDR] = sizeof (ElfW2(LIBELFBITS, Ext_Nhdr)), \
31 [ELF_T_SYMINFO] = sizeof (ElfW2(LIBELFBITS, Ext_Syminfo)), \
32 [ELF_T_MOVE] = sizeof (ElfW2(LIBELFBITS, Ext_Move)), \
33- [ELF_T_AUXV] = sizeof (ElfW2(LIBELFBITS, Ext_auxv_t))
34+ [ELF_T_LIB] = sizeof (ElfW2(LIBELFBITS, Ext_Lib)), \
35+ [ELF_T_AUXV] = sizeof (ElfW2(LIBELFBITS, Ext_auxv_t)), \
36+ [ELF_T_GNUHASH] = ELFW2(LIBELFBITS, FSZ_WORD)
37 TYPE_SIZES (32)
38 },
39 [ELFCLASS64 - 1] = {
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.148/fix-build-gcc-4.8.patch b/meta/recipes-devtools/elfutils/elfutils-0.148/fix-build-gcc-4.8.patch
new file mode 100644
index 0000000000..0e28690207
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/elfutils-0.148/fix-build-gcc-4.8.patch
@@ -0,0 +1,57 @@
1This patch fixes a warning seen with gcc 4.8 (especially on ubuntu 13.10)
2
3| addr2line.c: In function 'handle_address':
4| addr2line.c:450:7: error: format '%a' expects argument of type 'float *', but argument 3 has type 'char **' [-Werror=format=]
5| if (sscanf (string, "(%a[^)])%" PRIiMAX "%n", &name, &addr, &i) == 2
6| ^
7| addr2line.c:453:7: error: format '%a' expects argument of type 'float *', but argument 3 has type 'char **' [-Werror=format=]
8| switch (sscanf (string, "%a[^-+]%n%" PRIiMAX "%n", &name, &i, &addr, &j))
9| ^
10| cc1: all warnings being treated as errors
11
12
13%a is old GNU style and should be abandoned in favor of %m
14
15Also see
16
17http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54361
18
19to support this assertion
20
21This patch is added via redhat-compatibility patch so lets revert this part
22here.
23
24Signed-off-by: Khem Raj <raj.khem@gmail.com>
25
26Upstream-Status: Inappropriate [Caused by an earlier patch]
27
28Index: elfutils-0.148/src/addr2line.c
29===================================================================
30--- elfutils-0.148.orig/src/addr2line.c 2013-09-23 17:46:45.513586538 -0700
31+++ elfutils-0.148/src/addr2line.c 2013-09-23 17:46:46.329586558 -0700
32@@ -447,10 +447,10 @@
33 bool parsed = false;
34 int i, j;
35 char *name = NULL;
36- if (sscanf (string, "(%a[^)])%" PRIiMAX "%n", &name, &addr, &i) == 2
37+ if (sscanf (string, "(%m[^)])%" PRIiMAX "%n", &name, &addr, &i) == 2
38 && string[i] == '\0')
39 parsed = adjust_to_section (name, &addr, dwfl);
40- switch (sscanf (string, "%a[^-+]%n%" PRIiMAX "%n", &name, &i, &addr, &j))
41+ switch (sscanf (string, "%m[^-+]%n%" PRIiMAX "%n", &name, &i, &addr, &j))
42 {
43 default:
44 break;
45Index: elfutils-0.148/tests/line2addr.c
46===================================================================
47--- elfutils-0.148.orig/tests/line2addr.c 2013-09-23 17:46:45.521586538 -0700
48+++ elfutils-0.148/tests/line2addr.c 2013-09-23 17:46:46.329586558 -0700
49@@ -132,7 +132,7 @@
50 {
51 struct args a = { .arg = argv[cnt] };
52
53- switch (sscanf (a.arg, "%a[^:]:%d", &a.file, &a.line))
54+ switch (sscanf (a.arg, "%m[^:]:%d", &a.file, &a.line))
55 {
56 default:
57 case 0:
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.148/fix_for_gcc-4.7.patch b/meta/recipes-devtools/elfutils/elfutils-0.148/fix_for_gcc-4.7.patch
new file mode 100644
index 0000000000..bd634b4418
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/elfutils-0.148/fix_for_gcc-4.7.patch
@@ -0,0 +1,73 @@
1Upstream-Status: pending
2gcc 4.7 does not like pointer conversion, so have a void * tmp var to work
3around following compilation issue.
4
5Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com>
62011/07/07
7
8| md5.c: In function 'md5_finish_ctx':
9| md5.c:108:3: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
10| md5.c:109:3: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
11| cc1: all warnings being treated as errors
12|
13| make[2]: *** [md5.o] Error 1
14| make[2]: *** Waiting for unfinished jobs....
15| sha1.c: In function 'sha1_finish_ctx':
16| sha1.c:109:3: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
17| sha1.c:111:3: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
18| cc1: all warnings being treated as errors
19|
20| make[2]: *** [sha1.o] Error 1
21
22Index: elfutils-0.148/lib/md5.c
23===================================================================
24--- elfutils-0.148.orig/lib/md5.c
25+++ elfutils-0.148/lib/md5.c
26@@ -95,6 +95,7 @@ md5_finish_ctx (ctx, resbuf)
27 /* Take yet unprocessed bytes into account. */
28 md5_uint32 bytes = ctx->buflen;
29 size_t pad;
30+ void * tmp;
31
32 /* Now count remaining bytes. */
33 ctx->total[0] += bytes;
34@@ -105,9 +106,10 @@ md5_finish_ctx (ctx, resbuf)
35 memcpy (&ctx->buffer[bytes], fillbuf, pad);
36
37 /* Put the 64-bit file length in *bits* at the end of the buffer. */
38- *(md5_uint32 *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3);
39- *(md5_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) |
40- (ctx->total[0] >> 29));
41+ tmp = &ctx->buffer[bytes + pad];
42+ *(md5_uint32 *) tmp = SWAP (ctx->total[0] << 3);
43+ tmp = &ctx->buffer[bytes + pad + 4];
44+ *(md5_uint32 *) tmp = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
45
46 /* Process last bytes. */
47 md5_process_block (ctx->buffer, bytes + pad + 8, ctx);
48Index: elfutils-0.148/lib/sha1.c
49===================================================================
50--- elfutils-0.148.orig/lib/sha1.c
51+++ elfutils-0.148/lib/sha1.c
52@@ -96,6 +96,7 @@ sha1_finish_ctx (ctx, resbuf)
53 /* Take yet unprocessed bytes into account. */
54 sha1_uint32 bytes = ctx->buflen;
55 size_t pad;
56+ void * tmp;
57
58 /* Now count remaining bytes. */
59 ctx->total[0] += bytes;
60@@ -106,9 +107,10 @@ sha1_finish_ctx (ctx, resbuf)
61 memcpy (&ctx->buffer[bytes], fillbuf, pad);
62
63 /* Put the 64-bit file length in *bits* at the end of the buffer. */
64- *(sha1_uint32 *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) |
65- (ctx->total[0] >> 29));
66- *(sha1_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP (ctx->total[0] << 3);
67+ tmp = &ctx->buffer[bytes + pad];
68+ *(sha1_uint32 *) tmp = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
69+ tmp = &ctx->buffer[bytes + pad + 4];
70+ *(sha1_uint32 *) tmp = SWAP (ctx->total[0] << 3);
71
72 /* Process last bytes. */
73 sha1_process_block (ctx->buffer, bytes + pad + 8, ctx);
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.148/hppa_backend.diff b/meta/recipes-devtools/elfutils/elfutils-0.148/hppa_backend.diff
new file mode 100644
index 0000000000..a86b97c683
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/elfutils-0.148/hppa_backend.diff
@@ -0,0 +1,801 @@
1Upstream-Status: Backport
2
3Index: elfutils-0.146/backends/parisc_init.c
4===================================================================
5--- /dev/null 1970-01-01 00:00:00.000000000 +0000
6+++ elfutils-0.146/backends/parisc_init.c 2010-04-24 10:10:50.000000000 +0000
7@@ -0,0 +1,74 @@
8+/* Initialization of PA-RISC specific backend library.
9+ Copyright (C) 2002, 2005, 2006 Red Hat, Inc.
10+ This file is part of Red Hat elfutils.
11+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
12+
13+ Red Hat elfutils is free software; you can redistribute it and/or modify
14+ it under the terms of the GNU General Public License as published by the
15+ Free Software Foundation; version 2 of the License.
16+
17+ Red Hat elfutils is distributed in the hope that it will be useful, but
18+ WITHOUT ANY WARRANTY; without even the implied warranty of
19+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20+ General Public License for more details.
21+
22+ You should have received a copy of the GNU General Public License along
23+ with Red Hat elfutils; if not, write to the Free Software Foundation,
24+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
25+
26+ Red Hat elfutils is an included package of the Open Invention Network.
27+ An included package of the Open Invention Network is a package for which
28+ Open Invention Network licensees cross-license their patents. No patent
29+ license is granted, either expressly or impliedly, by designation as an
30+ included package. Should you wish to participate in the Open Invention
31+ Network licensing program, please visit www.openinventionnetwork.com
32+ <http://www.openinventionnetwork.com>. */
33+
34+#ifdef HAVE_CONFIG_H
35+# include <config.h>
36+#endif
37+
38+#define BACKEND parisc_
39+#define RELOC_PREFIX R_PARISC_
40+#include "libebl_CPU.h"
41+#include "libebl_parisc.h"
42+
43+/* This defines the common reloc hooks based on parisc_reloc.def. */
44+#include "common-reloc.c"
45+
46+
47+const char *
48+parisc_init (elf, machine, eh, ehlen)
49+ Elf *elf __attribute__ ((unused));
50+ GElf_Half machine __attribute__ ((unused));
51+ Ebl *eh;
52+ size_t ehlen;
53+{
54+ int pa64 = 0;
55+
56+ /* Check whether the Elf_BH object has a sufficent size. */
57+ if (ehlen < sizeof (Ebl))
58+ return NULL;
59+
60+ if (elf) {
61+ GElf_Ehdr ehdr_mem;
62+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
63+ if (ehdr && (ehdr->e_flags & EF_PARISC_WIDE))
64+ pa64 = 1;
65+ }
66+ /* We handle it. */
67+ eh->name = "PA-RISC";
68+ parisc_init_reloc (eh);
69+ HOOK (eh, reloc_simple_type);
70+ HOOK (eh, machine_flag_check);
71+ HOOK (eh, symbol_type_name);
72+ HOOK (eh, segment_type_name);
73+ HOOK (eh, section_type_name);
74+ HOOK (eh, register_info);
75+ if (pa64)
76+ eh->return_value_location = parisc_return_value_location_64;
77+ else
78+ eh->return_value_location = parisc_return_value_location_32;
79+
80+ return MODVERSION;
81+}
82Index: elfutils-0.146/backends/parisc_regs.c
83===================================================================
84--- /dev/null 1970-01-01 00:00:00.000000000 +0000
85+++ elfutils-0.146/backends/parisc_regs.c 2010-04-24 10:10:50.000000000 +0000
86@@ -0,0 +1,159 @@
87+/* Register names and numbers for PA-RISC DWARF.
88+ Copyright (C) 2005, 2006 Red Hat, Inc.
89+ This file is part of Red Hat elfutils.
90+
91+ Red Hat elfutils is free software; you can redistribute it and/or modify
92+ it under the terms of the GNU General Public License as published by the
93+ Free Software Foundation; version 2 of the License.
94+
95+ Red Hat elfutils is distributed in the hope that it will be useful, but
96+ WITHOUT ANY WARRANTY; without even the implied warranty of
97+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
98+ General Public License for more details.
99+
100+ You should have received a copy of the GNU General Public License along
101+ with Red Hat elfutils; if not, write to the Free Software Foundation,
102+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
103+
104+ Red Hat elfutils is an included package of the Open Invention Network.
105+ An included package of the Open Invention Network is a package for which
106+ Open Invention Network licensees cross-license their patents. No patent
107+ license is granted, either expressly or impliedly, by designation as an
108+ included package. Should you wish to participate in the Open Invention
109+ Network licensing program, please visit www.openinventionnetwork.com
110+ <http://www.openinventionnetwork.com>. */
111+
112+#ifdef HAVE_CONFIG_H
113+# include <config.h>
114+#endif
115+
116+#include <string.h>
117+#include <dwarf.h>
118+
119+#define BACKEND parisc_
120+#include "libebl_CPU.h"
121+
122+ssize_t
123+parisc_register_info (Ebl *ebl, int regno, char *name, size_t namelen,
124+ const char **prefix, const char **setname,
125+ int *bits, int *type)
126+{
127+ int pa64 = 0;
128+
129+ if (ebl->elf) {
130+ GElf_Ehdr ehdr_mem;
131+ GElf_Ehdr *ehdr = gelf_getehdr (ebl->elf, &ehdr_mem);
132+ if (ehdr->e_flags & EF_PARISC_WIDE)
133+ pa64 = 1;
134+ }
135+
136+ int nregs = pa64 ? 127 : 128;
137+
138+ if (name == NULL)
139+ return nregs;
140+
141+ if (regno < 0 || regno >= nregs || namelen < 6)
142+ return -1;
143+
144+ *prefix = "%";
145+
146+ if (regno < 32)
147+ {
148+ *setname = "integer";
149+ *type = DW_ATE_signed;
150+ if (pa64)
151+ {
152+ *bits = 64;
153+ }
154+ else
155+ {
156+ *bits = 32;
157+ }
158+ }
159+ else if (regno == 32)
160+ {
161+ *setname = "special";
162+ if (pa64)
163+ {
164+ *bits = 6;
165+ }
166+ else
167+ {
168+ *bits = 5;
169+ }
170+ *type = DW_ATE_unsigned;
171+ }
172+ else
173+ {
174+ *setname = "FPU";
175+ *type = DW_ATE_float;
176+ if (pa64)
177+ {
178+ *bits = 64;
179+ }
180+ else
181+ {
182+ *bits = 32;
183+ }
184+ }
185+
186+ if (regno < 33) {
187+ switch (regno)
188+ {
189+ case 0 ... 9:
190+ name[0] = 'r';
191+ name[1] = regno + '0';
192+ namelen = 2;
193+ break;
194+ case 10 ... 31:
195+ name[0] = 'r';
196+ name[1] = regno / 10 + '0';
197+ name[2] = regno % 10 + '0';
198+ namelen = 3;
199+ break;
200+ case 32:
201+ *prefix = NULL;
202+ name[0] = 'S';
203+ name[1] = 'A';
204+ name[2] = 'R';
205+ namelen = 3;
206+ break;
207+ }
208+ }
209+ else {
210+ if (pa64 && ((regno - 72) % 2)) {
211+ *setname = NULL;
212+ return 0;
213+ }
214+
215+ switch (regno)
216+ {
217+ case 72 + 0 ... 72 + 11:
218+ name[0] = 'f';
219+ name[1] = 'r';
220+ name[2] = (regno + 8 - 72) / 2 + '0';
221+ namelen = 3;
222+ if ((regno + 8 - 72) % 2) {
223+ name[3] = 'R';
224+ namelen++;
225+ }
226+ break;
227+ case 72 + 12 ... 72 + 55:
228+ name[0] = 'f';
229+ name[1] = 'r';
230+ name[2] = (regno + 8 - 72) / 2 / 10 + '0';
231+ name[3] = (regno + 8 - 72) / 2 % 10 + '0';
232+ namelen = 4;
233+ if ((regno + 8 - 72) % 2) {
234+ name[4] = 'R';
235+ namelen++;
236+ }
237+ break;
238+ default:
239+ *setname = NULL;
240+ return 0;
241+ }
242+ }
243+ name[namelen++] = '\0';
244+ return namelen;
245+}
246Index: elfutils-0.146/backends/parisc_reloc.def
247===================================================================
248--- /dev/null 1970-01-01 00:00:00.000000000 +0000
249+++ elfutils-0.146/backends/parisc_reloc.def 2010-04-24 10:10:50.000000000 +0000
250@@ -0,0 +1,128 @@
251+/* List the relocation types for PA-RISC. -*- C -*-
252+ Copyright (C) 2005 Red Hat, Inc.
253+ This file is part of Red Hat elfutils.
254+
255+ Red Hat elfutils is free software; you can redistribute it and/or modify
256+ it under the terms of the GNU General Public License as published by the
257+ Free Software Foundation; version 2 of the License.
258+
259+ Red Hat elfutils is distributed in the hope that it will be useful, but
260+ WITHOUT ANY WARRANTY; without even the implied warranty of
261+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
262+ General Public License for more details.
263+
264+ You should have received a copy of the GNU General Public License along
265+ with Red Hat elfutils; if not, write to the Free Software Foundation,
266+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
267+
268+ Red Hat elfutils is an included package of the Open Invention Network.
269+ An included package of the Open Invention Network is a package for which
270+ Open Invention Network licensees cross-license their patents. No patent
271+ license is granted, either expressly or impliedly, by designation as an
272+ included package. Should you wish to participate in the Open Invention
273+ Network licensing program, please visit www.openinventionnetwork.com
274+ <http://www.openinventionnetwork.com>. */
275+
276+/* NAME, REL|EXEC|DYN */
277+
278+RELOC_TYPE (NONE, EXEC|DYN)
279+RELOC_TYPE (DIR32, REL|EXEC|DYN)
280+RELOC_TYPE (DIR21L, REL|EXEC|DYN)
281+RELOC_TYPE (DIR17R, REL)
282+RELOC_TYPE (DIR17F, REL)
283+RELOC_TYPE (DIR14R, REL|DYN)
284+RELOC_TYPE (PCREL32, REL)
285+RELOC_TYPE (PCREL21L, REL)
286+RELOC_TYPE (PCREL17R, REL)
287+RELOC_TYPE (PCREL17F, REL)
288+RELOC_TYPE (PCREL14R, REL|EXEC)
289+RELOC_TYPE (DPREL21L, REL)
290+RELOC_TYPE (DPREL14WR, REL)
291+RELOC_TYPE (DPREL14DR, REL)
292+RELOC_TYPE (DPREL14R, REL)
293+RELOC_TYPE (GPREL21L, 0)
294+RELOC_TYPE (GPREL14R, 0)
295+RELOC_TYPE (LTOFF21L, REL)
296+RELOC_TYPE (LTOFF14R, REL)
297+RELOC_TYPE (DLTIND14F, 0)
298+RELOC_TYPE (SETBASE, 0)
299+RELOC_TYPE (SECREL32, REL)
300+RELOC_TYPE (BASEREL21L, 0)
301+RELOC_TYPE (BASEREL17R, 0)
302+RELOC_TYPE (BASEREL14R, 0)
303+RELOC_TYPE (SEGBASE, 0)
304+RELOC_TYPE (SEGREL32, REL)
305+RELOC_TYPE (PLTOFF21L, 0)
306+RELOC_TYPE (PLTOFF14R, 0)
307+RELOC_TYPE (PLTOFF14F, 0)
308+RELOC_TYPE (LTOFF_FPTR32, 0)
309+RELOC_TYPE (LTOFF_FPTR21L, 0)
310+RELOC_TYPE (LTOFF_FPTR14R, 0)
311+RELOC_TYPE (FPTR64, 0)
312+RELOC_TYPE (PLABEL32, REL|DYN)
313+RELOC_TYPE (PCREL64, 0)
314+RELOC_TYPE (PCREL22C, 0)
315+RELOC_TYPE (PCREL22F, 0)
316+RELOC_TYPE (PCREL14WR, 0)
317+RELOC_TYPE (PCREL14DR, 0)
318+RELOC_TYPE (PCREL16F, 0)
319+RELOC_TYPE (PCREL16WF, 0)
320+RELOC_TYPE (PCREL16DF, 0)
321+RELOC_TYPE (DIR64, REL|DYN)
322+RELOC_TYPE (DIR14WR, REL)
323+RELOC_TYPE (DIR14DR, REL)
324+RELOC_TYPE (DIR16F, REL)
325+RELOC_TYPE (DIR16WF, REL)
326+RELOC_TYPE (DIR16DF, REL)
327+RELOC_TYPE (GPREL64, 0)
328+RELOC_TYPE (GPREL14WR, 0)
329+RELOC_TYPE (GPREL14DR, 0)
330+RELOC_TYPE (GPREL16F, 0)
331+RELOC_TYPE (GPREL16WF, 0)
332+RELOC_TYPE (GPREL16DF, 0)
333+RELOC_TYPE (LTOFF64, 0)
334+RELOC_TYPE (LTOFF14WR, 0)
335+RELOC_TYPE (LTOFF14DR, 0)
336+RELOC_TYPE (LTOFF16F, 0)
337+RELOC_TYPE (LTOFF16WF, 0)
338+RELOC_TYPE (LTOFF16DF, 0)
339+RELOC_TYPE (SECREL64, 0)
340+RELOC_TYPE (BASEREL14WR, 0)
341+RELOC_TYPE (BASEREL14DR, 0)
342+RELOC_TYPE (SEGREL64, 0)
343+RELOC_TYPE (PLTOFF14WR, 0)
344+RELOC_TYPE (PLTOFF14DR, 0)
345+RELOC_TYPE (PLTOFF16F, 0)
346+RELOC_TYPE (PLTOFF16WF, 0)
347+RELOC_TYPE (PLTOFF16DF, 0)
348+RELOC_TYPE (LTOFF_FPTR64, 0)
349+RELOC_TYPE (LTOFF_FPTR14WR, 0)
350+RELOC_TYPE (LTOFF_FPTR14DR, 0)
351+RELOC_TYPE (LTOFF_FPTR16F, 0)
352+RELOC_TYPE (LTOFF_FPTR16WF, 0)
353+RELOC_TYPE (LTOFF_FPTR16DF, 0)
354+RELOC_TYPE (COPY, EXEC)
355+RELOC_TYPE (IPLT, EXEC|DYN)
356+RELOC_TYPE (EPLT, 0)
357+RELOC_TYPE (TPREL32, DYN)
358+RELOC_TYPE (TPREL21L, 0)
359+RELOC_TYPE (TPREL14R, 0)
360+RELOC_TYPE (LTOFF_TP21L, 0)
361+RELOC_TYPE (LTOFF_TP14R, 0)
362+RELOC_TYPE (LTOFF_TP14F, 0)
363+RELOC_TYPE (TPREL64, 0)
364+RELOC_TYPE (TPREL14WR, 0)
365+RELOC_TYPE (TPREL14DR, 0)
366+RELOC_TYPE (TPREL16F, 0)
367+RELOC_TYPE (TPREL16WF, 0)
368+RELOC_TYPE (TPREL16DF, 0)
369+RELOC_TYPE (LTOFF_TP64, 0)
370+RELOC_TYPE (LTOFF_TP14WR, 0)
371+RELOC_TYPE (LTOFF_TP14DR, 0)
372+RELOC_TYPE (LTOFF_TP16F, 0)
373+RELOC_TYPE (LTOFF_TP16WF, 0)
374+RELOC_TYPE (LTOFF_TP16DF, 0)
375+RELOC_TYPE (TLS_DTPMOD32, DYN)
376+RELOC_TYPE (TLS_DTPMOD64, DYN)
377+
378+#define NO_RELATIVE_RELOC 1
379Index: elfutils-0.146/backends/parisc_retval.c
380===================================================================
381--- /dev/null 1970-01-01 00:00:00.000000000 +0000
382+++ elfutils-0.146/backends/parisc_retval.c 2010-04-24 10:10:50.000000000 +0000
383@@ -0,0 +1,213 @@
384+/* Function return value location for Linux/PA-RISC ABI.
385+ Copyright (C) 2005 Red Hat, Inc.
386+ This file is part of Red Hat elfutils.
387+
388+ Red Hat elfutils is free software; you can redistribute it and/or modify
389+ it under the terms of the GNU General Public License as published by the
390+ Free Software Foundation; version 2 of the License.
391+
392+ Red Hat elfutils is distributed in the hope that it will be useful, but
393+ WITHOUT ANY WARRANTY; without even the implied warranty of
394+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
395+ General Public License for more details.
396+
397+ You should have received a copy of the GNU General Public License along
398+ with Red Hat elfutils; if not, write to the Free Software Foundation,
399+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
400+
401+ Red Hat elfutils is an included package of the Open Invention Network.
402+ An included package of the Open Invention Network is a package for which
403+ Open Invention Network licensees cross-license their patents. No patent
404+ license is granted, either expressly or impliedly, by designation as an
405+ included package. Should you wish to participate in the Open Invention
406+ Network licensing program, please visit www.openinventionnetwork.com
407+ <http://www.openinventionnetwork.com>. */
408+
409+#ifdef HAVE_CONFIG_H
410+# include <config.h>
411+#endif
412+
413+#include <assert.h>
414+#include <dwarf.h>
415+
416+#define BACKEND parisc_
417+#include "libebl_CPU.h"
418+#include "libebl_parisc.h"
419+
420+/* %r28, or pair %r28, %r29. */
421+static const Dwarf_Op loc_intreg32[] =
422+ {
423+ { .atom = DW_OP_reg28 }, { .atom = DW_OP_piece, .number = 4 },
424+ { .atom = DW_OP_reg29 }, { .atom = DW_OP_piece, .number = 4 },
425+ };
426+
427+static const Dwarf_Op loc_intreg[] =
428+ {
429+ { .atom = DW_OP_reg28 }, { .atom = DW_OP_piece, .number = 8 },
430+ { .atom = DW_OP_reg29 }, { .atom = DW_OP_piece, .number = 8 },
431+ };
432+#define nloc_intreg 1
433+#define nloc_intregpair 4
434+
435+/* %fr4L, or pair %fr4L, %fr4R on pa-32 */
436+static const Dwarf_Op loc_fpreg32[] =
437+ {
438+ { .atom = DW_OP_regx, .number = 72 }, { .atom = DW_OP_piece, .number = 4 },
439+ { .atom = DW_OP_regx, .number = 73 }, { .atom = DW_OP_piece, .number = 4 },
440+ };
441+#define nloc_fpreg32 2
442+#define nloc_fpregpair32 4
443+
444+/* $fr4 */
445+static const Dwarf_Op loc_fpreg[] =
446+ {
447+ { .atom = DW_OP_regx, .number = 72 },
448+ };
449+#define nloc_fpreg 1
450+
451+#if 0
452+/* The return value is a structure and is actually stored in stack space
453+ passed in a hidden argument by the caller. Address of the location is stored
454+ in %r28 before function call, but it may be changed by function. */
455+static const Dwarf_Op loc_aggregate[] =
456+ {
457+ { .atom = DW_OP_breg28 },
458+ };
459+#define nloc_aggregate 1
460+#endif
461+
462+static int
463+parisc_return_value_location_ (Dwarf_Die *functypedie, const Dwarf_Op **locp, int pa64)
464+{
465+ Dwarf_Word regsize = pa64 ? 8 : 4;
466+
467+ /* Start with the function's type, and get the DW_AT_type attribute,
468+ which is the type of the return value. */
469+
470+ Dwarf_Attribute attr_mem;
471+ Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type, &attr_mem);
472+ if (attr == NULL)
473+ /* The function has no return value, like a `void' function in C. */
474+ return 0;
475+
476+ Dwarf_Die die_mem;
477+ Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
478+ int tag = dwarf_tag (typedie);
479+
480+ /* Follow typedefs and qualifiers to get to the actual type. */
481+ while (tag == DW_TAG_typedef
482+ || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
483+ || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
484+ {
485+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
486+ typedie = dwarf_formref_die (attr, &die_mem);
487+ tag = dwarf_tag (typedie);
488+ }
489+
490+ switch (tag)
491+ {
492+ case -1:
493+ return -1;
494+
495+ case DW_TAG_subrange_type:
496+ if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
497+ {
498+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
499+ typedie = dwarf_formref_die (attr, &die_mem);
500+ tag = dwarf_tag (typedie);
501+ }
502+ /* Fall through. */
503+
504+ case DW_TAG_base_type:
505+ case DW_TAG_enumeration_type:
506+ case DW_TAG_pointer_type:
507+ case DW_TAG_ptr_to_member_type:
508+ {
509+ Dwarf_Word size;
510+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
511+ &attr_mem), &size) != 0)
512+ {
513+ if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
514+ size = 4;
515+ else
516+ return -1;
517+ }
518+ if (tag == DW_TAG_base_type)
519+ {
520+ Dwarf_Word encoding;
521+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
522+ &attr_mem), &encoding) != 0)
523+ return -1;
524+
525+ if (encoding == DW_ATE_float)
526+ {
527+ if (pa64) {
528+ *locp = loc_fpreg;
529+ if (size <= 8)
530+ return nloc_fpreg;
531+ }
532+ else {
533+ *locp = loc_fpreg32;
534+ if (size <= 4)
535+ return nloc_fpreg32;
536+ else if (size <= 8)
537+ return nloc_fpregpair32;
538+ }
539+ goto aggregate;
540+ }
541+ }
542+ if (pa64)
543+ *locp = loc_intreg;
544+ else
545+ *locp = loc_intreg32;
546+ if (size <= regsize)
547+ return nloc_intreg;
548+ if (size <= 2 * regsize)
549+ return nloc_intregpair;
550+
551+ /* Else fall through. */
552+ }
553+
554+ case DW_TAG_structure_type:
555+ case DW_TAG_class_type:
556+ case DW_TAG_union_type:
557+ case DW_TAG_array_type:
558+ aggregate: {
559+ Dwarf_Word size;
560+ if (dwarf_aggregate_size (typedie, &size) != 0)
561+ return -1;
562+ if (pa64)
563+ *locp = loc_intreg;
564+ else
565+ *locp = loc_intreg32;
566+ if (size <= regsize)
567+ return nloc_intreg;
568+ if (size <= 2 * regsize)
569+ return nloc_intregpair;
570+#if 0
571+ /* there should be some way to know this location... But I do not see it. */
572+ *locp = loc_aggregate;
573+ return nloc_aggregate;
574+#endif
575+ /* fall through. */
576+ }
577+ }
578+
579+ /* XXX We don't have a good way to return specific errors from ebl calls.
580+ This value means we do not understand the type, but it is well-formed
581+ DWARF and might be valid. */
582+ return -2;
583+}
584+
585+int
586+parisc_return_value_location_32 (Dwarf_Die *functypedie, const Dwarf_Op **locp)
587+{
588+ return parisc_return_value_location_ (functypedie, locp, 0);
589+}
590+
591+int
592+parisc_return_value_location_64 (Dwarf_Die *functypedie, const Dwarf_Op **locp)
593+{
594+ return parisc_return_value_location_ (functypedie, locp, 1);
595+}
596+
597Index: elfutils-0.146/backends/parisc_symbol.c
598===================================================================
599--- /dev/null 1970-01-01 00:00:00.000000000 +0000
600+++ elfutils-0.146/backends/parisc_symbol.c 2010-04-24 10:10:50.000000000 +0000
601@@ -0,0 +1,112 @@
602+/* PA-RISC specific symbolic name handling.
603+ Copyright (C) 2002, 2005 Red Hat, Inc.
604+ This file is part of Red Hat elfutils.
605+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
606+
607+ Red Hat elfutils is free software; you can redistribute it and/or modify
608+ it under the terms of the GNU General Public License as published by the
609+ Free Software Foundation; version 2 of the License.
610+
611+ Red Hat elfutils is distributed in the hope that it will be useful, but
612+ WITHOUT ANY WARRANTY; without even the implied warranty of
613+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
614+ General Public License for more details.
615+
616+ You should have received a copy of the GNU General Public License along
617+ with Red Hat elfutils; if not, write to the Free Software Foundation,
618+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
619+
620+ Red Hat elfutils is an included package of the Open Invention Network.
621+ An included package of the Open Invention Network is a package for which
622+ Open Invention Network licensees cross-license their patents. No patent
623+ license is granted, either expressly or impliedly, by designation as an
624+ included package. Should you wish to participate in the Open Invention
625+ Network licensing program, please visit www.openinventionnetwork.com
626+ <http://www.openinventionnetwork.com>. */
627+
628+#ifdef HAVE_CONFIG_H
629+# include <config.h>
630+#endif
631+
632+#include <elf.h>
633+#include <stddef.h>
634+
635+#define BACKEND parisc_
636+#include "libebl_CPU.h"
637+
638+const char *
639+parisc_segment_type_name (int segment, char *buf __attribute__ ((unused)),
640+ size_t len __attribute__ ((unused)))
641+{
642+ switch (segment)
643+ {
644+ case PT_PARISC_ARCHEXT:
645+ return "PARISC_ARCHEXT";
646+ case PT_PARISC_UNWIND:
647+ return "PARISC_UNWIND";
648+ default:
649+ break;
650+ }
651+ return NULL;
652+}
653+
654+/* Return symbolic representation of symbol type. */
655+const char *
656+parisc_symbol_type_name(int symbol, char *buf __attribute__ ((unused)),
657+ size_t len __attribute__ ((unused)))
658+{
659+ if (symbol == STT_PARISC_MILLICODE)
660+ return "PARISC_MILLI";
661+ return NULL;
662+}
663+
664+/* Return symbolic representation of section type. */
665+const char *
666+parisc_section_type_name (int type,
667+ char *buf __attribute__ ((unused)),
668+ size_t len __attribute__ ((unused)))
669+{
670+ switch (type)
671+ {
672+ case SHT_PARISC_EXT:
673+ return "PARISC_EXT";
674+ case SHT_PARISC_UNWIND:
675+ return "PARISC_UNWIND";
676+ case SHT_PARISC_DOC:
677+ return "PARISC_DOC";
678+ }
679+
680+ return NULL;
681+}
682+
683+/* Check whether machine flags are valid. */
684+bool
685+parisc_machine_flag_check (GElf_Word flags)
686+{
687+ if (flags &~ (EF_PARISC_TRAPNIL | EF_PARISC_EXT | EF_PARISC_LSB |
688+ EF_PARISC_WIDE | EF_PARISC_NO_KABP |
689+ EF_PARISC_LAZYSWAP | EF_PARISC_ARCH))
690+ return 0;
691+
692+ GElf_Word arch = flags & EF_PARISC_ARCH;
693+
694+ return ((arch == EFA_PARISC_1_0) || (arch == EFA_PARISC_1_1) ||
695+ (arch == EFA_PARISC_2_0));
696+}
697+
698+/* Check for the simple reloc types. */
699+Elf_Type
700+parisc_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
701+{
702+ switch (type)
703+ {
704+ case R_PARISC_DIR64:
705+ case R_PARISC_SECREL64:
706+ return ELF_T_XWORD;
707+ case R_PARISC_DIR32:
708+ case R_PARISC_SECREL32:
709+ return ELF_T_WORD;
710+ default:
711+ return ELF_T_NUM;
712+ }
713+}
714Index: elfutils-0.146/backends/libebl_parisc.h
715===================================================================
716--- /dev/null 1970-01-01 00:00:00.000000000 +0000
717+++ elfutils-0.146/backends/libebl_parisc.h 2010-04-24 10:10:50.000000000 +0000
718@@ -0,0 +1,9 @@
719+#ifndef _LIBEBL_HPPA_H
720+#define _LIBEBL_HPPA_H 1
721+
722+#include <libdw.h>
723+
724+extern int parisc_return_value_location_32(Dwarf_Die *, const Dwarf_Op **locp);
725+extern int parisc_return_value_location_64(Dwarf_Die *, const Dwarf_Op **locp);
726+
727+#endif
728Index: elfutils-0.146/backends/Makefile.am
729===================================================================
730--- elfutils-0.146.orig/backends/Makefile.am 2010-04-24 10:10:41.000000000 +0000
731+++ elfutils-0.146/backends/Makefile.am 2010-04-24 10:10:50.000000000 +0000
732@@ -29,11 +29,11 @@
733 -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw
734
735
736-modules = i386 sh x86_64 ia64 alpha arm sparc ppc ppc64 s390
737+modules = i386 sh x86_64 ia64 alpha arm sparc ppc ppc64 s390 parisc
738 libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \
739 libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \
740 libebl_sparc_pic.a libebl_ppc_pic.a libebl_ppc64_pic.a \
741- libebl_s390_pic.a
742+ libebl_s390_pic.a libebl_parisc_pic.a
743 noinst_LIBRARIES = $(libebl_pic)
744 noinst_DATA = $(libebl_pic:_pic.a=.so)
745
746@@ -95,6 +95,9 @@
747 libebl_s390_pic_a_SOURCES = $(s390_SRCS)
748 am_libebl_s390_pic_a_OBJECTS = $(s390_SRCS:.c=.os)
749
750+parisc_SRCS = parisc_init.c parisc_symbol.c parisc_regs.c parisc_retval.c
751+libebl_parisc_pic_a_SOURCES = $(parisc_SRCS)
752+am_libebl_parisc_pic_a_OBJECTS = $(parisc_SRCS:.c=.os)
753
754 libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw)
755 @rm -f $(@:.so=.map)
756Index: elfutils-0.146/libelf/elf.h
757===================================================================
758--- elfutils-0.146.orig/libelf/elf.h 2010-04-13 20:08:02.000000000 +0000
759+++ elfutils-0.146/libelf/elf.h 2010-04-24 10:10:50.000000000 +0000
760@@ -1789,16 +1789,24 @@
761 #define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */
762 #define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */
763 #define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */
764+#define R_PARISC_DPREL14WR 19
765+#define R_PARISC_DPREL14DR 20
766 #define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */
767 #define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */
768 #define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */
769 #define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */
770 #define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */
771+#define R_PARISC_DLTIND14F 39
772+#define R_PARISC_SETBASE 40
773 #define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */
774+#define R_PARISC_BASEREL21L 42
775+#define R_PARISC_BASEREL17R 43
776+#define R_PARISC_BASEREL14R 46
777 #define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */
778 #define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */
779 #define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */
780 #define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */
781+#define R_PARISC_PLTOFF14F 55
782 #define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */
783 #define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */
784 #define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */
785@@ -1807,6 +1815,7 @@
786 #define R_PARISC_PLABEL21L 66 /* Left 21 bits of fdesc address. */
787 #define R_PARISC_PLABEL14R 70 /* Right 14 bits of fdesc address. */
788 #define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */
789+#define R_PARISC_PCREL22C 73
790 #define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */
791 #define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */
792 #define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */
793@@ -1832,6 +1841,8 @@
794 #define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */
795 #define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */
796 #define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */
797+#define R_PARISC_BASEREL14WR 107
798+#define R_PARISC_BASEREL14DR 108
799 #define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */
800 #define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */
801 #define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.148/m68k_backend.diff b/meta/recipes-devtools/elfutils/elfutils-0.148/m68k_backend.diff
new file mode 100644
index 0000000000..5b621f92ff
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/elfutils-0.148/m68k_backend.diff
@@ -0,0 +1,309 @@
1Upstream-Status: Backport
2
3Index: elfutils-0.146/backends/m68k_init.c
4===================================================================
5--- /dev/null 1970-01-01 00:00:00.000000000 +0000
6+++ elfutils-0.146/backends/m68k_init.c 2010-04-24 10:11:38.000000000 +0000
7@@ -0,0 +1,49 @@
8+/* Initialization of m68k specific backend library.
9+ Copyright (C) 2007 Kurt Roeckx <kurt@roeckx.be>
10+
11+ This software 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+ This softare 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 this software; if not, write to the Free Software Foundation,
22+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
23+
24+*/
25+
26+#ifdef HAVE_CONFIG_H
27+# include <config.h>
28+#endif
29+
30+#define BACKEND m68k_
31+#define RELOC_PREFIX R_68K_
32+#include "libebl_CPU.h"
33+
34+/* This defines the common reloc hooks based on m68k_reloc.def. */
35+#include "common-reloc.c"
36+
37+
38+const char *
39+m68k_init (elf, machine, eh, ehlen)
40+ Elf *elf __attribute__ ((unused));
41+ GElf_Half machine __attribute__ ((unused));
42+ Ebl *eh;
43+ size_t ehlen;
44+{
45+ /* Check whether the Elf_BH object has a sufficent size. */
46+ if (ehlen < sizeof (Ebl))
47+ return NULL;
48+
49+ /* We handle it. */
50+ eh->name = "m68k";
51+ m68k_init_reloc (eh);
52+ HOOK (eh, reloc_simple_type);
53+ HOOK (eh, register_info);
54+
55+ return MODVERSION;
56+}
57Index: elfutils-0.146/backends/m68k_regs.c
58===================================================================
59--- /dev/null 1970-01-01 00:00:00.000000000 +0000
60+++ elfutils-0.146/backends/m68k_regs.c 2010-04-24 10:11:38.000000000 +0000
61@@ -0,0 +1,106 @@
62+/* Register names and numbers for m68k DWARF.
63+ Copyright (C) 2007 Kurt Roeckx <kurt@roeckx.be>
64+
65+ This software is free software; you can redistribute it and/or modify
66+ it under the terms of the GNU General Public License as published by the
67+ Free Software Foundation; version 2 of the License.
68+
69+ This software is distributed in the hope that it will be useful, but
70+ WITHOUT ANY WARRANTY; without even the implied warranty of
71+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
72+ General Public License for more details.
73+
74+ You should have received a copy of the GNU General Public License along
75+ with this software; if not, write to the Free Software Foundation,
76+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
77+
78+ */
79+
80+#ifdef HAVE_CONFIG_H
81+# include <config.h>
82+#endif
83+
84+#include <string.h>
85+#include <dwarf.h>
86+
87+#define BACKEND m68k_
88+#include "libebl_CPU.h"
89+
90+ssize_t
91+m68k_register_info (Ebl *ebl __attribute__ ((unused)),
92+ int regno, char *name, size_t namelen,
93+ const char **prefix, const char **setname,
94+ int *bits, int *type)
95+{
96+ if (name == NULL)
97+ return 25;
98+
99+ if (regno < 0 || regno > 24 || namelen < 5)
100+ return -1;
101+
102+ *prefix = "%";
103+ *bits = 32;
104+ *type = (regno < 8 ? DW_ATE_signed
105+ : regno < 16 ? DW_ATE_address : DW_ATE_float);
106+
107+ if (regno < 8)
108+ {
109+ *setname = "integer";
110+ }
111+ else if (regno < 16)
112+ {
113+ *setname = "address";
114+ }
115+ else if (regno < 24)
116+ {
117+ *setname = "FPU";
118+ }
119+ else
120+ {
121+ *setname = "address";
122+ *type = DW_ATE_address;
123+ }
124+
125+ switch (regno)
126+ {
127+ case 0 ... 7:
128+ name[0] = 'd';
129+ name[1] = regno + '0';
130+ namelen = 2;
131+ break;
132+
133+ case 8 ... 13:
134+ name[0] = 'a';
135+ name[1] = regno - 8 + '0';
136+ namelen = 2;
137+ break;
138+
139+ case 14:
140+ name[0] = 'f';
141+ name[1] = 'p';
142+ namelen = 2;
143+ break;
144+
145+ case 15:
146+ name[0] = 's';
147+ name[1] = 'p';
148+ namelen = 2;
149+ break;
150+
151+ case 16 ... 23:
152+ name[0] = 'f';
153+ name[1] = 'p';
154+ name[2] = regno - 16 + '0';
155+ namelen = 3;
156+ break;
157+
158+ case 24:
159+ name[0] = 'p';
160+ name[1] = 'c';
161+ namelen = 2;
162+ }
163+
164+ name[namelen++] = '\0';
165+ return namelen;
166+}
167+
168Index: elfutils-0.146/backends/m68k_reloc.def
169===================================================================
170--- /dev/null 1970-01-01 00:00:00.000000000 +0000
171+++ elfutils-0.146/backends/m68k_reloc.def 2010-04-24 10:11:38.000000000 +0000
172@@ -0,0 +1,45 @@
173+/* List the relocation types for m68k. -*- C -*-
174+ Copyright (C) 2007 Kurt Roeckx <kurt@roeckx.be>
175+
176+ This software is free software; you can redistribute it and/or modify
177+ it under the terms of the GNU General Public License as published by the
178+ Free Software Foundation; version 2 of the License.
179+
180+ This software is distributed in the hope that it will be useful, but
181+ WITHOUT ANY WARRANTY; without even the implied warranty of
182+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
183+ General Public License for more details.
184+
185+ You should have received a copy of the GNU General Public License along
186+ with this software; if not, write to the Free Software Foundation,
187+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
188+*/
189+
190+/* NAME, REL|EXEC|DYN */
191+
192+RELOC_TYPE (NONE, 0)
193+RELOC_TYPE (32, REL|EXEC|DYN)
194+RELOC_TYPE (16, REL)
195+RELOC_TYPE (8, REL)
196+RELOC_TYPE (PC32, REL|EXEC|DYN)
197+RELOC_TYPE (PC16, REL)
198+RELOC_TYPE (PC8, REL)
199+RELOC_TYPE (GOT32, REL)
200+RELOC_TYPE (GOT16, REL)
201+RELOC_TYPE (GOT8, REL)
202+RELOC_TYPE (GOT32O, REL)
203+RELOC_TYPE (GOT16O, REL)
204+RELOC_TYPE (GOT8O, REL)
205+RELOC_TYPE (PLT32, REL)
206+RELOC_TYPE (PLT16, REL)
207+RELOC_TYPE (PLT8, REL)
208+RELOC_TYPE (PLT32O, REL)
209+RELOC_TYPE (PLT16O, REL)
210+RELOC_TYPE (PLT8O, REL)
211+RELOC_TYPE (COPY, EXEC)
212+RELOC_TYPE (GLOB_DAT, EXEC|DYN)
213+RELOC_TYPE (JMP_SLOT, EXEC|DYN)
214+RELOC_TYPE (RELATIVE, EXEC|DYN)
215+RELOC_TYPE (GNU_VTINHERIT, REL)
216+RELOC_TYPE (GNU_VTENTRY, REL)
217+
218Index: elfutils-0.146/libelf/elf.h
219===================================================================
220--- elfutils-0.146.orig/libelf/elf.h 2010-04-24 10:11:13.000000000 +0000
221+++ elfutils-0.146/libelf/elf.h 2010-04-24 10:13:50.000000000 +0000
222@@ -1125,6 +1125,9 @@
223 #define R_68K_GLOB_DAT 20 /* Create GOT entry */
224 #define R_68K_JMP_SLOT 21 /* Create PLT entry */
225 #define R_68K_RELATIVE 22 /* Adjust by program base */
226+/* The next 2 are GNU extensions to enable C++ vtable garbage collection. */
227+#define R_68K_GNU_VTINHERIT 23
228+#define R_68K_GNU_VTENTRY 24
229 #define R_68K_TLS_GD32 25 /* 32 bit GOT offset for GD */
230 #define R_68K_TLS_GD16 26 /* 16 bit GOT offset for GD */
231 #define R_68K_TLS_GD8 27 /* 8 bit GOT offset for GD */
232Index: elfutils-0.146/backends/Makefile.am
233===================================================================
234--- elfutils-0.146.orig/backends/Makefile.am 2010-04-24 10:11:23.000000000 +0000
235+++ elfutils-0.146/backends/Makefile.am 2010-04-24 10:11:38.000000000 +0000
236@@ -29,11 +29,12 @@
237 -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw
238
239
240-modules = i386 sh x86_64 ia64 alpha arm sparc ppc ppc64 s390 parisc mips
241+modules = i386 sh x86_64 ia64 alpha arm sparc ppc ppc64 s390 parisc mips m68k
242 libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \
243 libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \
244 libebl_sparc_pic.a libebl_ppc_pic.a libebl_ppc64_pic.a \
245- libebl_s390_pic.a libebl_parisc_pic.a libebl_mips_pic.a
246+ libebl_s390_pic.a libebl_parisc_pic.a libebl_mips_pic.a \
247+ libebl_m68k_pic.a
248 noinst_LIBRARIES = $(libebl_pic)
249 noinst_DATA = $(libebl_pic:_pic.a=.so)
250
251@@ -103,6 +104,10 @@
252 libebl_mips_pic_a_SOURCES = $(mips_SRCS)
253 am_libebl_mips_pic_a_OBJECTS = $(mips_SRCS:.c=.os)
254
255+m68k_SRCS = m68k_init.c m68k_symbol.c m68k_regs.c
256+libebl_m68k_pic_a_SOURCES = $(m68k_SRCS)
257+am_libebl_m68k_pic_a_OBJECTS = $(m68k_SRCS:.c=.os)
258+
259 libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw)
260 @rm -f $(@:.so=.map)
261 echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: *; };' \
262Index: elfutils-0.146/backends/m68k_symbol.c
263===================================================================
264--- /dev/null 1970-01-01 00:00:00.000000000 +0000
265+++ elfutils-0.146/backends/m68k_symbol.c 2010-04-24 10:11:38.000000000 +0000
266@@ -0,0 +1,43 @@
267+/* m68k specific symbolic name handling.
268+ Copyright (C) 2007 Kurt Roeckx <kurt@roeckx.be>
269+
270+ This software is free software; you can redistribute it and/or modify
271+ it under the terms of the GNU General Public License as published by the
272+ Free Software Foundation; version 2 of the License.
273+
274+ This software distributed in the hope that it will be useful, but
275+ WITHOUT ANY WARRANTY; without even the implied warranty of
276+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
277+ General Public License for more details.
278+
279+ You should have received a copy of the GNU General Public License along
280+ with this software; if not, write to the Free Software Foundation,
281+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
282+*/
283+
284+#ifdef HAVE_CONFIG_H
285+# include <config.h>
286+#endif
287+
288+#include <elf.h>
289+#include <stddef.h>
290+
291+#define BACKEND m68k_
292+#include "libebl_CPU.h"
293+
294+/* Check for the simple reloc types. */
295+Elf_Type
296+m68k_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
297+{
298+ switch (type)
299+ {
300+ case R_68K_32:
301+ return ELF_T_SWORD;
302+ case R_68K_16:
303+ return ELF_T_HALF;
304+ case R_68K_8:
305+ return ELF_T_BYTE;
306+ default:
307+ return ELF_T_NUM;
308+ }
309+}
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.148/mips_backend.diff b/meta/recipes-devtools/elfutils/elfutils-0.148/mips_backend.diff
new file mode 100644
index 0000000000..3f81a75b1a
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/elfutils-0.148/mips_backend.diff
@@ -0,0 +1,713 @@
1Upstream-Status: Backport
2
3Index: elfutils-0.145/backends/mips_init.c
4===================================================================
5--- /dev/null 1970-01-01 00:00:00.000000000 +0000
6+++ elfutils-0.145/backends/mips_init.c 2010-02-24 18:57:35.000000000 +0000
7@@ -0,0 +1,60 @@
8+/* Initialization of mips specific backend library.
9+ Copyright (C) 2006 Red Hat, Inc.
10+ This file is part of Red Hat elfutils.
11+
12+ Red Hat elfutils is free software; you can redistribute it and/or modify
13+ it under the terms of the GNU General Public License as published by the
14+ Free Software Foundation; version 2 of the License.
15+
16+ Red Hat elfutils is distributed in the hope that it will be useful, but
17+ WITHOUT ANY WARRANTY; without even the implied warranty of
18+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19+ General Public License for more details.
20+
21+ You should have received a copy of the GNU General Public License along
22+ with Red Hat elfutils; if not, write to the Free Software Foundation,
23+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
24+
25+ Red Hat elfutils is an included package of the Open Invention Network.
26+ An included package of the Open Invention Network is a package for which
27+ Open Invention Network licensees cross-license their patents. No patent
28+ license is granted, either expressly or impliedly, by designation as an
29+ included package. Should you wish to participate in the Open Invention
30+ Network licensing program, please visit www.openinventionnetwork.com
31+ <http://www.openinventionnetwork.com>. */
32+
33+#ifdef HAVE_CONFIG_H
34+# include <config.h>
35+#endif
36+
37+#define BACKEND mips_
38+#define RELOC_PREFIX R_MIPS_
39+#include "libebl_CPU.h"
40+
41+/* This defines the common reloc hooks based on mips_reloc.def. */
42+#include "common-reloc.c"
43+
44+const char *
45+mips_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+ if (machine == EM_MIPS)
57+ eh->name = "MIPS R3000 big-endian";
58+ else if (machine == EM_MIPS_RS3_LE)
59+ eh->name = "MIPS R3000 little-endian";
60+
61+ mips_init_reloc (eh);
62+ HOOK (eh, reloc_simple_type);
63+ HOOK (eh, return_value_location);
64+ HOOK (eh, register_info);
65+
66+ return MODVERSION;
67+}
68Index: elfutils-0.145/backends/mips_regs.c
69===================================================================
70--- /dev/null 1970-01-01 00:00:00.000000000 +0000
71+++ elfutils-0.145/backends/mips_regs.c 2010-02-24 18:57:35.000000000 +0000
72@@ -0,0 +1,104 @@
73+/* Register names and numbers for MIPS DWARF.
74+ Copyright (C) 2006 Red Hat, Inc.
75+ This file is part of Red Hat elfutils.
76+
77+ Red Hat elfutils is free software; you can redistribute it and/or modify
78+ it under the terms of the GNU General Public License as published by the
79+ Free Software Foundation; version 2 of the License.
80+
81+ Red Hat elfutils is distributed in the hope that it will be useful, but
82+ WITHOUT ANY WARRANTY; without even the implied warranty of
83+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
84+ General Public License for more details.
85+
86+ You should have received a copy of the GNU General Public License along
87+ with Red Hat elfutils; if not, write to the Free Software Foundation,
88+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
89+
90+ Red Hat elfutils is an included package of the Open Invention Network.
91+ An included package of the Open Invention Network is a package for which
92+ Open Invention Network licensees cross-license their patents. No patent
93+ license is granted, either expressly or impliedly, by designation as an
94+ included package. Should you wish to participate in the Open Invention
95+ Network licensing program, please visit www.openinventionnetwork.com
96+ <http://www.openinventionnetwork.com>. */
97+
98+#ifdef HAVE_CONFIG_H
99+# include <config.h>
100+#endif
101+
102+#include <string.h>
103+#include <dwarf.h>
104+
105+#define BACKEND mips_
106+#include "libebl_CPU.h"
107+
108+ssize_t
109+mips_register_info (Ebl *ebl __attribute__((unused)),
110+ int regno, char *name, size_t namelen,
111+ const char **prefix, const char **setname,
112+ int *bits, int *type)
113+{
114+ if (name == NULL)
115+ return 66;
116+
117+ if (regno < 0 || regno > 65 || namelen < 4)
118+ return -1;
119+
120+ *prefix = "$";
121+
122+ if (regno < 32)
123+ {
124+ *setname = "integer";
125+ *type = DW_ATE_signed;
126+ *bits = 32;
127+ if (regno < 32 + 10)
128+ {
129+ name[0] = regno + '0';
130+ namelen = 1;
131+ }
132+ else
133+ {
134+ name[0] = (regno / 10) + '0';
135+ name[1] = (regno % 10) + '0';
136+ namelen = 2;
137+ }
138+ }
139+ else if (regno < 64)
140+ {
141+ *setname = "FPU";
142+ *type = DW_ATE_float;
143+ *bits = 32;
144+ name[0] = 'f';
145+ if (regno < 32 + 10)
146+ {
147+ name[1] = (regno - 32) + '0';
148+ namelen = 2;
149+ }
150+ else
151+ {
152+ name[1] = (regno - 32) / 10 + '0';
153+ name[2] = (regno - 32) % 10 + '0';
154+ namelen = 3;
155+ }
156+ }
157+ else if (regno == 64)
158+ {
159+ *type = DW_ATE_signed;
160+ *bits = 32;
161+ name[0] = 'h';
162+ name[1] = 'i';
163+ namelen = 2;
164+ }
165+ else
166+ {
167+ *type = DW_ATE_signed;
168+ *bits = 32;
169+ name[0] = 'l';
170+ name[1] = 'o';
171+ namelen = 2;
172+ }
173+
174+ name[namelen++] = '\0';
175+ return namelen;
176+}
177Index: elfutils-0.145/backends/mips_reloc.def
178===================================================================
179--- /dev/null 1970-01-01 00:00:00.000000000 +0000
180+++ elfutils-0.145/backends/mips_reloc.def 2010-02-24 18:57:35.000000000 +0000
181@@ -0,0 +1,79 @@
182+/* List the relocation types for mips. -*- C -*-
183+ Copyright (C) 2006 Red Hat, Inc.
184+ This file is part of Red Hat elfutils.
185+
186+ Red Hat elfutils is free software; you can redistribute it and/or modify
187+ it under the terms of the GNU General Public License as published by the
188+ Free Software Foundation; version 2 of the License.
189+
190+ Red Hat elfutils is distributed in the hope that it will be useful, but
191+ WITHOUT ANY WARRANTY; without even the implied warranty of
192+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
193+ General Public License for more details.
194+
195+ You should have received a copy of the GNU General Public License along
196+ with Red Hat elfutils; if not, write to the Free Software Foundation,
197+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
198+
199+ Red Hat elfutils is an included package of the Open Invention Network.
200+ An included package of the Open Invention Network is a package for which
201+ Open Invention Network licensees cross-license their patents. No patent
202+ license is granted, either expressly or impliedly, by designation as an
203+ included package. Should you wish to participate in the Open Invention
204+ Network licensing program, please visit www.openinventionnetwork.com
205+ <http://www.openinventionnetwork.com>. */
206+
207+/* NAME, REL|EXEC|DYN */
208+
209+RELOC_TYPE (NONE, 0)
210+RELOC_TYPE (16, 0)
211+RELOC_TYPE (32, 0)
212+RELOC_TYPE (REL32, 0)
213+RELOC_TYPE (26, 0)
214+RELOC_TYPE (HI16, 0)
215+RELOC_TYPE (LO16, 0)
216+RELOC_TYPE (GPREL16, 0)
217+RELOC_TYPE (LITERAL, 0)
218+RELOC_TYPE (GOT16, 0)
219+RELOC_TYPE (PC16, 0)
220+RELOC_TYPE (CALL16, 0)
221+RELOC_TYPE (GPREL32, 0)
222+
223+RELOC_TYPE (SHIFT5, 0)
224+RELOC_TYPE (SHIFT6, 0)
225+RELOC_TYPE (64, 0)
226+RELOC_TYPE (GOT_DISP, 0)
227+RELOC_TYPE (GOT_PAGE, 0)
228+RELOC_TYPE (GOT_OFST, 0)
229+RELOC_TYPE (GOT_HI16, 0)
230+RELOC_TYPE (GOT_LO16, 0)
231+RELOC_TYPE (SUB, 0)
232+RELOC_TYPE (INSERT_A, 0)
233+RELOC_TYPE (INSERT_B, 0)
234+RELOC_TYPE (DELETE, 0)
235+RELOC_TYPE (HIGHER, 0)
236+RELOC_TYPE (HIGHEST, 0)
237+RELOC_TYPE (CALL_HI16, 0)
238+RELOC_TYPE (CALL_LO16, 0)
239+RELOC_TYPE (SCN_DISP, 0)
240+RELOC_TYPE (REL16, 0)
241+RELOC_TYPE (ADD_IMMEDIATE, 0)
242+RELOC_TYPE (PJUMP, 0)
243+RELOC_TYPE (RELGOT, 0)
244+RELOC_TYPE (JALR, 0)
245+RELOC_TYPE (TLS_DTPMOD32, 0)
246+RELOC_TYPE (TLS_DTPREL32, 0)
247+RELOC_TYPE (TLS_DTPMOD64, 0)
248+RELOC_TYPE (TLS_DTPREL64, 0)
249+RELOC_TYPE (TLS_GD, 0)
250+RELOC_TYPE (TLS_LDM, 0)
251+RELOC_TYPE (TLS_DTPREL_HI16, 0)
252+RELOC_TYPE (TLS_DTPREL_LO16, 0)
253+RELOC_TYPE (TLS_GOTTPREL, 0)
254+RELOC_TYPE (TLS_TPREL32, 0)
255+RELOC_TYPE (TLS_TPREL64, 0)
256+RELOC_TYPE (TLS_TPREL_HI16, 0)
257+RELOC_TYPE (TLS_TPREL_LO16, 0)
258+
259+#define NO_COPY_RELOC 1
260+#define NO_RELATIVE_RELOC 1
261Index: elfutils-0.145/backends/mips_retval.c
262===================================================================
263--- /dev/null 1970-01-01 00:00:00.000000000 +0000
264+++ elfutils-0.145/backends/mips_retval.c 2010-02-24 18:57:35.000000000 +0000
265@@ -0,0 +1,321 @@
266+/* Function return value location for Linux/mips ABI.
267+ Copyright (C) 2005 Red Hat, Inc.
268+ This file is part of Red Hat elfutils.
269+
270+ Red Hat elfutils is free software; you can redistribute it and/or modify
271+ it under the terms of the GNU General Public License as published by the
272+ Free Software Foundation; version 2 of the License.
273+
274+ Red Hat elfutils is distributed in the hope that it will be useful, but
275+ WITHOUT ANY WARRANTY; without even the implied warranty of
276+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
277+ General Public License for more details.
278+
279+ You should have received a copy of the GNU General Public License along
280+ with Red Hat elfutils; if not, write to the Free Software Foundation,
281+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
282+
283+ Red Hat elfutils is an included package of the Open Invention Network.
284+ An included package of the Open Invention Network is a package for which
285+ Open Invention Network licensees cross-license their patents. No patent
286+ license is granted, either expressly or impliedly, by designation as an
287+ included package. Should you wish to participate in the Open Invention
288+ Network licensing program, please visit www.openinventionnetwork.com
289+ <http://www.openinventionnetwork.com>. */
290+
291+#ifdef HAVE_CONFIG_H
292+# include <config.h>
293+#endif
294+
295+#include <string.h>
296+#include <assert.h>
297+#include <dwarf.h>
298+#include <elf.h>
299+
300+#include "../libebl/libeblP.h"
301+#include "../libdw/libdwP.h"
302+
303+#define BACKEND mips_
304+#include "libebl_CPU.h"
305+
306+/* The ABI of the file. Also see EF_MIPS_ABI2 above. */
307+#define EF_MIPS_ABI 0x0000F000
308+
309+/* The original o32 abi. */
310+#define E_MIPS_ABI_O32 0x00001000
311+
312+/* O32 extended to work on 64 bit architectures */
313+#define E_MIPS_ABI_O64 0x00002000
314+
315+/* EABI in 32 bit mode */
316+#define E_MIPS_ABI_EABI32 0x00003000
317+
318+/* EABI in 64 bit mode */
319+#define E_MIPS_ABI_EABI64 0x00004000
320+
321+/* All the possible MIPS ABIs. */
322+enum mips_abi
323+ {
324+ MIPS_ABI_UNKNOWN = 0,
325+ MIPS_ABI_N32,
326+ MIPS_ABI_O32,
327+ MIPS_ABI_N64,
328+ MIPS_ABI_O64,
329+ MIPS_ABI_EABI32,
330+ MIPS_ABI_EABI64,
331+ MIPS_ABI_LAST
332+ };
333+
334+/* Find the mips ABI of the current file */
335+enum mips_abi find_mips_abi(Elf *elf)
336+{
337+ GElf_Ehdr ehdr_mem;
338+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
339+
340+ if (ehdr == NULL)
341+ return MIPS_ABI_LAST;
342+
343+ GElf_Word elf_flags = ehdr->e_flags;
344+
345+ /* Check elf_flags to see if it specifies the ABI being used. */
346+ switch ((elf_flags & EF_MIPS_ABI))
347+ {
348+ case E_MIPS_ABI_O32:
349+ return MIPS_ABI_O32;
350+ case E_MIPS_ABI_O64:
351+ return MIPS_ABI_O64;
352+ case E_MIPS_ABI_EABI32:
353+ return MIPS_ABI_EABI32;
354+ case E_MIPS_ABI_EABI64:
355+ return MIPS_ABI_EABI64;
356+ default:
357+ if ((elf_flags & EF_MIPS_ABI2))
358+ return MIPS_ABI_N32;
359+ }
360+
361+ /* GCC creates a pseudo-section whose name describes the ABI. */
362+ size_t shstrndx;
363+ if (elf_getshdrstrndx (elf, &shstrndx) < 0)
364+ return MIPS_ABI_LAST;
365+
366+ const char *name;
367+ Elf_Scn *scn = NULL;
368+ while ((scn = elf_nextscn (elf, scn)) != NULL)
369+ {
370+ GElf_Shdr shdr_mem;
371+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
372+ if (shdr == NULL)
373+ return MIPS_ABI_LAST;
374+
375+ name = elf_strptr (elf, shstrndx, shdr->sh_name) ?: "";
376+ if (strncmp (name, ".mdebug.", 8) != 0)
377+ continue;
378+
379+ if (strcmp (name, ".mdebug.abi32") == 0)
380+ return MIPS_ABI_O32;
381+ else if (strcmp (name, ".mdebug.abiN32") == 0)
382+ return MIPS_ABI_N32;
383+ else if (strcmp (name, ".mdebug.abi64") == 0)
384+ return MIPS_ABI_N64;
385+ else if (strcmp (name, ".mdebug.abiO64") == 0)
386+ return MIPS_ABI_O64;
387+ else if (strcmp (name, ".mdebug.eabi32") == 0)
388+ return MIPS_ABI_EABI32;
389+ else if (strcmp (name, ".mdebug.eabi64") == 0)
390+ return MIPS_ABI_EABI64;
391+ else
392+ return MIPS_ABI_UNKNOWN;
393+ }
394+
395+ return MIPS_ABI_UNKNOWN;
396+}
397+
398+unsigned int
399+mips_abi_regsize (enum mips_abi abi)
400+{
401+ switch (abi)
402+ {
403+ case MIPS_ABI_EABI32:
404+ case MIPS_ABI_O32:
405+ return 4;
406+ case MIPS_ABI_N32:
407+ case MIPS_ABI_N64:
408+ case MIPS_ABI_O64:
409+ case MIPS_ABI_EABI64:
410+ return 8;
411+ case MIPS_ABI_UNKNOWN:
412+ case MIPS_ABI_LAST:
413+ default:
414+ return 0;
415+ }
416+}
417+
418+
419+/* $v0 or pair $v0, $v1 */
420+static const Dwarf_Op loc_intreg_o32[] =
421+ {
422+ { .atom = DW_OP_reg2 }, { .atom = DW_OP_piece, .number = 4 },
423+ { .atom = DW_OP_reg3 }, { .atom = DW_OP_piece, .number = 4 },
424+ };
425+
426+static const Dwarf_Op loc_intreg[] =
427+ {
428+ { .atom = DW_OP_reg2 }, { .atom = DW_OP_piece, .number = 8 },
429+ { .atom = DW_OP_reg3 }, { .atom = DW_OP_piece, .number = 8 },
430+ };
431+#define nloc_intreg 1
432+#define nloc_intregpair 4
433+
434+/* $f0 (float), or pair $f0, $f1 (double).
435+ * f2/f3 are used for COMPLEX (= 2 doubles) returns in Fortran */
436+static const Dwarf_Op loc_fpreg_o32[] =
437+ {
438+ { .atom = DW_OP_regx, .number = 32 }, { .atom = DW_OP_piece, .number = 4 },
439+ { .atom = DW_OP_regx, .number = 33 }, { .atom = DW_OP_piece, .number = 4 },
440+ { .atom = DW_OP_regx, .number = 34 }, { .atom = DW_OP_piece, .number = 4 },
441+ { .atom = DW_OP_regx, .number = 35 }, { .atom = DW_OP_piece, .number = 4 },
442+ };
443+
444+/* $f0, or pair $f0, $f2. */
445+static const Dwarf_Op loc_fpreg[] =
446+ {
447+ { .atom = DW_OP_regx, .number = 32 }, { .atom = DW_OP_piece, .number = 8 },
448+ { .atom = DW_OP_regx, .number = 34 }, { .atom = DW_OP_piece, .number = 8 },
449+ };
450+#define nloc_fpreg 1
451+#define nloc_fpregpair 4
452+#define nloc_fpregquad 8
453+
454+/* The return value is a structure and is actually stored in stack space
455+ passed in a hidden argument by the caller. But, the compiler
456+ helpfully returns the address of that space in $v0. */
457+static const Dwarf_Op loc_aggregate[] =
458+ {
459+ { .atom = DW_OP_breg2, .number = 0 }
460+ };
461+#define nloc_aggregate 1
462+
463+int
464+mips_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
465+{
466+ /* First find the ABI used by the elf object */
467+ enum mips_abi abi = find_mips_abi(functypedie->cu->dbg->elf);
468+
469+ /* Something went seriously wrong while trying to figure out the ABI */
470+ if (abi == MIPS_ABI_LAST)
471+ return -1;
472+
473+ /* We couldn't identify the ABI, but the file seems valid */
474+ if (abi == MIPS_ABI_UNKNOWN)
475+ return -2;
476+
477+ /* Can't handle EABI variants */
478+ if ((abi == MIPS_ABI_EABI32) || (abi == MIPS_ABI_EABI64))
479+ return -2;
480+
481+ unsigned int regsize = mips_abi_regsize (abi);
482+ if (!regsize)
483+ return -2;
484+
485+ /* Start with the function's type, and get the DW_AT_type attribute,
486+ which is the type of the return value. */
487+
488+ Dwarf_Attribute attr_mem;
489+ Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type, &attr_mem);
490+ if (attr == NULL)
491+ /* The function has no return value, like a `void' function in C. */
492+ return 0;
493+
494+ Dwarf_Die die_mem;
495+ Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
496+ int tag = dwarf_tag (typedie);
497+
498+ /* Follow typedefs and qualifiers to get to the actual type. */
499+ while (tag == DW_TAG_typedef
500+ || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
501+ || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
502+ {
503+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
504+ typedie = dwarf_formref_die (attr, &die_mem);
505+ tag = dwarf_tag (typedie);
506+ }
507+
508+ switch (tag)
509+ {
510+ case -1:
511+ return -1;
512+
513+ case DW_TAG_subrange_type:
514+ if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
515+ {
516+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
517+ typedie = dwarf_formref_die (attr, &die_mem);
518+ tag = dwarf_tag (typedie);
519+ }
520+ /* Fall through. */
521+
522+ case DW_TAG_base_type:
523+ case DW_TAG_enumeration_type:
524+ case DW_TAG_pointer_type:
525+ case DW_TAG_ptr_to_member_type:
526+ {
527+ Dwarf_Word size;
528+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
529+ &attr_mem), &size) != 0)
530+ {
531+ if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
532+ size = regsize;
533+ else
534+ return -1;
535+ }
536+ if (tag == DW_TAG_base_type)
537+ {
538+ Dwarf_Word encoding;
539+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
540+ &attr_mem), &encoding) != 0)
541+ return -1;
542+
543+#define ABI_LOC(loc, regsize) ((regsize) == 4 ? (loc ## _o32) : (loc))
544+
545+ if (encoding == DW_ATE_float)
546+ {
547+ *locp = ABI_LOC(loc_fpreg, regsize);
548+ if (size <= regsize)
549+ return nloc_fpreg;
550+
551+ if (size <= 2*regsize)
552+ return nloc_fpregpair;
553+
554+ if (size <= 4*regsize && abi == MIPS_ABI_O32)
555+ return nloc_fpregquad;
556+
557+ goto aggregate;
558+ }
559+ }
560+ *locp = ABI_LOC(loc_intreg, regsize);
561+ if (size <= regsize)
562+ return nloc_intreg;
563+ if (size <= 2*regsize)
564+ return nloc_intregpair;
565+
566+ /* Else fall through. Shouldn't happen though (at least with gcc) */
567+ }
568+
569+ case DW_TAG_structure_type:
570+ case DW_TAG_class_type:
571+ case DW_TAG_union_type:
572+ case DW_TAG_array_type:
573+ aggregate:
574+ /* XXX TODO: Can't handle structure return with other ABI's yet :-/ */
575+ if ((abi != MIPS_ABI_O32) && (abi != MIPS_ABI_O64))
576+ return -2;
577+
578+ *locp = loc_aggregate;
579+ return nloc_aggregate;
580+ }
581+
582+ /* XXX We don't have a good way to return specific errors from ebl calls.
583+ This value means we do not understand the type, but it is well-formed
584+ DWARF and might be valid. */
585+ return -2;
586+}
587Index: elfutils-0.145/backends/mips_symbol.c
588===================================================================
589--- /dev/null 1970-01-01 00:00:00.000000000 +0000
590+++ elfutils-0.145/backends/mips_symbol.c 2010-02-24 18:57:35.000000000 +0000
591@@ -0,0 +1,52 @@
592+/* MIPS specific symbolic name handling.
593+ Copyright (C) 2002, 2003, 2005 Red Hat, Inc.
594+ This file is part of Red Hat elfutils.
595+ Written by Jakub Jelinek <jakub@redhat.com>, 2002.
596+
597+ Red Hat elfutils is free software; you can redistribute it and/or modify
598+ it under the terms of the GNU General Public License as published by the
599+ Free Software Foundation; version 2 of the License.
600+
601+ Red Hat elfutils is distributed in the hope that it will be useful, but
602+ WITHOUT ANY WARRANTY; without even the implied warranty of
603+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
604+ General Public License for more details.
605+
606+ You should have received a copy of the GNU General Public License along
607+ with Red Hat elfutils; if not, write to the Free Software Foundation,
608+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
609+
610+ Red Hat elfutils is an included package of the Open Invention Network.
611+ An included package of the Open Invention Network is a package for which
612+ Open Invention Network licensees cross-license their patents. No patent
613+ license is granted, either expressly or impliedly, by designation as an
614+ included package. Should you wish to participate in the Open Invention
615+ Network licensing program, please visit www.openinventionnetwork.com
616+ <http://www.openinventionnetwork.com>. */
617+
618+#ifdef HAVE_CONFIG_H
619+# include <config.h>
620+#endif
621+
622+#include <elf.h>
623+#include <stddef.h>
624+
625+#define BACKEND mips_
626+#include "libebl_CPU.h"
627+
628+/* Check for the simple reloc types. */
629+Elf_Type
630+mips_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
631+{
632+ switch (type)
633+ {
634+ case R_MIPS_16:
635+ return ELF_T_HALF;
636+ case R_MIPS_32:
637+ return ELF_T_WORD;
638+ case R_MIPS_64:
639+ return ELF_T_XWORD;
640+ default:
641+ return ELF_T_NUM;
642+ }
643+}
644Index: elfutils-0.145/libebl/eblopenbackend.c
645===================================================================
646--- elfutils-0.145.orig/libebl/eblopenbackend.c 2010-02-24 18:55:51.000000000 +0000
647+++ elfutils-0.145/libebl/eblopenbackend.c 2010-02-24 18:57:35.000000000 +0000
648@@ -91,6 +91,8 @@
649 { "sparc", "elf_sparc", "sparc", 5, EM_SPARC, 0, 0 },
650 { "sparc", "elf_sparcv8plus", "sparc", 5, EM_SPARC32PLUS, 0, 0 },
651 { "s390", "ebl_s390", "s390", 4, EM_S390, 0, 0 },
652+ { "mips", "elf_mips", "mips", 4, EM_MIPS, 0, 0 },
653+ { "mips", "elf_mipsel", "mipsel", 4, EM_MIPS_RS3_LE, 0, 0 },
654
655 { "m32", "elf_m32", "m32", 3, EM_M32, 0, 0 },
656 { "m68k", "elf_m68k", "m68k", 4, EM_68K, 0, 0 },
657Index: elfutils-0.145/backends/common-reloc.c
658===================================================================
659--- elfutils-0.145.orig/backends/common-reloc.c 2010-02-24 18:55:51.000000000 +0000
660+++ elfutils-0.145/backends/common-reloc.c 2010-02-24 18:57:35.000000000 +0000
661@@ -109,11 +109,13 @@
662 }
663
664
665+#ifndef NO_COPY_RELOC
666 bool
667 EBLHOOK(copy_reloc_p) (int reloc)
668 {
669 return reloc == R_TYPE (COPY);
670 }
671+#endif
672
673 bool
674 EBLHOOK(none_reloc_p) (int reloc)
675@@ -135,7 +137,9 @@
676 ebl->reloc_type_name = EBLHOOK(reloc_type_name);
677 ebl->reloc_type_check = EBLHOOK(reloc_type_check);
678 ebl->reloc_valid_use = EBLHOOK(reloc_valid_use);
679+#ifndef NO_COPY_RELOC
680 ebl->copy_reloc_p = EBLHOOK(copy_reloc_p);
681+#endif
682 ebl->none_reloc_p = EBLHOOK(none_reloc_p);
683 #ifndef NO_RELATIVE_RELOC
684 ebl->relative_reloc_p = EBLHOOK(relative_reloc_p);
685Index: elfutils-0.145/backends/Makefile.am
686===================================================================
687--- elfutils-0.145.orig/backends/Makefile.am 2010-02-24 18:57:26.000000000 +0000
688+++ elfutils-0.145/backends/Makefile.am 2010-02-24 18:57:57.000000000 +0000
689@@ -29,11 +29,11 @@
690 -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw
691
692
693-modules = i386 sh x86_64 ia64 alpha arm sparc ppc ppc64 s390 parisc
694+modules = i386 sh x86_64 ia64 alpha arm sparc ppc ppc64 s390 parisc mips
695 libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \
696 libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \
697 libebl_sparc_pic.a libebl_ppc_pic.a libebl_ppc64_pic.a \
698- libebl_s390_pic.a libebl_parisc_pic.a
699+ libebl_s390_pic.a libebl_parisc_pic.a libebl_mips_pic.a
700 noinst_LIBRARIES = $(libebl_pic)
701 noinst_DATA = $(libebl_pic:_pic.a=.so)
702
703@@ -99,6 +99,10 @@
704 libebl_parisc_pic_a_SOURCES = $(parisc_SRCS)
705 am_libebl_parisc_pic_a_OBJECTS = $(parisc_SRCS:.c=.os)
706
707+mips_SRCS = mips_init.c mips_symbol.c mips_regs.c mips_retval.c
708+libebl_mips_pic_a_SOURCES = $(mips_SRCS)
709+am_libebl_mips_pic_a_OBJECTS = $(mips_SRCS:.c=.os)
710+
711 libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw)
712 @rm -f $(@:.so=.map)
713 echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: *; };' \
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.148/nm-Fix-size-passed-to-snprintf-for-invalid-sh_name-case.patch b/meta/recipes-devtools/elfutils/elfutils-0.148/nm-Fix-size-passed-to-snprintf-for-invalid-sh_name-case.patch
new file mode 100644
index 0000000000..2b5dad368a
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/elfutils-0.148/nm-Fix-size-passed-to-snprintf-for-invalid-sh_name-case.patch
@@ -0,0 +1,27 @@
1Upstream-Status: Backport
2
3nm: Fix size passed to snprintf for invalid sh_name case.
4native build failed as following on Fedora18:
5nm.c: In function 'show_symbols_sysv':
6nm.c:756:27: error: argument to 'sizeof' in 'snprintf' call is the same expression as the destination; did you mean to provide an explicit length? [-Werror=sizeof-pointer-memaccess]
7 snprintf (name, sizeof name, "[invalid sh_name %#" PRIx32 "]",
8 ^
9
10The original commit is http://git.fedorahosted.org/cgit/elfutils.git/commit/src/nm.c?id=57bd66cabf6e6b9ecf622cdbf350804897a8df58
11
12Signed-off-by: Zhenhua Luo <zhenhua.luo@freescale.com>
13
14--- elfutils-0.148/src/nm.c.org 2013-03-11 22:36:11.000000000 -0500
15+++ elfutils-0.148/src/nm.c 2013-03-11 22:46:09.000000000 -0500
16@@ -752,8 +752,9 @@
17 gelf_getshdr (scn, &shdr_mem)->sh_name);
18 if (unlikely (name == NULL))
19 {
20- name = alloca (sizeof "[invalid sh_name 0x12345678]");
21- snprintf (name, sizeof name, "[invalid sh_name %#" PRIx32 "]",
22+ const size_t bufsz = sizeof "[invalid sh_name 0x12345678]";
23+ name = alloca (bufsz);
24+ snprintf (name, bufsz, "[invalid sh_name %#" PRIx32 "]",
25 gelf_getshdr (scn, &shdr_mem)->sh_name);
26 }
27 scnnames[elf_ndxscn (scn)] = name;
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.148/redhat-portability.diff b/meta/recipes-devtools/elfutils/elfutils-0.148/redhat-portability.diff
new file mode 100644
index 0000000000..b8a912c412
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/elfutils-0.148/redhat-portability.diff
@@ -0,0 +1,756 @@
1Upstream-Status: Backport
2
3Index: elfutils-0.148/backends/ChangeLog
4===================================================================
5--- elfutils-0.148.orig/backends/ChangeLog 2010-04-13 20:08:02.000000000 +0000
6+++ elfutils-0.148/backends/ChangeLog 2010-07-03 13:04:07.000000000 +0000
7@@ -106,6 +106,10 @@
8 * ppc_attrs.c (ppc_check_object_attribute): Handle tag
9 GNU_Power_ABI_Struct_Return.
10
11+2009-01-23 Roland McGrath <roland@redhat.com>
12+
13+ * Makefile.am (libebl_%.so): Use $(LD_AS_NEEDED).
14+
15 2008-10-04 Ulrich Drepper <drepper@redhat.com>
16
17 * i386_reloc.def: Fix entries for TLS_GOTDESC, TLS_DESC_CALL, and
18@@ -433,6 +437,11 @@
19 * sparc_init.c: Likewise.
20 * x86_64_init.c: Likewise.
21
22+2005-11-22 Roland McGrath <roland@redhat.com>
23+
24+ * Makefile.am (LD_AS_NEEDED): New variable, substituted by configure.
25+ (libebl_%.so rule): Use it in place of -Wl,--as-needed.
26+
27 2005-11-19 Roland McGrath <roland@redhat.com>
28
29 * ppc64_reloc.def: REL30 -> ADDR30.
30@@ -455,6 +464,9 @@
31 * Makefile.am (uninstall): Don't try to remove $(pkgincludedir).
32 (CLEANFILES): Add libebl_$(m).so.
33
34+ * Makefile.am (WEXTRA): New variable, substituted by configure.
35+ (AM_CFLAGS): Use it in place of -Wextra.
36+
37 * ppc_reloc.def: Update bits per Alan Modra <amodra@bigpond.net.au>.
38 * ppc64_reloc.def: Likewise.
39
40Index: elfutils-0.148/backends/Makefile.am
41===================================================================
42--- elfutils-0.148.orig/backends/Makefile.am 2010-04-13 20:08:02.000000000 +0000
43+++ elfutils-0.148/backends/Makefile.am 2010-07-03 13:04:07.000000000 +0000
44@@ -103,7 +103,7 @@
45 $(LINK) -shared -o $(@:.map=.so) \
46 -Wl,--whole-archive $< $(cpu_$*) -Wl,--no-whole-archive \
47 -Wl,--version-script,$(@:.so=.map) \
48- -Wl,-z,defs -Wl,--as-needed $(libelf) $(libdw) $(libmudflap)
49+ -Wl,-z,defs $(LD_AS_NEEDED) $(libelf) $(libdw) $(libmudflap)
50 $(textrel_check)
51
52 libebl_i386.so: $(cpu_i386)
53Index: elfutils-0.148/ChangeLog
54===================================================================
55--- elfutils-0.148.orig/ChangeLog 2010-04-21 14:26:40.000000000 +0000
56+++ elfutils-0.148/ChangeLog 2010-07-03 13:04:07.000000000 +0000
57@@ -2,6 +2,10 @@
58
59 * configure.ac (LOCALEDIR, DATADIRNAME): Removed.
60
61+2009-11-22 Roland McGrath <roland@redhat.com>
62+
63+ * configure.ac: Use sed and expr instead of modern bash extensions.
64+
65 2009-09-21 Ulrich Drepper <drepper@redhat.com>
66
67 * configure.ac: Update for more modern autoconf.
68@@ -10,6 +14,10 @@
69
70 * configure.ac (zip_LIBS): Check for liblzma too.
71
72+2009-08-17 Roland McGrath <roland@redhat.com>
73+
74+ * configure.ac: Check for -fgnu89-inline; add it to WEXTRA if it works.
75+
76 2009-04-19 Roland McGrath <roland@redhat.com>
77
78 * configure.ac (eu_version): Round down here, not in version.h macros.
79@@ -21,6 +29,8 @@
80
81 2009-01-23 Roland McGrath <roland@redhat.com>
82
83+ * configure.ac: Check for __builtin_popcount.
84+
85 * configure.ac (zlib check): Check for gzdirect, need zlib >= 1.2.2.3.
86
87 * configure.ac (__thread check): Use AC_LINK_IFELSE, in case of
88@@ -101,6 +111,10 @@
89 * configure.ac: Add dummy automake conditional to get dependencies
90 for non-generic linker right. See src/Makefile.am.
91
92+2005-11-22 Roland McGrath <roland@redhat.com>
93+
94+ * configure.ac: Check for --as-needed linker option.
95+
96 2005-11-18 Roland McGrath <roland@redhat.com>
97
98 * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): New variable.
99@@ -148,6 +162,17 @@
100 * Makefile.am (all_SUBDIRS): Add libdwfl.
101 * configure.ac: Write libdwfl/Makefile.
102
103+2005-05-31 Roland McGrath <roland@redhat.com>
104+
105+ * configure.ac (WEXTRA): Check for -Wextra and set this substitution.
106+
107+ * configure.ac: Check for struct stat st_?tim members.
108+ * src/strip.c (process_file): Use st_?time if st_?tim are not there.
109+
110+ * configure.ac: Check for futimes function.
111+ * src/strip.c (handle_elf) [! HAVE_FUTIMES]: Use utimes instead.
112+ (handle_ar) [! HAVE_FUTIMES]: Likewise.
113+
114 2005-05-19 Roland McGrath <roland@redhat.com>
115
116 * configure.ac [AH_BOTTOM] (INTDECL, _INTDECL): New macros.
117Index: elfutils-0.148/config/eu.am
118===================================================================
119--- elfutils-0.148.orig/config/eu.am 2010-04-21 14:26:40.000000000 +0000
120+++ elfutils-0.148/config/eu.am 2010-07-03 13:04:07.000000000 +0000
121@@ -25,11 +25,14 @@
122 ## <http://www.openinventionnetwork.com>.
123 ##
124
125+WEXTRA = @WEXTRA@
126+LD_AS_NEEDED = @LD_AS_NEEDED@
127+
128 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"${localedir}"'
129 INCLUDES = -I. -I$(srcdir) -I$(top_srcdir)/lib -I..
130 AM_CFLAGS = -std=gnu99 -Wall -Wshadow \
131 $(if $($(*F)_no_Werror),,-Werror) \
132- $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
133+ $(if $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) \
134 $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) \
135 $($(*F)_CFLAGS)
136
137Index: elfutils-0.148/config.h.in
138===================================================================
139--- elfutils-0.148.orig/config.h.in 2010-06-28 19:07:37.000000000 +0000
140+++ elfutils-0.148/config.h.in 2010-07-03 13:04:07.000000000 +0000
141@@ -1,5 +1,8 @@
142 /* config.h.in. Generated from configure.ac by autoheader. */
143
144+/* Have __builtin_popcount. */
145+#undef HAVE_BUILTIN_POPCOUNT
146+
147 /* $libdir subdirectory containing libebl modules. */
148 #undef LIBEBL_SUBDIR
149
150@@ -55,4 +58,7 @@
151 /* Define for large files, on AIX-style hosts. */
152 #undef _LARGE_FILES
153
154+/* Stubbed out if missing compiler support. */
155+#undef __thread
156+
157 #include <eu-config.h>
158Index: elfutils-0.148/configure.ac
159===================================================================
160--- elfutils-0.148.orig/configure.ac 2010-06-28 19:07:26.000000000 +0000
161+++ elfutils-0.148/configure.ac 2010-07-03 13:04:07.000000000 +0000
162@@ -73,6 +73,54 @@
163 AS_IF([test "x$ac_cv_c99" != xyes],
164 AC_MSG_ERROR([gcc with C99 support required]))
165
166+AC_CACHE_CHECK([for -Wextra option to $CC], ac_cv_cc_wextra, [dnl
167+old_CFLAGS="$CFLAGS"
168+CFLAGS="$CFLAGS -Wextra"
169+AC_COMPILE_IFELSE([void foo (void) { }],
170+ ac_cv_cc_wextra=yes, ac_cv_cc_wextra=no)
171+CFLAGS="$old_CFLAGS"])
172+AC_SUBST(WEXTRA)
173+AS_IF([test "x$ac_cv_cc_wextra" = xyes], [WEXTRA=-Wextra], [WEXTRA=-W])
174+
175+AC_CACHE_CHECK([for -fgnu89-inline option to $CC], ac_cv_cc_gnu89_inline, [dnl
176+old_CFLAGS="$CFLAGS"
177+CFLAGS="$CFLAGS -fgnu89-inline -Werror"
178+AC_COMPILE_IFELSE([
179+void foo (void)
180+{
181+ inline void bar (void) {}
182+ bar ();
183+}
184+extern inline void baz (void) {}
185+], ac_cv_cc_gnu89_inline=yes, ac_cv_cc_gnu89_inline=no)
186+CFLAGS="$old_CFLAGS"])
187+AS_IF([test "x$ac_cv_cc_gnu89_inline" = xyes],
188+ [WEXTRA="${WEXTRA:+$WEXTRA }-fgnu89-inline"])
189+
190+AC_CACHE_CHECK([for --as-needed linker option],
191+ ac_cv_as_needed, [dnl
192+cat > conftest.c <<EOF
193+int main (void) { return 0; }
194+EOF
195+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
196+ -fPIC -shared -o conftest.so conftest.c
197+ -Wl,--as-needed 1>&AS_MESSAGE_LOG_FD])
198+then
199+ ac_cv_as_needed=yes
200+else
201+ ac_cv_as_needed=no
202+fi
203+rm -f conftest*])
204+AS_IF([test "x$ac_cv_as_needed" = xyes],
205+ [LD_AS_NEEDED=-Wl,--as-needed], [LD_AS_NEEDED=])
206+AC_SUBST(LD_AS_NEEDED)
207+
208+AC_CACHE_CHECK([for __builtin_popcount], ac_cv_popcount, [dnl
209+AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[exit (__builtin_popcount (127));]])],
210+ ac_cv_popcount=yes, ac_cv_popcount=no)])
211+AS_IF([test "x$ac_cv_popcount" = xyes],
212+ [AC_DEFINE([HAVE_BUILTIN_POPCOUNT], [1], [Have __builtin_popcount.])])
213+
214 AC_CACHE_CHECK([for __thread support], ac_cv_tls, [dnl
215 # Use the same flags that we use for our DSOs, so the test is representative.
216 # Some old compiler/linker/libc combinations fail some ways and not others.
217@@ -88,7 +136,10 @@
218 CFLAGS="$save_CFLAGS"
219 LDFLAGS="$save_LDFLAGS"])
220 AS_IF([test "x$ac_cv_tls" != xyes],
221- AC_MSG_ERROR([__thread support required]))
222+ [AS_IF([test "$use_locks" = yes],
223+ [AC_MSG_ERROR([--enable-thread-safety requires __thread support])],
224+ [AC_DEFINE([__thread], [/* empty: no multi-thread support */],
225+ [Stubbed out if missing compiler support.])])])
226
227 dnl This test must come as early as possible after the compiler configuration
228 dnl tests, because the choice of the file model can (in principle) affect
229@@ -251,7 +302,7 @@
230
231 # 1.234<whatever> -> 1234<whatever>
232 case "$PACKAGE_VERSION" in
233-[[0-9]].*) eu_version="${PACKAGE_VERSION/./}" ;;
234+[[0-9]].*) eu_version=`echo "$PACKAGE_VERSION" | sed 's@\.@@'` ;;
235 *) AC_MSG_ERROR([confused by version number '$PACKAGE_VERSION']) ;;
236 esac
237 case "$eu_version" in
238@@ -280,6 +331,6 @@
239 esac
240
241 # Round up to the next release API (x.y) version.
242-[eu_version=$[($eu_version + 999) / 1000]]
243+eu_version=`expr \( $eu_version + 999 \) / 1000`
244
245 AC_OUTPUT
246Index: elfutils-0.148/lib/ChangeLog
247===================================================================
248--- elfutils-0.148.orig/lib/ChangeLog 2010-06-28 19:05:56.000000000 +0000
249+++ elfutils-0.148/lib/ChangeLog 2010-07-03 13:04:07.000000000 +0000
250@@ -14,6 +14,9 @@
251
252 2009-01-23 Roland McGrath <roland@redhat.com>
253
254+ * eu-config.h [! HAVE_BUILTIN_POPCOUNT]
255+ (__builtin_popcount): New inline function.
256+
257 * eu-config.h: Add multiple inclusion protection.
258
259 2009-01-17 Ulrich Drepper <drepper@redhat.com>
260@@ -70,6 +73,11 @@
261 * Makefile.am (libeu_a_SOURCES): Add it.
262 * system.h: Declare crc32_file.
263
264+2005-02-07 Roland McGrath <roland@redhat.com>
265+
266+ * Makefile.am (WEXTRA): New variable, substituted by configure.
267+ (AM_CFLAGS): Use it in place of -Wextra.
268+
269 2005-04-30 Ulrich Drepper <drepper@redhat.com>
270
271 * Makefile.am: Use -ffunction-sections for xmalloc.c.
272Index: elfutils-0.148/lib/eu-config.h
273===================================================================
274--- elfutils-0.148.orig/lib/eu-config.h 2009-08-12 14:23:22.000000000 +0000
275+++ elfutils-0.148/lib/eu-config.h 2010-07-03 13:04:07.000000000 +0000
276@@ -182,6 +182,17 @@
277 /* This macro is used by the tests conditionalize for standalone building. */
278 #define ELFUTILS_HEADER(name) <lib##name.h>
279
280+#ifndef HAVE_BUILTIN_POPCOUNT
281+# define __builtin_popcount hakmem_popcount
282+static inline unsigned int __attribute__ ((unused))
283+hakmem_popcount (unsigned int x)
284+{
285+ /* HAKMEM 169 */
286+ unsigned int n = x - ((x >> 1) & 033333333333) - ((x >> 2) & 011111111111);
287+ return ((n + (n >> 3)) & 030707070707) % 63;
288+}
289+#endif /* HAVE_BUILTIN_POPCOUNT */
290+
291
292 #ifdef SHARED
293 # define OLD_VERSION(name, version) \
294Index: elfutils-0.148/libasm/ChangeLog
295===================================================================
296--- elfutils-0.148.orig/libasm/ChangeLog 2010-03-05 05:48:23.000000000 +0000
297+++ elfutils-0.148/libasm/ChangeLog 2010-07-03 13:04:07.000000000 +0000
298@@ -67,6 +67,11 @@
299 * asm_error.c: Add new error ASM_E_IOERROR.
300 * libasmP.h: Add ASM_E_IOERROR definition.
301
302+2005-05-31 Roland McGrath <roland@redhat.com>
303+
304+ * Makefile.am (WEXTRA): New variable, substituted by configure.
305+ (AM_CFLAGS): Use it in place of -Wextra.
306+
307 2005-02-15 Ulrich Drepper <drepper@redhat.com>
308
309 * Makefile.am (AM_CFLAGS): Add -Wunused -Wextra -Wformat=2.
310Index: elfutils-0.148/libcpu/ChangeLog
311===================================================================
312--- elfutils-0.148.orig/libcpu/ChangeLog 2010-03-05 05:48:23.000000000 +0000
313+++ elfutils-0.148/libcpu/ChangeLog 2010-07-03 13:04:07.000000000 +0000
314@@ -9,6 +9,9 @@
315
316 2009-01-23 Roland McGrath <roland@redhat.com>
317
318+ * i386_disasm.c (i386_disasm): Add abort after assert-constant for old
319+ compilers that don't realize it's noreturn.
320+
321 * Makefile.am (i386_parse_CFLAGS): Use quotes around command
322 substitution that can produce leading whitespace.
323
324@@ -338,6 +341,11 @@
325 * defs/i386.doc: New file.
326 * defs/x86_64: New file.
327
328+2005-04-04 Roland McGrath <roland@redhat.com>
329+
330+ * Makefile.am (WEXTRA): New variable, substituted by configure.
331+ (AM_CFLAGS): Use it instead of -Wextra.
332+
333 2005-02-15 Ulrich Drepper <drepper@redhat.com>
334
335 * Makefile (AM_CFLAGS): Add -Wunused -Wextra -Wformat=2.
336Index: elfutils-0.148/libcpu/i386_disasm.c
337===================================================================
338--- elfutils-0.148.orig/libcpu/i386_disasm.c 2009-01-08 20:56:36.000000000 +0000
339+++ elfutils-0.148/libcpu/i386_disasm.c 2010-07-03 13:04:07.000000000 +0000
340@@ -791,6 +791,7 @@
341
342 default:
343 assert (! "INVALID not handled");
344+ abort ();
345 }
346 }
347 else
348Index: elfutils-0.148/libdw/ChangeLog
349===================================================================
350--- elfutils-0.148.orig/libdw/ChangeLog 2010-06-28 19:05:56.000000000 +0000
351+++ elfutils-0.148/libdw/ChangeLog 2010-07-03 13:04:07.000000000 +0000
352@@ -276,6 +276,10 @@
353
354 * dwarf_hasattr_integrate.c: Integrate DW_AT_specification too.
355
356+2009-08-17 Roland McGrath <roland@redhat.com>
357+
358+ * libdw.h: Disable extern inlines for GCC 4.2.
359+
360 2009-08-10 Roland McGrath <roland@redhat.com>
361
362 * dwarf_getscopevar.c: Use dwarf_diename.
363@@ -1044,6 +1048,11 @@
364
365 2005-05-31 Roland McGrath <roland@redhat.com>
366
367+ * Makefile.am (WEXTRA): New variable, substituted by configure.
368+ (AM_CFLAGS): Use it in place of -Wextra.
369+
370+2005-05-31 Roland McGrath <roland@redhat.com>
371+
372 * dwarf_formref_die.c (dwarf_formref_die): Add CU header offset to
373 formref offset.
374
375Index: elfutils-0.148/libdw/libdw.h
376===================================================================
377--- elfutils-0.148.orig/libdw/libdw.h 2010-06-28 19:05:56.000000000 +0000
378+++ elfutils-0.148/libdw/libdw.h 2010-07-03 13:04:07.000000000 +0000
379@@ -842,7 +842,7 @@
380
381
382 /* Inline optimizations. */
383-#ifdef __OPTIMIZE__
384+#if defined __OPTIMIZE__ && !(__GNUC__ == 4 && __GNUC_MINOR__ == 2)
385 /* Return attribute code of given attribute. */
386 __libdw_extern_inline unsigned int
387 dwarf_whatattr (Dwarf_Attribute *attr)
388Index: elfutils-0.148/libdwfl/ChangeLog
389===================================================================
390--- elfutils-0.148.orig/libdwfl/ChangeLog 2010-06-28 19:05:56.000000000 +0000
391+++ elfutils-0.148/libdwfl/ChangeLog 2010-07-03 13:04:07.000000000 +0000
392@@ -1265,6 +1265,11 @@
393
394 2005-07-21 Roland McGrath <roland@redhat.com>
395
396+ * Makefile.am (WEXTRA): New variable, substituted by configure.
397+ (AM_CFLAGS): Use it in place of -Wextra.
398+
399+2005-07-21 Roland McGrath <roland@redhat.com>
400+
401 * Makefile.am (noinst_HEADERS): Add loc2c.c.
402
403 * test2.c (main): Check sscanf result to quiet warning.
404Index: elfutils-0.148/libebl/ChangeLog
405===================================================================
406--- elfutils-0.148.orig/libebl/ChangeLog 2010-03-05 05:48:23.000000000 +0000
407+++ elfutils-0.148/libebl/ChangeLog 2010-07-03 13:04:07.000000000 +0000
408@@ -624,6 +624,11 @@
409 * Makefile.am (libebl_*_so_SOURCES): Set to $(*_SRCS) so dependency
410 tracking works right.
411
412+2005-05-31 Roland McGrath <roland@redhat.com>
413+
414+ * Makefile.am (WEXTRA): New variable, substituted by configure.
415+ (AM_CFLAGS): Use it in place of -Wextra.
416+
417 2005-05-21 Ulrich Drepper <drepper@redhat.com>
418
419 * libebl_x86_64.map: Add x86_64_core_note.
420Index: elfutils-0.148/libelf/ChangeLog
421===================================================================
422--- elfutils-0.148.orig/libelf/ChangeLog 2010-06-14 21:17:20.000000000 +0000
423+++ elfutils-0.148/libelf/ChangeLog 2010-07-03 13:04:07.000000000 +0000
424@@ -657,6 +657,11 @@
425
426 * elf.h: Update from glibc.
427
428+2005-05-31 Roland McGrath <roland@redhat.com>
429+
430+ * Makefile.am (WEXTRA): New variable, substituted by configure.
431+ (AM_CFLAGS): Use it in place of -Wextra.
432+
433 2005-05-08 Roland McGrath <roland@redhat.com>
434
435 * elf_begin.c (read_file) [_MUDFLAP]: Don't use mmap for now.
436Index: elfutils-0.148/libelf/common.h
437===================================================================
438--- elfutils-0.148.orig/libelf/common.h 2009-01-08 20:56:36.000000000 +0000
439+++ elfutils-0.148/libelf/common.h 2010-07-03 13:04:07.000000000 +0000
440@@ -160,7 +160,7 @@
441 (Var) = (sizeof (Var) == 1 \
442 ? (unsigned char) (Var) \
443 : (sizeof (Var) == 2 \
444- ? bswap_16 (Var) \
445+ ? (unsigned short int) bswap_16 (Var) \
446 : (sizeof (Var) == 4 \
447 ? bswap_32 (Var) \
448 : bswap_64 (Var))))
449@@ -169,7 +169,7 @@
450 (Dst) = (sizeof (Var) == 1 \
451 ? (unsigned char) (Var) \
452 : (sizeof (Var) == 2 \
453- ? bswap_16 (Var) \
454+ ? (unsigned short int) bswap_16 (Var) \
455 : (sizeof (Var) == 4 \
456 ? bswap_32 (Var) \
457 : bswap_64 (Var))))
458Index: elfutils-0.148/src/addr2line.c
459===================================================================
460--- elfutils-0.148.orig/src/addr2line.c 2010-05-28 14:38:30.000000000 +0000
461+++ elfutils-0.148/src/addr2line.c 2010-07-03 13:05:40.000000000 +0000
462@@ -447,10 +447,10 @@
463 bool parsed = false;
464 int i, j;
465 char *name = NULL;
466- if (sscanf (string, "(%m[^)])%" PRIiMAX "%n", &name, &addr, &i) == 2
467+ if (sscanf (string, "(%a[^)])%" PRIiMAX "%n", &name, &addr, &i) == 2
468 && string[i] == '\0')
469 parsed = adjust_to_section (name, &addr, dwfl);
470- switch (sscanf (string, "%m[^-+]%n%" PRIiMAX "%n", &name, &i, &addr, &j))
471+ switch (sscanf (string, "%a[^-+]%n%" PRIiMAX "%n", &name, &i, &addr, &j))
472 {
473 default:
474 break;
475Index: elfutils-0.148/src/ChangeLog
476===================================================================
477--- elfutils-0.148.orig/src/ChangeLog 2010-06-28 19:05:56.000000000 +0000
478+++ elfutils-0.148/src/ChangeLog 2010-07-03 13:04:08.000000000 +0000
479@@ -165,8 +165,16 @@
480 * readelf.c (attr_callback): Use print_block only when we don't use
481 print_ops.
482
483+2009-08-17 Roland McGrath <roland@redhat.com>
484+
485+ * ld.h: Disable extern inlines for GCC 4.2.
486+
487 2009-08-14 Roland McGrath <roland@redhat.com>
488
489+ * strings.c (read_block): Conditionalize posix_fadvise use
490+ on [POSIX_FADV_SEQUENTIAL].
491+ From Petr Salinger <Petr.Salinger@seznam.cz>.
492+
493 * ar.c (do_oper_extract): Use pathconf instead of statfs.
494
495 2009-08-01 Ulrich Drepper <drepper@redhat.com>
496@@ -330,6 +338,8 @@
497 * readelf.c (print_debug_frame_section): Use t instead of j formats
498 for ptrdiff_t OFFSET.
499
500+ * addr2line.c (handle_address): Use %a instead of %m for compatibility.
501+
502 2009-01-21 Ulrich Drepper <drepper@redhat.com>
503
504 * elflint.c (check_program_header): Fix typo in .eh_frame_hdr section
505@@ -513,6 +523,11 @@
506 that matches its PT_LOAD's p_flags &~ PF_W. On sparc, PF_X really
507 is valid in RELRO.
508
509+2008-03-01 Roland McGrath <roland@redhat.com>
510+
511+ * readelf.c (dump_archive_index): Tweak portability hack
512+ to match [__GNUC__ < 4] too.
513+
514 2008-02-29 Roland McGrath <roland@redhat.com>
515
516 * readelf.c (print_attributes): Add a cast.
517@@ -764,6 +779,8 @@
518
519 * readelf.c (hex_dump): Fix rounding error in whitespace calculation.
520
521+ * Makefile.am (readelf_no_Werror): New variable.
522+
523 2007-10-15 Roland McGrath <roland@redhat.com>
524
525 * make-debug-archive.in: New file.
526@@ -1203,6 +1220,10 @@
527 * elflint.c (valid_e_machine): Add EM_ALPHA.
528 Reported by Christian Aichinger <Greek0@gmx.net>.
529
530+ * strings.c (map_file): Define POSIX_MADV_SEQUENTIAL to
531+ MADV_SEQUENTIAL if undefined. Don't call posix_madvise
532+ if neither is defined.
533+
534 2006-08-08 Ulrich Drepper <drepper@redhat.com>
535
536 * elflint.c (check_dynamic): Don't require DT_HASH for DT_SYMTAB.
537@@ -1279,6 +1300,10 @@
538 * Makefile.am: Add hacks to create dependency files for non-generic
539 linker.
540
541+2006-04-05 Roland McGrath <roland@redhat.com>
542+
543+ * strings.c (MAP_POPULATE): Define to 0 if undefined.
544+
545 2006-06-12 Ulrich Drepper <drepper@redhat.com>
546
547 * ldgeneric.c (ld_generic_generate_sections): Don't create .interp
548@@ -1627,6 +1652,11 @@
549 * readelf.c (print_debug_loc_section): Fix indentation for larger
550 address size.
551
552+2005-05-31 Roland McGrath <roland@redhat.com>
553+
554+ * Makefile.am (WEXTRA): New variable, substituted by configure.
555+ (AM_CFLAGS): Use it in place of -Wextra.
556+
557 2005-05-30 Roland McGrath <roland@redhat.com>
558
559 * readelf.c (print_debug_line_section): Print section offset of each
560Index: elfutils-0.148/src/findtextrel.c
561===================================================================
562--- elfutils-0.148.orig/src/findtextrel.c 2009-02-11 01:12:59.000000000 +0000
563+++ elfutils-0.148/src/findtextrel.c 2010-07-03 13:04:08.000000000 +0000
564@@ -490,7 +490,11 @@
565
566
567 static void
568-check_rel (size_t nsegments, struct segments segments[nsegments],
569+check_rel (size_t nsegments, struct segments segments[
570+#if __GNUC__ >= 4
571+ nsegments
572+#endif
573+ ],
574 GElf_Addr addr, Elf *elf, Elf_Scn *symscn, Dwarf *dw,
575 const char *fname, bool more_than_one, void **knownsrcs)
576 {
577Index: elfutils-0.148/src/ld.h
578===================================================================
579--- elfutils-0.148.orig/src/ld.h 2009-06-13 22:39:51.000000000 +0000
580+++ elfutils-0.148/src/ld.h 2010-07-03 13:04:08.000000000 +0000
581@@ -1122,6 +1122,7 @@
582
583 /* Checked whether the symbol is undefined and referenced from a DSO. */
584 extern bool linked_from_dso_p (struct scninfo *scninfo, size_t symidx);
585+#if defined __OPTIMIZE__ && !(__GNUC__ == 4 && __GNUC_MINOR__ == 2)
586 #ifdef __GNUC_STDC_INLINE__
587 __attribute__ ((__gnu_inline__))
588 #endif
589@@ -1139,5 +1140,6 @@
590
591 return sym->defined && sym->in_dso;
592 }
593+#endif /* Optimizing and not GCC 4.2. */
594
595 #endif /* ld.h */
596Index: elfutils-0.148/src/Makefile.am
597===================================================================
598--- elfutils-0.148.orig/src/Makefile.am 2010-03-05 05:48:23.000000000 +0000
599+++ elfutils-0.148/src/Makefile.am 2010-07-03 13:04:08.000000000 +0000
600@@ -99,6 +99,9 @@
601 # XXX While the file is not finished, don't warn about this
602 ldgeneric_no_Wunused = yes
603
604+# Buggy old compilers.
605+readelf_no_Werror = yes
606+
607 readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
608 nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
609 size_LDADD = $(libelf) $(libeu) $(libmudflap)
610
611Index: elfutils-0.148/src/readelf.c
612===================================================================
613--- elfutils-0.148.orig/src/readelf.c 2010-06-28 19:05:56.000000000 +0000
614+++ elfutils-0.148/src/readelf.c 2010-07-03 13:04:08.000000000 +0000
615@@ -7845,7 +7845,7 @@
616 if (unlikely (elf_rand (elf, as_off) == 0)
617 || unlikely ((subelf = elf_begin (-1, ELF_C_READ_MMAP, elf))
618 == NULL))
619-#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 7)
620+#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 7) || __GNUC__ < 4
621 while (1)
622 #endif
623 error (EXIT_FAILURE, 0,
624Index: elfutils-0.148/src/strings.c
625===================================================================
626--- elfutils-0.148.orig/src/strings.c 2009-02-11 01:12:59.000000000 +0000
627+++ elfutils-0.148/src/strings.c 2010-07-03 13:04:08.000000000 +0000
628@@ -51,6 +51,10 @@
629
630 #include <system.h>
631
632+#ifndef MAP_POPULATE
633+# define MAP_POPULATE 0
634+#endif
635+
636
637 /* Prototypes of local functions. */
638 static int read_fd (int fd, const char *fname, off64_t fdlen);
639@@ -491,8 +495,13 @@
640 fd, start_off);
641 if (mem != MAP_FAILED)
642 {
643+#if !defined POSIX_MADV_SEQUENTIAL && defined MADV_SEQUENTIAL
644+# define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL
645+#endif
646+#ifdef POSIX_MADV_SEQUENTIAL
647 /* We will go through the mapping sequentially. */
648 (void) posix_madvise (mem, map_size, POSIX_MADV_SEQUENTIAL);
649+#endif
650 break;
651 }
652 if (errno != EINVAL && errno != ENOMEM)
653@@ -586,9 +595,11 @@
654 elfmap_off = from & ~(ps - 1);
655 elfmap_base = elfmap = map_file (fd, elfmap_off, fdlen, &elfmap_size);
656
657+#ifdef POSIX_FADV_SEQUENTIAL
658 if (unlikely (elfmap == MAP_FAILED))
659 /* Let the kernel know we are going to read everything in sequence. */
660 (void) posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL);
661+#endif
662 }
663
664 if (unlikely (elfmap == MAP_FAILED))
665Index: elfutils-0.148/src/strip.c
666===================================================================
667--- elfutils-0.148.orig/src/strip.c 2010-01-15 09:05:55.000000000 +0000
668+++ elfutils-0.148/src/strip.c 2010-07-03 13:04:08.000000000 +0000
669@@ -53,6 +53,12 @@
670 #include <libebl.h>
671 #include <system.h>
672
673+#ifdef HAVE_FUTIMES
674+# define FUTIMES(fd, fname, tvp) futimes (fd, tvp)
675+#else
676+# define FUTIMES(fd, fname, tvp) utimes (fname, tvp)
677+#endif
678+
679
680 /* Name and version of program. */
681 static void print_version (FILE *stream, struct argp_state *state);
682@@ -301,8 +307,18 @@
683
684 /* If we have to preserve the timestamp, we need it in the
685 format utimes() understands. */
686+#ifdef HAVE_STRUCT_STAT_ST_ATIM
687 TIMESPEC_TO_TIMEVAL (&tv[0], &pre_st.st_atim);
688+#else
689+ tv[0].tv_sec = pre_st.st_atime;
690+ tv[0].tv_usec = 0;
691+#endif
692+#ifdef HAVE_STRUCT_STAT_ST_MTIM
693 TIMESPEC_TO_TIMEVAL (&tv[1], &pre_st.st_mtim);
694+#else
695+ tv[1].tv_sec = pre_st.st_atime;
696+ tv[1].tv_usec = 0;
697+#endif
698 }
699
700 /* Open the file. */
701@@ -1747,7 +1763,7 @@
702 /* If requested, preserve the timestamp. */
703 if (tvp != NULL)
704 {
705- if (futimes (fd, tvp) != 0)
706+ if (FUTIMES (fd, output_fname, tvp) != 0)
707 {
708 error (0, errno, gettext ("\
709 cannot set access and modification date of '%s'"),
710@@ -1804,7 +1820,7 @@
711
712 if (tvp != NULL)
713 {
714- if (unlikely (futimes (fd, tvp) != 0))
715+ if (unlikely (FUTIMES (fd, fname, tvp) != 0))
716 {
717 error (0, errno, gettext ("\
718 cannot set access and modification date of '%s'"), fname);
719Index: elfutils-0.148/tests/ChangeLog
720===================================================================
721--- elfutils-0.148.orig/tests/ChangeLog 2010-06-28 19:05:56.000000000 +0000
722+++ elfutils-0.148/tests/ChangeLog 2010-07-03 13:04:08.000000000 +0000
723@@ -154,6 +154,8 @@
724
725 2008-01-21 Roland McGrath <roland@redhat.com>
726
727+ * line2addr.c (main): Revert last change.
728+
729 * testfile45.S.bz2: Add tests for cltq, cqto.
730 * testfile45.expect.bz2: Adjust.
731
732@@ -862,6 +864,11 @@
733 * Makefile.am (TESTS): Add run-elflint-test.sh.
734 (EXTRA_DIST): Add run-elflint-test.sh and testfile18.bz2.
735
736+2005-05-31 Roland McGrath <roland@redhat.com>
737+
738+ * Makefile.am (WEXTRA): New variable, substituted by configure.
739+ (AM_CFLAGS): Use it in place of -Wextra.
740+
741 2005-05-24 Ulrich Drepper <drepper@redhat.com>
742
743 * get-files.c (main): Use correct format specifier.
744Index: elfutils-0.148/tests/line2addr.c
745===================================================================
746--- elfutils-0.148.orig/tests/line2addr.c 2009-01-08 20:56:37.000000000 +0000
747+++ elfutils-0.148/tests/line2addr.c 2010-07-03 13:04:08.000000000 +0000
748@@ -132,7 +132,7 @@
749 {
750 struct args a = { .arg = argv[cnt] };
751
752- switch (sscanf (a.arg, "%m[^:]:%d", &a.file, &a.line))
753+ switch (sscanf (a.arg, "%a[^:]:%d", &a.file, &a.line))
754 {
755 default:
756 case 0:
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.148/redhat-robustify.diff b/meta/recipes-devtools/elfutils/elfutils-0.148/redhat-robustify.diff
new file mode 100644
index 0000000000..cd398549df
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/elfutils-0.148/redhat-robustify.diff
@@ -0,0 +1,1709 @@
1Upstream-Status: Backport
2
3Index: elfutils-0.148/libelf/ChangeLog
4===================================================================
5--- elfutils-0.148.orig/libelf/ChangeLog 2010-07-03 13:07:10.000000000 +0000
6+++ elfutils-0.148/libelf/ChangeLog 2010-07-03 13:07:11.000000000 +0000
7@@ -649,10 +649,53 @@
8 If section content hasn't been read yet, do it before looking for the
9 block size. If no section data present, infer size of section header.
10
11+2005-05-14 Jakub Jelinek <jakub@redhat.com>
12+
13+ * libelfP.h (INVALID_NDX): Define.
14+ * gelf_getdyn.c (gelf_getdyn): Use it. Remove ndx < 0 test if any.
15+ * gelf_getlib.c (gelf_getlib): Likewise.
16+ * gelf_getmove.c (gelf_getmove): Likewise.
17+ * gelf_getrel.c (gelf_getrel): Likewise.
18+ * gelf_getrela.c (gelf_getrela): Likewise.
19+ * gelf_getsym.c (gelf_getsym): Likewise.
20+ * gelf_getsyminfo.c (gelf_getsyminfo): Likewise.
21+ * gelf_getsymshndx.c (gelf_getsymshndx): Likewise.
22+ * gelf_getversym.c (gelf_getversym): Likewise.
23+ * gelf_update_dyn.c (gelf_update_dyn): Likewise.
24+ * gelf_update_lib.c (gelf_update_lib): Likewise.
25+ * gelf_update_move.c (gelf_update_move): Likewise.
26+ * gelf_update_rel.c (gelf_update_rel): Likewise.
27+ * gelf_update_rela.c (gelf_update_rela): Likewise.
28+ * gelf_update_sym.c (gelf_update_sym): Likewise.
29+ * gelf_update_syminfo.c (gelf_update_syminfo): Likewise.
30+ * gelf_update_symshndx.c (gelf_update_symshndx): Likewise.
31+ * gelf_update_versym.c (gelf_update_versym): Likewise.
32+ * elf_newscn.c (elf_newscn): Check for overflow.
33+ * elf32_updatefile.c (__elfw2(LIBELFBITS,updatemmap)): Likewise.
34+ (__elfw2(LIBELFBITS,updatefile)): Likewise.
35+ * elf_begin.c (file_read_elf): Likewise.
36+ * elf32_newphdr.c (elfw2(LIBELFBITS,newphdr)): Likewise.
37+ * elf_getarsym.c (elf_getarsym): Likewise.
38+ * elf32_getshdr.c (elfw2(LIBELFBITS,getshdr)): Likewise.
39 2005-05-11 Ulrich Drepper <drepper@redhat.com>
40
41 * elf.h: Update again.
42
43+2005-05-17 Jakub Jelinek <jakub@redhat.com>
44+
45+ * elf32_getphdr.c (elfw2(LIBELFBITS,getphdr)): Check if program header
46+ table fits into object's bounds.
47+ * elf_getshstrndx.c (elf_getshstrndx): Add elf->start_offset to
48+ elf->map_address. Check if first section header fits into object's
49+ bounds.
50+ * elf32_getshdr.c (elfw2(LIBELFBITS,getshdr)):
51+ Check if section header table fits into object's bounds.
52+ * elf_begin.c (get_shnum): Ensure section headers fits into
53+ object's bounds.
54+ (file_read_elf): Make sure scncnt is small enough to allocate both
55+ ElfXX_Shdr and Elf_Scn array. Make sure section and program header
56+ tables fit into object's bounds. Avoid memory leak on failure.
57+
58 2005-05-09 Ulrich Drepper <drepper@redhat.com>
59
60 * elf.h: Update from glibc.
61Index: elfutils-0.148/libelf/elf32_getphdr.c
62===================================================================
63--- elfutils-0.148.orig/libelf/elf32_getphdr.c 2010-04-21 14:26:40.000000000 +0000
64+++ elfutils-0.148/libelf/elf32_getphdr.c 2010-07-03 13:07:11.000000000 +0000
65@@ -114,6 +114,16 @@
66
67 if (elf->map_address != NULL)
68 {
69+ /* First see whether the information in the ELF header is
70+ valid and it does not ask for too much. */
71+ if (unlikely (ehdr->e_phoff >= elf->maximum_size)
72+ || unlikely (elf->maximum_size - ehdr->e_phoff < size))
73+ {
74+ /* Something is wrong. */
75+ __libelf_seterrno (ELF_E_INVALID_PHDR);
76+ goto out;
77+ }
78+
79 /* All the data is already mapped. Use it. */
80 void *file_phdr = ((char *) elf->map_address
81 + elf->start_offset + ehdr->e_phoff);
82Index: elfutils-0.148/libelf/elf32_getshdr.c
83===================================================================
84--- elfutils-0.148.orig/libelf/elf32_getshdr.c 2009-06-13 22:41:42.000000000 +0000
85+++ elfutils-0.148/libelf/elf32_getshdr.c 2010-07-03 13:07:11.000000000 +0000
86@@ -1,5 +1,5 @@
87 /* Return section header.
88- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005, 2007, 2009 Red Hat, Inc.
89+ Copyright (C) 1998-2009 Red Hat, Inc.
90 This file is part of Red Hat elfutils.
91 Written by Ulrich Drepper <drepper@redhat.com>, 1998.
92
93@@ -81,7 +81,8 @@
94 goto out;
95
96 size_t shnum;
97- if (__elf_getshdrnum_rdlock (elf, &shnum) != 0)
98+ if (__elf_getshdrnum_rdlock (elf, &shnum) != 0
99+ || shnum > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Shdr)))
100 goto out;
101 size_t size = shnum * sizeof (ElfW2(LIBELFBITS,Shdr));
102
103@@ -98,6 +99,16 @@
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_shoff >= elf->maximum_size)
110+ || unlikely (elf->maximum_size - ehdr->e_shoff < size))
111+ {
112+ /* Something is wrong. */
113+ __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER);
114+ goto free_and_out;
115+ }
116+
117 ElfW2(LIBELFBITS,Shdr) *notcvt;
118
119 /* All the data is already mapped. If we could use it
120Index: elfutils-0.148/libelf/elf32_newphdr.c
121===================================================================
122--- elfutils-0.148.orig/libelf/elf32_newphdr.c 2010-01-12 16:57:54.000000000 +0000
123+++ elfutils-0.148/libelf/elf32_newphdr.c 2010-07-03 13:07:11.000000000 +0000
124@@ -135,6 +135,12 @@
125 || count == PN_XNUM
126 || elf->state.ELFW(elf,LIBELFBITS).phdr == NULL)
127 {
128+ if (unlikely (count > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Phdr))))
129+ {
130+ result = NULL;
131+ goto out;
132+ }
133+
134 /* Allocate a new program header with the appropriate number of
135 elements. */
136 result = (ElfW2(LIBELFBITS,Phdr) *)
137Index: elfutils-0.148/libelf/elf32_updatefile.c
138===================================================================
139--- elfutils-0.148.orig/libelf/elf32_updatefile.c 2010-01-12 16:57:54.000000000 +0000
140+++ elfutils-0.148/libelf/elf32_updatefile.c 2010-07-03 13:07:11.000000000 +0000
141@@ -223,6 +223,9 @@
142 /* Write all the sections. Well, only those which are modified. */
143 if (shnum > 0)
144 {
145+ if (unlikely (shnum > SIZE_MAX / sizeof (Elf_Scn *)))
146+ return 1;
147+
148 Elf_ScnList *list = &elf->state.ELFW(elf,LIBELFBITS).scns;
149 Elf_Scn **scns = (Elf_Scn **) alloca (shnum * sizeof (Elf_Scn *));
150 char *const shdr_start = ((char *) elf->map_address + elf->start_offset
151@@ -645,6 +648,10 @@
152 /* Write all the sections. Well, only those which are modified. */
153 if (shnum > 0)
154 {
155+ if (unlikely (shnum > SIZE_MAX / (sizeof (Elf_Scn *)
156+ + sizeof (ElfW2(LIBELFBITS,Shdr)))))
157+ return 1;
158+
159 off_t shdr_offset = elf->start_offset + ehdr->e_shoff;
160 #if EV_NUM != 2
161 xfct_t shdr_fctp = __elf_xfctstom[__libelf_version - 1][EV_CURRENT - 1][ELFW(ELFCLASS, LIBELFBITS) - 1][ELF_T_SHDR];
162Index: elfutils-0.148/libelf/elf_begin.c
163===================================================================
164--- elfutils-0.148.orig/libelf/elf_begin.c 2010-04-21 14:26:40.000000000 +0000
165+++ elfutils-0.148/libelf/elf_begin.c 2010-07-03 13:07:11.000000000 +0000
166@@ -165,7 +165,8 @@
167
168 if (unlikely (result == 0) && ehdr.e32->e_shoff != 0)
169 {
170- if (ehdr.e32->e_shoff + sizeof (Elf32_Shdr) > maxsize)
171+ if (unlikely (ehdr.e32->e_shoff >= maxsize)
172+ || unlikely (maxsize - ehdr.e32->e_shoff < sizeof (Elf32_Shdr)))
173 /* Cannot read the first section header. */
174 return 0;
175
176@@ -213,7 +214,8 @@
177
178 if (unlikely (result == 0) && ehdr.e64->e_shoff != 0)
179 {
180- if (ehdr.e64->e_shoff + sizeof (Elf64_Shdr) > maxsize)
181+ if (unlikely (ehdr.e64->e_shoff >= maxsize)
182+ || unlikely (ehdr.e64->e_shoff + sizeof (Elf64_Shdr) > maxsize))
183 /* Cannot read the first section header. */
184 return 0;
185
186@@ -285,6 +287,15 @@
187 /* Could not determine the number of sections. */
188 return NULL;
189
190+ /* Check for too many sections. */
191+ if (e_ident[EI_CLASS] == ELFCLASS32)
192+ {
193+ if (scncnt > SIZE_MAX / (sizeof (Elf_Scn) + sizeof (Elf32_Shdr)))
194+ return NULL;
195+ }
196+ else if (scncnt > SIZE_MAX / (sizeof (Elf_Scn) + sizeof (Elf64_Shdr)))
197+ return NULL;
198+
199 /* We can now allocate the memory. Even if there are no section headers,
200 we allocate space for a zeroth section in case we need it later. */
201 const size_t scnmax = (scncnt ?: (cmd == ELF_C_RDWR || cmd == ELF_C_RDWR_MMAP)
202@@ -324,6 +335,16 @@
203 {
204 /* We can use the mmapped memory. */
205 elf->state.elf32.ehdr = ehdr;
206+
207+ if (unlikely (ehdr->e_shoff >= maxsize)
208+ || unlikely (maxsize - ehdr->e_shoff
209+ < scncnt * sizeof (Elf32_Shdr)))
210+ {
211+ free_and_out:
212+ free (elf);
213+ __libelf_seterrno (ELF_E_INVALID_FILE);
214+ return NULL;
215+ }
216 elf->state.elf32.shdr
217 = (Elf32_Shdr *) ((char *) ehdr + ehdr->e_shoff);
218
219@@ -410,6 +431,11 @@
220 {
221 /* We can use the mmapped memory. */
222 elf->state.elf64.ehdr = ehdr;
223+
224+ if (unlikely (ehdr->e_shoff >= maxsize)
225+ || unlikely (ehdr->e_shoff
226+ + scncnt * sizeof (Elf32_Shdr) > maxsize))
227+ goto free_and_out;
228 elf->state.elf64.shdr
229 = (Elf64_Shdr *) ((char *) ehdr + ehdr->e_shoff);
230
231Index: elfutils-0.148/libelf/elf_getarsym.c
232===================================================================
233--- elfutils-0.148.orig/libelf/elf_getarsym.c 2009-01-08 20:56:37.000000000 +0000
234+++ elfutils-0.148/libelf/elf_getarsym.c 2010-07-03 13:07:11.000000000 +0000
235@@ -179,6 +179,9 @@
236 size_t index_size = atol (tmpbuf);
237
238 if (SARMAG + sizeof (struct ar_hdr) + index_size > elf->maximum_size
239+#if SIZE_MAX <= 4294967295U
240+ || n >= SIZE_MAX / sizeof (Elf_Arsym)
241+#endif
242 || n * sizeof (uint32_t) > index_size)
243 {
244 /* This index table cannot be right since it does not fit into
245Index: elfutils-0.148/libelf/elf_getshdrstrndx.c
246===================================================================
247--- elfutils-0.148.orig/libelf/elf_getshdrstrndx.c 2009-06-13 22:31:35.000000000 +0000
248+++ elfutils-0.148/libelf/elf_getshdrstrndx.c 2010-07-03 13:07:11.000000000 +0000
249@@ -125,10 +125,25 @@
250 if (elf->map_address != NULL
251 && elf->state.elf32.ehdr->e_ident[EI_DATA] == MY_ELFDATA
252 && (ALLOW_UNALIGNED
253- || (((size_t) ((char *) elf->map_address + offset))
254+ || (((size_t) ((char *) elf->map_address
255+ + elf->start_offset + offset))
256 & (__alignof__ (Elf32_Shdr) - 1)) == 0))
257- /* We can directly access the memory. */
258- num = ((Elf32_Shdr *) (elf->map_address + offset))->sh_link;
259+ {
260+ /* First see whether the information in the ELF header is
261+ valid and it does not ask for too much. */
262+ if (unlikely (elf->maximum_size - offset
263+ < sizeof (Elf32_Shdr)))
264+ {
265+ /* Something is wrong. */
266+ __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER);
267+ result = -1;
268+ goto out;
269+ }
270+
271+ /* We can directly access the memory. */
272+ num = ((Elf32_Shdr *) (elf->map_address + elf->start_offset
273+ + offset))->sh_link;
274+ }
275 else
276 {
277 /* We avoid reading in all the section headers. Just read
278@@ -163,10 +178,25 @@
279 if (elf->map_address != NULL
280 && elf->state.elf64.ehdr->e_ident[EI_DATA] == MY_ELFDATA
281 && (ALLOW_UNALIGNED
282- || (((size_t) ((char *) elf->map_address + offset))
283+ || (((size_t) ((char *) elf->map_address
284+ + elf->start_offset + offset))
285 & (__alignof__ (Elf64_Shdr) - 1)) == 0))
286- /* We can directly access the memory. */
287- num = ((Elf64_Shdr *) (elf->map_address + offset))->sh_link;
288+ {
289+ /* First see whether the information in the ELF header is
290+ valid and it does not ask for too much. */
291+ if (unlikely (elf->maximum_size - offset
292+ < sizeof (Elf64_Shdr)))
293+ {
294+ /* Something is wrong. */
295+ __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER);
296+ result = -1;
297+ goto out;
298+ }
299+
300+ /* We can directly access the memory. */
301+ num = ((Elf64_Shdr *) (elf->map_address + elf->start_offset
302+ + offset))->sh_link;
303+ }
304 else
305 {
306 /* We avoid reading in all the section headers. Just read
307Index: elfutils-0.148/libelf/elf_newscn.c
308===================================================================
309--- elfutils-0.148.orig/libelf/elf_newscn.c 2009-01-08 20:56:37.000000000 +0000
310+++ elfutils-0.148/libelf/elf_newscn.c 2010-07-03 13:07:11.000000000 +0000
311@@ -104,10 +104,18 @@
312 else
313 {
314 /* We must allocate a new element. */
315- Elf_ScnList *newp;
316+ Elf_ScnList *newp = NULL;
317
318 assert (elf->state.elf.scnincr > 0);
319
320+ if (
321+#if SIZE_MAX <= 4294967295U
322+ likely (elf->state.elf.scnincr
323+ < SIZE_MAX / 2 / sizeof (Elf_Scn) - sizeof (Elf_ScnList))
324+#else
325+ 1
326+#endif
327+ )
328 newp = (Elf_ScnList *) calloc (sizeof (Elf_ScnList)
329 + ((elf->state.elf.scnincr *= 2)
330 * sizeof (Elf_Scn)), 1);
331Index: elfutils-0.148/libelf/gelf_getdyn.c
332===================================================================
333--- elfutils-0.148.orig/libelf/gelf_getdyn.c 2009-01-08 20:56:37.000000000 +0000
334+++ elfutils-0.148/libelf/gelf_getdyn.c 2010-07-03 13:07:11.000000000 +0000
335@@ -1,5 +1,5 @@
336 /* Get information from dynamic table at the given index.
337- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
338+ Copyright (C) 2000-2009 Red Hat, Inc.
339 This file is part of Red Hat elfutils.
340 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
341
342@@ -93,7 +93,7 @@
343 table entries has to be adopted. The user better has provided
344 a buffer where we can store the information. While copying the
345 data we are converting the format. */
346- if (unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size))
347+ if (INVALID_NDX (ndx, Elf32_Dyn, &data_scn->d))
348 {
349 __libelf_seterrno (ELF_E_INVALID_INDEX);
350 goto out;
351@@ -114,7 +114,7 @@
352
353 /* The data is already in the correct form. Just make sure the
354 index is OK. */
355- if (unlikely ((ndx + 1) * sizeof (GElf_Dyn) > data_scn->d.d_size))
356+ if (INVALID_NDX (ndx, GElf_Dyn, &data_scn->d))
357 {
358 __libelf_seterrno (ELF_E_INVALID_INDEX);
359 goto out;
360Index: elfutils-0.148/libelf/gelf_getlib.c
361===================================================================
362--- elfutils-0.148.orig/libelf/gelf_getlib.c 2009-01-08 20:56:37.000000000 +0000
363+++ elfutils-0.148/libelf/gelf_getlib.c 2010-07-03 13:07:11.000000000 +0000
364@@ -1,5 +1,5 @@
365 /* Get library from table at the given index.
366- Copyright (C) 2004 Red Hat, Inc.
367+ Copyright (C) 2004-2009 Red Hat, Inc.
368 This file is part of Red Hat elfutils.
369 Written by Ulrich Drepper <drepper@redhat.com>, 2004.
370
371@@ -86,7 +86,7 @@
372 /* The data is already in the correct form. Just make sure the
373 index is OK. */
374 GElf_Lib *result = NULL;
375- if (unlikely ((ndx + 1) * sizeof (GElf_Lib) > data->d_size))
376+ if (INVALID_NDX (ndx, GElf_Lib, data))
377 __libelf_seterrno (ELF_E_INVALID_INDEX);
378 else
379 {
380Index: elfutils-0.148/libelf/gelf_getmove.c
381===================================================================
382--- elfutils-0.148.orig/libelf/gelf_getmove.c 2009-01-08 20:56:37.000000000 +0000
383+++ elfutils-0.148/libelf/gelf_getmove.c 2010-07-03 13:07:11.000000000 +0000
384@@ -1,5 +1,5 @@
385 /* Get move structure at the given index.
386- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
387+ Copyright (C) 2000-2009 Red Hat, Inc.
388 This file is part of Red Hat elfutils.
389 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
390
391@@ -83,7 +83,7 @@
392
393 /* The data is already in the correct form. Just make sure the
394 index is OK. */
395- if (unlikely ((ndx + 1) * sizeof (GElf_Move) > data->d_size))
396+ if (INVALID_NDX (ndx, GElf_Move, data))
397 {
398 __libelf_seterrno (ELF_E_INVALID_INDEX);
399 goto out;
400Index: elfutils-0.148/libelf/gelf_getrela.c
401===================================================================
402--- elfutils-0.148.orig/libelf/gelf_getrela.c 2009-01-08 20:56:37.000000000 +0000
403+++ elfutils-0.148/libelf/gelf_getrela.c 2010-07-03 13:07:11.000000000 +0000
404@@ -1,5 +1,5 @@
405 /* Get RELA relocation information at given index.
406- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
407+ Copyright (C) 2000-2009 Red Hat, Inc.
408 This file is part of Red Hat elfutils.
409 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
410
411@@ -71,12 +71,6 @@
412 if (data_scn == NULL)
413 return NULL;
414
415- if (unlikely (ndx < 0))
416- {
417- __libelf_seterrno (ELF_E_INVALID_INDEX);
418- return NULL;
419- }
420-
421 if (unlikely (data_scn->d.d_type != ELF_T_RELA))
422 {
423 __libelf_seterrno (ELF_E_INVALID_HANDLE);
424@@ -93,7 +87,7 @@
425 if (scn->elf->class == ELFCLASS32)
426 {
427 /* We have to convert the data. */
428- if (unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size))
429+ if (INVALID_NDX (ndx, Elf32_Rela, &data_scn->d))
430 {
431 __libelf_seterrno (ELF_E_INVALID_INDEX);
432 result = NULL;
433@@ -114,7 +108,7 @@
434 {
435 /* Simply copy the data after we made sure we are actually getting
436 correct data. */
437- if (unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size))
438+ if (INVALID_NDX (ndx, Elf64_Rela, &data_scn->d))
439 {
440 __libelf_seterrno (ELF_E_INVALID_INDEX);
441 result = NULL;
442Index: elfutils-0.148/libelf/gelf_getrel.c
443===================================================================
444--- elfutils-0.148.orig/libelf/gelf_getrel.c 2009-01-08 20:56:37.000000000 +0000
445+++ elfutils-0.148/libelf/gelf_getrel.c 2010-07-03 13:07:11.000000000 +0000
446@@ -1,5 +1,5 @@
447 /* Get REL relocation information at given index.
448- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
449+ Copyright (C) 2000-2009 Red Hat, Inc.
450 This file is part of Red Hat elfutils.
451 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
452
453@@ -71,12 +71,6 @@
454 if (data_scn == NULL)
455 return NULL;
456
457- if (unlikely (ndx < 0))
458- {
459- __libelf_seterrno (ELF_E_INVALID_INDEX);
460- return NULL;
461- }
462-
463 if (unlikely (data_scn->d.d_type != ELF_T_REL))
464 {
465 __libelf_seterrno (ELF_E_INVALID_HANDLE);
466@@ -93,7 +87,7 @@
467 if (scn->elf->class == ELFCLASS32)
468 {
469 /* We have to convert the data. */
470- if (unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size))
471+ if (INVALID_NDX (ndx, Elf32_Rel, &data_scn->d))
472 {
473 __libelf_seterrno (ELF_E_INVALID_INDEX);
474 result = NULL;
475@@ -113,7 +107,7 @@
476 {
477 /* Simply copy the data after we made sure we are actually getting
478 correct data. */
479- if (unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size))
480+ if (INVALID_NDX (ndx, Elf64_Rel, &data_scn->d))
481 {
482 __libelf_seterrno (ELF_E_INVALID_INDEX);
483 result = NULL;
484Index: elfutils-0.148/libelf/gelf_getsym.c
485===================================================================
486--- elfutils-0.148.orig/libelf/gelf_getsym.c 2009-01-08 20:56:37.000000000 +0000
487+++ elfutils-0.148/libelf/gelf_getsym.c 2010-07-03 13:07:11.000000000 +0000
488@@ -1,5 +1,5 @@
489 /* Get symbol information from symbol table at the given index.
490- Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
491+ Copyright (C) 1999-2009 Red Hat, Inc.
492 This file is part of Red Hat elfutils.
493 Written by Ulrich Drepper <drepper@redhat.com>, 1999.
494
495@@ -90,7 +90,7 @@
496 table entries has to be adopted. The user better has provided
497 a buffer where we can store the information. While copying the
498 data we are converting the format. */
499- if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data->d_size))
500+ if (INVALID_NDX (ndx, Elf32_Sym, data))
501 {
502 __libelf_seterrno (ELF_E_INVALID_INDEX);
503 goto out;
504@@ -119,7 +119,7 @@
505
506 /* The data is already in the correct form. Just make sure the
507 index is OK. */
508- if (unlikely ((ndx + 1) * sizeof (GElf_Sym) > data->d_size))
509+ if (INVALID_NDX (ndx, GElf_Sym, data))
510 {
511 __libelf_seterrno (ELF_E_INVALID_INDEX);
512 goto out;
513Index: elfutils-0.148/libelf/gelf_getsyminfo.c
514===================================================================
515--- elfutils-0.148.orig/libelf/gelf_getsyminfo.c 2009-01-08 20:56:37.000000000 +0000
516+++ elfutils-0.148/libelf/gelf_getsyminfo.c 2010-07-03 13:07:11.000000000 +0000
517@@ -1,5 +1,5 @@
518 /* Get additional symbol information from symbol table at the given index.
519- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
520+ Copyright (C) 2000-2009 Red Hat, Inc.
521 This file is part of Red Hat elfutils.
522 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
523
524@@ -84,7 +84,7 @@
525
526 /* The data is already in the correct form. Just make sure the
527 index is OK. */
528- if (unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data->d_size))
529+ if (INVALID_NDX (ndx, GElf_Syminfo, data))
530 {
531 __libelf_seterrno (ELF_E_INVALID_INDEX);
532 goto out;
533Index: elfutils-0.148/libelf/gelf_getsymshndx.c
534===================================================================
535--- elfutils-0.148.orig/libelf/gelf_getsymshndx.c 2009-01-08 20:56:37.000000000 +0000
536+++ elfutils-0.148/libelf/gelf_getsymshndx.c 2010-07-03 13:07:11.000000000 +0000
537@@ -1,6 +1,6 @@
538 /* Get symbol information and separate section index from symbol table
539 at the given index.
540- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
541+ Copyright (C) 2000-2009 Red Hat, Inc.
542 This file is part of Red Hat elfutils.
543 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
544
545@@ -90,7 +90,7 @@
546 section index table. */
547 if (likely (shndxdata_scn != NULL))
548 {
549- if (unlikely ((ndx + 1) * sizeof (Elf32_Word) > shndxdata_scn->d.d_size))
550+ if (INVALID_NDX (ndx, Elf32_Word, &shndxdata_scn->d))
551 {
552 __libelf_seterrno (ELF_E_INVALID_INDEX);
553 goto out;
554@@ -110,7 +110,7 @@
555 table entries has to be adopted. The user better has provided
556 a buffer where we can store the information. While copying the
557 data we are converting the format. */
558- if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata->d_size))
559+ if (INVALID_NDX (ndx, Elf32_Sym, symdata))
560 {
561 __libelf_seterrno (ELF_E_INVALID_INDEX);
562 goto out;
563@@ -139,7 +139,7 @@
564
565 /* The data is already in the correct form. Just make sure the
566 index is OK. */
567- if (unlikely ((ndx + 1) * sizeof (GElf_Sym) > symdata->d_size))
568+ if (INVALID_NDX (ndx, GElf_Sym, symdata))
569 {
570 __libelf_seterrno (ELF_E_INVALID_INDEX);
571 goto out;
572Index: elfutils-0.148/libelf/gelf_getversym.c
573===================================================================
574--- elfutils-0.148.orig/libelf/gelf_getversym.c 2009-01-08 20:56:37.000000000 +0000
575+++ elfutils-0.148/libelf/gelf_getversym.c 2010-07-03 13:07:11.000000000 +0000
576@@ -1,5 +1,5 @@
577 /* Get symbol version information at the given index.
578- Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
579+ Copyright (C) 1999-2009 Red Hat, Inc.
580 This file is part of Red Hat elfutils.
581 Written by Ulrich Drepper <drepper@redhat.com>, 1999.
582
583@@ -92,7 +92,7 @@
584
585 /* The data is already in the correct form. Just make sure the
586 index is OK. */
587- if (unlikely ((ndx + 1) * sizeof (GElf_Versym) > data->d_size))
588+ if (INVALID_NDX (ndx, GElf_Versym, data))
589 {
590 __libelf_seterrno (ELF_E_INVALID_INDEX);
591 result = NULL;
592Index: elfutils-0.148/libelf/gelf_update_dyn.c
593===================================================================
594--- elfutils-0.148.orig/libelf/gelf_update_dyn.c 2009-01-08 20:56:37.000000000 +0000
595+++ elfutils-0.148/libelf/gelf_update_dyn.c 2010-07-03 13:07:11.000000000 +0000
596@@ -1,5 +1,5 @@
597 /* Update information in dynamic table at the given index.
598- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
599+ Copyright (C) 2000-2009 Red Hat, Inc.
600 This file is part of Red Hat elfutils.
601 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
602
603@@ -71,12 +71,6 @@
604 if (data == NULL)
605 return 0;
606
607- if (unlikely (ndx < 0))
608- {
609- __libelf_seterrno (ELF_E_INVALID_INDEX);
610- return 0;
611- }
612-
613 if (unlikely (data_scn->d.d_type != ELF_T_DYN))
614 {
615 /* The type of the data better should match. */
616@@ -102,7 +96,7 @@
617 }
618
619 /* Check whether we have to resize the data buffer. */
620- if (unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size))
621+ if (INVALID_NDX (ndx, Elf32_Dyn, &data_scn->d))
622 {
623 __libelf_seterrno (ELF_E_INVALID_INDEX);
624 goto out;
625@@ -116,7 +110,7 @@
626 else
627 {
628 /* Check whether we have to resize the data buffer. */
629- if (unlikely ((ndx + 1) * sizeof (Elf64_Dyn) > data_scn->d.d_size))
630+ if (INVALID_NDX (ndx, Elf64_Dyn, &data_scn->d))
631 {
632 __libelf_seterrno (ELF_E_INVALID_INDEX);
633 goto out;
634Index: elfutils-0.148/libelf/gelf_update_lib.c
635===================================================================
636--- elfutils-0.148.orig/libelf/gelf_update_lib.c 2009-01-08 20:56:37.000000000 +0000
637+++ elfutils-0.148/libelf/gelf_update_lib.c 2010-07-03 13:07:11.000000000 +0000
638@@ -1,5 +1,5 @@
639 /* Update library in table at the given index.
640- Copyright (C) 2004 Red Hat, Inc.
641+ Copyright (C) 2004-2009 Red Hat, Inc.
642 This file is part of Red Hat elfutils.
643 Written by Ulrich Drepper <drepper@redhat.com>, 2004.
644
645@@ -68,12 +68,6 @@
646 if (data == NULL)
647 return 0;
648
649- if (unlikely (ndx < 0))
650- {
651- __libelf_seterrno (ELF_E_INVALID_INDEX);
652- return 0;
653- }
654-
655 Elf_Data_Scn *data_scn = (Elf_Data_Scn *) data;
656 if (unlikely (data_scn->d.d_type != ELF_T_LIB))
657 {
658@@ -87,7 +81,7 @@
659
660 /* Check whether we have to resize the data buffer. */
661 int result = 0;
662- if (unlikely ((ndx + 1) * sizeof (Elf64_Lib) > data_scn->d.d_size))
663+ if (INVALID_NDX (ndx, Elf64_Lib, &data_scn->d))
664 __libelf_seterrno (ELF_E_INVALID_INDEX);
665 else
666 {
667Index: elfutils-0.148/libelf/gelf_update_move.c
668===================================================================
669--- elfutils-0.148.orig/libelf/gelf_update_move.c 2009-01-08 20:56:37.000000000 +0000
670+++ elfutils-0.148/libelf/gelf_update_move.c 2010-07-03 13:07:11.000000000 +0000
671@@ -1,5 +1,5 @@
672 /* Update move structure at the given index.
673- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
674+ Copyright (C) 2000-2009 Red Hat, Inc.
675 This file is part of Red Hat elfutils.
676 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
677
678@@ -75,8 +75,7 @@
679 assert (sizeof (GElf_Move) == sizeof (Elf64_Move));
680
681 /* Check whether we have to resize the data buffer. */
682- if (unlikely (ndx < 0)
683- || unlikely ((ndx + 1) * sizeof (GElf_Move) > data_scn->d.d_size))
684+ if (INVALID_NDX (ndx, GElf_Move, &data_scn->d))
685 {
686 __libelf_seterrno (ELF_E_INVALID_INDEX);
687 return 0;
688Index: elfutils-0.148/libelf/gelf_update_rela.c
689===================================================================
690--- elfutils-0.148.orig/libelf/gelf_update_rela.c 2009-01-08 20:56:37.000000000 +0000
691+++ elfutils-0.148/libelf/gelf_update_rela.c 2010-07-03 13:07:11.000000000 +0000
692@@ -1,5 +1,5 @@
693 /* Update RELA relocation information at given index.
694- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
695+ Copyright (C) 2000-2009 Red Hat, Inc.
696 This file is part of Red Hat elfutils.
697 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
698
699@@ -68,12 +68,6 @@
700 if (dst == NULL)
701 return 0;
702
703- if (unlikely (ndx < 0))
704- {
705- __libelf_seterrno (ELF_E_INVALID_INDEX);
706- return 0;
707- }
708-
709 if (unlikely (data_scn->d.d_type != ELF_T_RELA))
710 {
711 /* The type of the data better should match. */
712@@ -101,7 +95,7 @@
713 }
714
715 /* Check whether we have to resize the data buffer. */
716- if (unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size))
717+ if (INVALID_NDX (ndx, Elf32_Rela, &data_scn->d))
718 {
719 __libelf_seterrno (ELF_E_INVALID_INDEX);
720 goto out;
721@@ -117,7 +111,7 @@
722 else
723 {
724 /* Check whether we have to resize the data buffer. */
725- if (unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size))
726+ if (INVALID_NDX (ndx, Elf64_Rela, &data_scn->d))
727 {
728 __libelf_seterrno (ELF_E_INVALID_INDEX);
729 goto out;
730Index: elfutils-0.148/libelf/gelf_update_rel.c
731===================================================================
732--- elfutils-0.148.orig/libelf/gelf_update_rel.c 2009-01-08 20:56:37.000000000 +0000
733+++ elfutils-0.148/libelf/gelf_update_rel.c 2010-07-03 13:07:11.000000000 +0000
734@@ -1,5 +1,5 @@
735 /* Update REL relocation information at given index.
736- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
737+ Copyright (C) 2000-2009 Red Hat, Inc.
738 This file is part of Red Hat elfutils.
739 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
740
741@@ -68,12 +68,6 @@
742 if (dst == NULL)
743 return 0;
744
745- if (unlikely (ndx < 0))
746- {
747- __libelf_seterrno (ELF_E_INVALID_INDEX);
748- return 0;
749- }
750-
751 if (unlikely (data_scn->d.d_type != ELF_T_REL))
752 {
753 /* The type of the data better should match. */
754@@ -99,7 +93,7 @@
755 }
756
757 /* Check whether we have to resize the data buffer. */
758- if (unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size))
759+ if (INVALID_NDX (ndx, Elf32_Rel, &data_scn->d))
760 {
761 __libelf_seterrno (ELF_E_INVALID_INDEX);
762 goto out;
763@@ -114,7 +108,7 @@
764 else
765 {
766 /* Check whether we have to resize the data buffer. */
767- if (unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size))
768+ if (INVALID_NDX (ndx, Elf64_Rel, &data_scn->d))
769 {
770 __libelf_seterrno (ELF_E_INVALID_INDEX);
771 goto out;
772Index: elfutils-0.148/libelf/gelf_update_sym.c
773===================================================================
774--- elfutils-0.148.orig/libelf/gelf_update_sym.c 2009-01-08 20:56:37.000000000 +0000
775+++ elfutils-0.148/libelf/gelf_update_sym.c 2010-07-03 13:07:11.000000000 +0000
776@@ -1,5 +1,5 @@
777 /* Update symbol information in symbol table at the given index.
778- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
779+ Copyright (C) 2000-2009 Red Hat, Inc.
780 This file is part of Red Hat elfutils.
781 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
782
783@@ -72,12 +72,6 @@
784 if (data == NULL)
785 return 0;
786
787- if (unlikely (ndx < 0))
788- {
789- __libelf_seterrno (ELF_E_INVALID_INDEX);
790- return 0;
791- }
792-
793 if (unlikely (data_scn->d.d_type != ELF_T_SYM))
794 {
795 /* The type of the data better should match. */
796@@ -102,7 +96,7 @@
797 }
798
799 /* Check whether we have to resize the data buffer. */
800- if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data_scn->d.d_size))
801+ if (INVALID_NDX (ndx, Elf32_Sym, &data_scn->d))
802 {
803 __libelf_seterrno (ELF_E_INVALID_INDEX);
804 goto out;
805@@ -125,7 +119,7 @@
806 else
807 {
808 /* Check whether we have to resize the data buffer. */
809- if (unlikely ((ndx + 1) * sizeof (Elf64_Sym) > data_scn->d.d_size))
810+ if (INVALID_NDX (ndx, Elf64_Sym, &data_scn->d))
811 {
812 __libelf_seterrno (ELF_E_INVALID_INDEX);
813 goto out;
814Index: elfutils-0.148/libelf/gelf_update_syminfo.c
815===================================================================
816--- elfutils-0.148.orig/libelf/gelf_update_syminfo.c 2009-01-08 20:56:37.000000000 +0000
817+++ elfutils-0.148/libelf/gelf_update_syminfo.c 2010-07-03 13:07:11.000000000 +0000
818@@ -1,5 +1,5 @@
819 /* Update additional symbol information in symbol table at the given index.
820- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
821+ Copyright (C) 2000-2009 Red Hat, Inc.
822 This file is part of Red Hat elfutils.
823 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
824
825@@ -72,12 +72,6 @@
826 if (data == NULL)
827 return 0;
828
829- if (unlikely (ndx < 0))
830- {
831- __libelf_seterrno (ELF_E_INVALID_INDEX);
832- return 0;
833- }
834-
835 if (unlikely (data_scn->d.d_type != ELF_T_SYMINFO))
836 {
837 /* The type of the data better should match. */
838@@ -93,7 +87,7 @@
839 rwlock_wrlock (scn->elf->lock);
840
841 /* Check whether we have to resize the data buffer. */
842- if (unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data_scn->d.d_size))
843+ if (INVALID_NDX (ndx, GElf_Syminfo, &data_scn->d))
844 {
845 __libelf_seterrno (ELF_E_INVALID_INDEX);
846 goto out;
847Index: elfutils-0.148/libelf/gelf_update_symshndx.c
848===================================================================
849--- elfutils-0.148.orig/libelf/gelf_update_symshndx.c 2009-01-08 20:56:37.000000000 +0000
850+++ elfutils-0.148/libelf/gelf_update_symshndx.c 2010-07-03 13:07:11.000000000 +0000
851@@ -1,6 +1,6 @@
852 /* Update symbol information and section index in symbol table at the
853 given index.
854- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
855+ Copyright (C) 2000-2009 Red Hat, Inc.
856 This file is part of Red Hat elfutils.
857 Written by Ulrich Drepper <drepper@redhat.com>, 2000.
858
859@@ -77,12 +77,6 @@
860 if (symdata == NULL)
861 return 0;
862
863- if (unlikely (ndx < 0))
864- {
865- __libelf_seterrno (ELF_E_INVALID_INDEX);
866- return 0;
867- }
868-
869 if (unlikely (symdata_scn->d.d_type != ELF_T_SYM))
870 {
871 /* The type of the data better should match. */
872@@ -128,7 +122,7 @@
873 }
874
875 /* Check whether we have to resize the data buffer. */
876- if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata_scn->d.d_size))
877+ if (INVALID_NDX (ndx, Elf32_Sym, &symdata_scn->d))
878 {
879 __libelf_seterrno (ELF_E_INVALID_INDEX);
880 goto out;
881@@ -151,7 +145,7 @@
882 else
883 {
884 /* Check whether we have to resize the data buffer. */
885- if (unlikely ((ndx + 1) * sizeof (Elf64_Sym) > symdata_scn->d.d_size))
886+ if (INVALID_NDX (ndx, Elf64_Sym, &symdata_scn->d))
887 {
888 __libelf_seterrno (ELF_E_INVALID_INDEX);
889 goto out;
890Index: elfutils-0.148/libelf/gelf_update_versym.c
891===================================================================
892--- elfutils-0.148.orig/libelf/gelf_update_versym.c 2009-01-08 20:56:37.000000000 +0000
893+++ elfutils-0.148/libelf/gelf_update_versym.c 2010-07-03 13:07:11.000000000 +0000
894@@ -1,5 +1,5 @@
895 /* Update symbol version information.
896- Copyright (C) 2001, 2002 Red Hat, Inc.
897+ Copyright (C) 2001-2009 Red Hat, Inc.
898 This file is part of Red Hat elfutils.
899 Written by Ulrich Drepper <drepper@redhat.com>, 2001.
900
901@@ -75,8 +75,7 @@
902 assert (sizeof (GElf_Versym) == sizeof (Elf64_Versym));
903
904 /* Check whether we have to resize the data buffer. */
905- if (unlikely (ndx < 0)
906- || unlikely ((ndx + 1) * sizeof (GElf_Versym) > data_scn->d.d_size))
907+ if (INVALID_NDX (ndx, GElf_Versym, &data_scn->d))
908 {
909 __libelf_seterrno (ELF_E_INVALID_INDEX);
910 return 0;
911Index: elfutils-0.148/libelf/libelfP.h
912===================================================================
913--- elfutils-0.148.orig/libelf/libelfP.h 2010-01-12 16:57:54.000000000 +0000
914+++ elfutils-0.148/libelf/libelfP.h 2010-07-03 13:07:11.000000000 +0000
915@@ -608,4 +608,8 @@
916 /* Align offset to 4 bytes as needed for note name and descriptor data. */
917 #define NOTE_ALIGN(n) (((n) + 3) & -4U)
918
919+/* Convenience macro. */
920+#define INVALID_NDX(ndx, type, data) \
921+ unlikely ((data)->d_size / sizeof (type) <= (unsigned int) (ndx))
922+
923 #endif /* libelfP.h */
924Index: elfutils-0.148/src/ChangeLog
925===================================================================
926--- elfutils-0.148.orig/src/ChangeLog 2010-07-03 13:07:10.000000000 +0000
927+++ elfutils-0.148/src/ChangeLog 2010-07-03 13:07:11.000000000 +0000
928@@ -1640,6 +1640,16 @@
929 object symbols or symbols with unknown type.
930 (check_rel): Likewise.
931
932+2005-06-09 Roland McGrath <roland@redhat.com>
933+
934+ * readelf.c (handle_dynamic, handle_symtab): Check for bogus sh_link.
935+ (handle_verneed, handle_verdef, handle_versym, handle_hash): Likewise.
936+ (handle_scngrp): Check for bogus sh_info.
937+
938+ * strip.c (handle_elf): Check for bogus values in sh_link, sh_info,
939+ st_shndx, e_shstrndx, and SHT_GROUP or SHT_SYMTAB_SHNDX data.
940+ Don't use assert on input values, instead bail with "illformed" error.
941+
942 2005-06-08 Roland McGrath <roland@redhat.com>
943
944 * readelf.c (print_ops): Add consts.
945@@ -1690,6 +1700,19 @@
946
947 * readelf.c (dwarf_tag_string): Add new tags.
948
949+2005-05-17 Jakub Jelinek <jakub@redhat.com>
950+
951+ * elflint.c (check_hash): Don't check entries beyond end of section.
952+ (check_note): Don't crash if gelf_rawchunk fails.
953+ (section_name): Return <invalid> if gelf_getshdr returns NULL.
954+
955+2005-05-14 Jakub Jelinek <jakub@redhat.com>
956+
957+ * elflint.c (section_name): Return "<invalid>" instead of
958+ crashing on invalid section name.
959+ (check_symtab, is_rel_dyn, check_rela, check_rel, check_dynamic,
960+ check_symtab_shndx, check_hash, check_versym): Robustify.
961+
962 2005-05-08 Roland McGrath <roland@redhat.com>
963
964 * strip.c (handle_elf): Don't translate hash and versym data formats,
965Index: elfutils-0.148/src/elflint.c
966===================================================================
967--- elfutils-0.148.orig/src/elflint.c 2010-04-13 20:08:02.000000000 +0000
968+++ elfutils-0.148/src/elflint.c 2010-07-03 13:07:11.000000000 +0000
969@@ -131,6 +131,10 @@
970 /* Array to count references in section groups. */
971 static int *scnref;
972
973+/* Numbers of sections and program headers. */
974+static unsigned int shnum;
975+static unsigned int phnum;
976+
977
978 int
979 main (int argc, char *argv[])
980@@ -319,10 +323,19 @@
981 {
982 GElf_Shdr shdr_mem;
983 GElf_Shdr *shdr;
984+ const char *ret;
985+
986+ if ((unsigned int) idx > shnum)
987+ return "<invalid>";
988
989 shdr = gelf_getshdr (elf_getscn (ebl->elf, idx), &shdr_mem);
990+ if (shdr == NULL)
991+ return "<invalid>";
992
993- return elf_strptr (ebl->elf, shstrndx, shdr->sh_name);
994+ ret = elf_strptr (ebl->elf, shstrndx, shdr->sh_name);
995+ if (ret == NULL)
996+ return "<invalid>";
997+ return ret;
998 }
999
1000
1001@@ -344,11 +357,6 @@
1002 (sizeof (valid_e_machine) / sizeof (valid_e_machine[0]))
1003
1004
1005-/* Numbers of sections and program headers. */
1006-static unsigned int shnum;
1007-static unsigned int phnum;
1008-
1009-
1010 static void
1011 check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size)
1012 {
1013@@ -632,7 +640,8 @@
1014 }
1015 }
1016
1017- if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_SYM, 1, EV_CURRENT))
1018+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_SYM, 1, EV_CURRENT);
1019+ if (shdr->sh_entsize != sh_entsize)
1020 ERROR (gettext ("\
1021 section [%2u] '%s': entry size is does not match ElfXX_Sym\n"),
1022 idx, section_name (ebl, idx));
1023@@ -670,7 +679,7 @@
1024 xndxscnidx, section_name (ebl, xndxscnidx));
1025 }
1026
1027- for (size_t cnt = 1; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1028+ for (size_t cnt = 1; cnt < shdr->sh_size / sh_entsize; ++cnt)
1029 {
1030 sym = gelf_getsymshndx (data, xndxdata, cnt, &sym_mem, &xndx);
1031 if (sym == NULL)
1032@@ -690,7 +699,8 @@
1033 else
1034 {
1035 name = elf_strptr (ebl->elf, shdr->sh_link, sym->st_name);
1036- assert (name != NULL);
1037+ assert (name != NULL
1038+ || strshdr->sh_type != SHT_STRTAB);
1039 }
1040
1041 if (sym->st_shndx == SHN_XINDEX)
1042@@ -1038,9 +1048,11 @@
1043 {
1044 GElf_Shdr rcshdr_mem;
1045 const GElf_Shdr *rcshdr = gelf_getshdr (scn, &rcshdr_mem);
1046- assert (rcshdr != NULL);
1047
1048- if (rcshdr->sh_type == SHT_DYNAMIC)
1049+ if (rcshdr == NULL)
1050+ break;
1051+
1052+ if (rcshdr->sh_type == SHT_DYNAMIC && rcshdr->sh_entsize)
1053 {
1054 /* Found the dynamic section. Look through it. */
1055 Elf_Data *d = elf_getdata (scn, NULL);
1056@@ -1050,7 +1062,9 @@
1057 {
1058 GElf_Dyn dyn_mem;
1059 GElf_Dyn *dyn = gelf_getdyn (d, cnt, &dyn_mem);
1060- assert (dyn != NULL);
1061+
1062+ if (dyn == NULL)
1063+ break;
1064
1065 if (dyn->d_tag == DT_RELCOUNT)
1066 {
1067@@ -1064,7 +1078,9 @@
1068 /* Does the number specified number of relative
1069 relocations exceed the total number of
1070 relocations? */
1071- if (dyn->d_un.d_val > shdr->sh_size / shdr->sh_entsize)
1072+ if (shdr->sh_entsize != 0
1073+ && dyn->d_un.d_val > (shdr->sh_size
1074+ / shdr->sh_entsize))
1075 ERROR (gettext ("\
1076 section [%2d] '%s': DT_RELCOUNT value %d too high for this section\n"),
1077 idx, section_name (ebl, idx),
1078@@ -1224,7 +1240,8 @@
1079 }
1080 }
1081
1082- if (shdr->sh_entsize != gelf_fsize (ebl->elf, reltype, 1, EV_CURRENT))
1083+ size_t sh_entsize = gelf_fsize (ebl->elf, reltype, 1, EV_CURRENT);
1084+ if (shdr->sh_entsize != sh_entsize)
1085 ERROR (gettext (reltype == ELF_T_RELA ? "\
1086 section [%2d] '%s': section entry size does not match ElfXX_Rela\n" : "\
1087 section [%2d] '%s': section entry size does not match ElfXX_Rel\n"),
1088@@ -1447,7 +1464,8 @@
1089 Elf_Data *symdata = elf_getdata (symscn, NULL);
1090 enum load_state state = state_undecided;
1091
1092- for (size_t cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1093+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_RELA, 1, EV_CURRENT);
1094+ for (size_t cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt)
1095 {
1096 GElf_Rela rela_mem;
1097 GElf_Rela *rela = gelf_getrela (data, cnt, &rela_mem);
1098@@ -1497,7 +1515,8 @@
1099 Elf_Data *symdata = elf_getdata (symscn, NULL);
1100 enum load_state state = state_undecided;
1101
1102- for (size_t cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1103+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_REL, 1, EV_CURRENT);
1104+ for (size_t cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt)
1105 {
1106 GElf_Rel rel_mem;
1107 GElf_Rel *rel = gelf_getrel (data, cnt, &rel_mem);
1108@@ -1600,7 +1619,8 @@
1109 shdr->sh_link, section_name (ebl, shdr->sh_link),
1110 idx, section_name (ebl, idx));
1111
1112- if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_DYN, 1, EV_CURRENT))
1113+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_DYN, 1, EV_CURRENT);
1114+ if (shdr->sh_entsize != sh_entsize)
1115 ERROR (gettext ("\
1116 section [%2d] '%s': section entry size does not match ElfXX_Dyn\n"),
1117 idx, section_name (ebl, idx));
1118@@ -1610,7 +1630,7 @@
1119 idx, section_name (ebl, idx));
1120
1121 bool non_null_warned = false;
1122- for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1123+ for (cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt)
1124 {
1125 GElf_Dyn dyn_mem;
1126 GElf_Dyn *dyn = gelf_getdyn (data, cnt, &dyn_mem);
1127@@ -1891,6 +1911,8 @@
1128 idx, section_name (ebl, idx));
1129
1130 if (symshdr != NULL
1131+ && shdr->sh_entsize
1132+ && symshdr->sh_entsize
1133 && (shdr->sh_size / shdr->sh_entsize
1134 < symshdr->sh_size / symshdr->sh_entsize))
1135 ERROR (gettext ("\
1136@@ -1917,6 +1939,12 @@
1137 }
1138
1139 Elf_Data *data = elf_getdata (elf_getscn (ebl->elf, idx), NULL);
1140+ if (data == NULL)
1141+ {
1142+ ERROR (gettext ("section [%2d] '%s': cannot get section data\n"),
1143+ idx, section_name (ebl, idx));
1144+ return;
1145+ }
1146
1147 if (*((Elf32_Word *) data->d_buf) != 0)
1148 ERROR (gettext ("symbol 0 should have zero extended section index\n"));
1149@@ -1959,7 +1987,7 @@
1150
1151 size_t maxidx = nchain;
1152
1153- if (symshdr != NULL)
1154+ if (symshdr != NULL && symshdr->sh_entsize != 0)
1155 {
1156 size_t symsize = symshdr->sh_size / symshdr->sh_entsize;
1157
1158@@ -1970,18 +1998,28 @@
1159 maxidx = symsize;
1160 }
1161
1162+ Elf32_Word *buf = (Elf32_Word *) data->d_buf;
1163+ Elf32_Word *end = (Elf32_Word *) ((char *) data->d_buf + shdr->sh_size);
1164 size_t cnt;
1165 for (cnt = 2; cnt < 2 + nbucket; ++cnt)
1166- if (((Elf32_Word *) data->d_buf)[cnt] >= maxidx)
1167+ {
1168+ if (buf + cnt >= end)
1169+ break;
1170+ else if (buf[cnt] >= maxidx)
1171 ERROR (gettext ("\
1172 section [%2d] '%s': hash bucket reference %zu out of bounds\n"),
1173 idx, section_name (ebl, idx), cnt - 2);
1174+ }
1175
1176 for (; cnt < 2 + nbucket + nchain; ++cnt)
1177- if (((Elf32_Word *) data->d_buf)[cnt] >= maxidx)
1178+ {
1179+ if (buf + cnt >= end)
1180+ break;
1181+ else if (buf[cnt] >= maxidx)
1182 ERROR (gettext ("\
1183 section [%2d] '%s': hash chain reference %zu out of bounds\n"),
1184 idx, section_name (ebl, idx), cnt - 2 - nbucket);
1185+ }
1186 }
1187
1188
1189@@ -2011,18 +2049,28 @@
1190 maxidx = symsize;
1191 }
1192
1193+ Elf64_Xword *buf = (Elf64_Xword *) data->d_buf;
1194+ Elf64_Xword *end = (Elf64_Xword *) ((char *) data->d_buf + shdr->sh_size);
1195 size_t cnt;
1196 for (cnt = 2; cnt < 2 + nbucket; ++cnt)
1197- if (((Elf64_Xword *) data->d_buf)[cnt] >= maxidx)
1198+ {
1199+ if (buf + cnt >= end)
1200+ break;
1201+ else if (buf[cnt] >= maxidx)
1202 ERROR (gettext ("\
1203 section [%2d] '%s': hash bucket reference %zu out of bounds\n"),
1204 idx, section_name (ebl, idx), cnt - 2);
1205+ }
1206
1207 for (; cnt < 2 + nbucket + nchain; ++cnt)
1208- if (((Elf64_Xword *) data->d_buf)[cnt] >= maxidx)
1209+ {
1210+ if (buf + cnt >= end)
1211+ break;
1212+ else if (buf[cnt] >= maxidx)
1213 ERROR (gettext ("\
1214 section [%2d] '%s': hash chain reference %" PRIu64 " out of bounds\n"),
1215- idx, section_name (ebl, idx), (uint64_t) (cnt - 2 - nbucket));
1216+ idx, section_name (ebl, idx), (uint64_t) cnt - 2 - nbucket);
1217+ }
1218 }
1219
1220
1221@@ -2047,7 +2095,7 @@
1222 if (shdr->sh_size < (4 + bitmask_words + nbuckets) * sizeof (Elf32_Word))
1223 {
1224 ERROR (gettext ("\
1225-section [%2d] '%s': hash table section is too small (is %ld, expected at least%ld)\n"),
1226+section [%2d] '%s': hash table section is too small (is %ld, expected at least %ld)\n"),
1227 idx, section_name (ebl, idx), (long int) shdr->sh_size,
1228 (long int) ((4 + bitmask_words + nbuckets) * sizeof (Elf32_Word)));
1229 return;
1230@@ -2719,8 +2767,9 @@
1231
1232 /* The number of elements in the version symbol table must be the
1233 same as the number of symbols. */
1234- if (shdr->sh_size / shdr->sh_entsize
1235- != symshdr->sh_size / symshdr->sh_entsize)
1236+ if (shdr->sh_entsize && symshdr->sh_entsize
1237+ && (shdr->sh_size / shdr->sh_entsize
1238+ != symshdr->sh_size / symshdr->sh_entsize))
1239 ERROR (gettext ("\
1240 section [%2d] '%s' has different number of entries than symbol table [%2d] '%s'\n"),
1241 idx, section_name (ebl, idx),
1242Index: elfutils-0.148/src/readelf.c
1243===================================================================
1244--- elfutils-0.148.orig/src/readelf.c 2010-07-03 13:07:10.000000000 +0000
1245+++ elfutils-0.148/src/readelf.c 2010-07-03 13:07:11.000000000 +0000
1246@@ -1172,6 +1172,8 @@
1247 Elf32_Word *grpref = (Elf32_Word *) data->d_buf;
1248
1249 GElf_Sym sym_mem;
1250+ GElf_Sym *sym = gelf_getsym (symdata, shdr->sh_info, &sym_mem);
1251+
1252 printf ((grpref[0] & GRP_COMDAT)
1253 ? ngettext ("\
1254 \nCOMDAT section group [%2zu] '%s' with signature '%s' contains %zu entry:\n",
1255@@ -1184,8 +1186,8 @@
1256 data->d_size / sizeof (Elf32_Word) - 1),
1257 elf_ndxscn (scn),
1258 elf_strptr (ebl->elf, shstrndx, shdr->sh_name),
1259- elf_strptr (ebl->elf, symshdr->sh_link,
1260- gelf_getsym (symdata, shdr->sh_info, &sym_mem)->st_name)
1261+ (sym == NULL ? NULL
1262+ : elf_strptr (ebl->elf, symshdr->sh_link, sym->st_name))
1263 ?: gettext ("<INVALID SYMBOL>"),
1264 data->d_size / sizeof (Elf32_Word) - 1);
1265
1266@@ -1336,7 +1338,8 @@
1267 handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr)
1268 {
1269 int class = gelf_getclass (ebl->elf);
1270- GElf_Shdr glink;
1271+ GElf_Shdr glink_mem;
1272+ GElf_Shdr *glink;
1273 Elf_Data *data;
1274 size_t cnt;
1275 size_t shstrndx;
1276@@ -1351,6 +1354,11 @@
1277 error (EXIT_FAILURE, 0,
1278 gettext ("cannot get section header string table index"));
1279
1280+ glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &glink_mem);
1281+ if (glink == NULL)
1282+ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
1283+ elf_ndxscn (scn));
1284+
1285 printf (ngettext ("\
1286 \nDynamic segment contains %lu entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n",
1287 "\
1288@@ -1360,9 +1368,7 @@
1289 class == ELFCLASS32 ? 10 : 18, shdr->sh_addr,
1290 shdr->sh_offset,
1291 (int) shdr->sh_link,
1292- elf_strptr (ebl->elf, shstrndx,
1293- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1294- &glink)->sh_name));
1295+ elf_strptr (ebl->elf, shstrndx, glink->sh_name));
1296 fputs_unlocked (gettext (" Type Value\n"), stdout);
1297
1298 for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1299@@ -1945,6 +1951,13 @@
1300 error (EXIT_FAILURE, 0,
1301 gettext ("cannot get section header string table index"));
1302
1303+ GElf_Shdr glink_mem;
1304+ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1305+ &glink_mem);
1306+ if (glink == NULL)
1307+ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
1308+ elf_ndxscn (scn));
1309+
1310 /* Now we can compute the number of entries in the section. */
1311 unsigned int nsyms = data->d_size / (class == ELFCLASS32
1312 ? sizeof (Elf32_Sym)
1313@@ -1955,15 +1968,12 @@
1314 nsyms),
1315 (unsigned int) elf_ndxscn (scn),
1316 elf_strptr (ebl->elf, shstrndx, shdr->sh_name), nsyms);
1317- GElf_Shdr glink;
1318 printf (ngettext (" %lu local symbol String table: [%2u] '%s'\n",
1319 " %lu local symbols String table: [%2u] '%s'\n",
1320 shdr->sh_info),
1321 (unsigned long int) shdr->sh_info,
1322 (unsigned int) shdr->sh_link,
1323- elf_strptr (ebl->elf, shstrndx,
1324- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1325- &glink)->sh_name));
1326+ elf_strptr (ebl->elf, shstrndx, glink->sh_name));
1327
1328 fputs_unlocked (class == ELFCLASS32
1329 ? gettext ("\
1330@@ -2199,7 +2209,13 @@
1331 error (EXIT_FAILURE, 0,
1332 gettext ("cannot get section header string table index"));
1333
1334- GElf_Shdr glink;
1335+ GElf_Shdr glink_mem;
1336+ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1337+ &glink_mem);
1338+ if (glink == NULL)
1339+ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
1340+ elf_ndxscn (scn));
1341+
1342 printf (ngettext ("\
1343 \nVersion needs section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n",
1344 "\
1345@@ -2210,9 +2226,7 @@
1346 class == ELFCLASS32 ? 10 : 18, shdr->sh_addr,
1347 shdr->sh_offset,
1348 (unsigned int) shdr->sh_link,
1349- elf_strptr (ebl->elf, shstrndx,
1350- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1351- &glink)->sh_name));
1352+ elf_strptr (ebl->elf, shstrndx, glink->sh_name));
1353
1354 unsigned int offset = 0;
1355 for (int cnt = shdr->sh_info; --cnt >= 0; )
1356@@ -2265,8 +2279,14 @@
1357 error (EXIT_FAILURE, 0,
1358 gettext ("cannot get section header string table index"));
1359
1360+ GElf_Shdr glink_mem;
1361+ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1362+ &glink_mem);
1363+ if (glink == NULL)
1364+ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
1365+ elf_ndxscn (scn));
1366+
1367 int class = gelf_getclass (ebl->elf);
1368- GElf_Shdr glink;
1369 printf (ngettext ("\
1370 \nVersion definition section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n",
1371 "\
1372@@ -2278,9 +2298,7 @@
1373 class == ELFCLASS32 ? 10 : 18, shdr->sh_addr,
1374 shdr->sh_offset,
1375 (unsigned int) shdr->sh_link,
1376- elf_strptr (ebl->elf, shstrndx,
1377- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1378- &glink)->sh_name));
1379+ elf_strptr (ebl->elf, shstrndx, glink->sh_name));
1380
1381 unsigned int offset = 0;
1382 for (int cnt = shdr->sh_info; --cnt >= 0; )
1383@@ -2542,8 +2560,14 @@
1384 filename = NULL;
1385 }
1386
1387+ GElf_Shdr glink_mem;
1388+ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1389+ &glink_mem);
1390+ if (glink == NULL)
1391+ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"),
1392+ elf_ndxscn (scn));
1393+
1394 /* Print the header. */
1395- GElf_Shdr glink;
1396 printf (ngettext ("\
1397 \nVersion symbols section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'",
1398 "\
1399@@ -2555,9 +2579,7 @@
1400 class == ELFCLASS32 ? 10 : 18, shdr->sh_addr,
1401 shdr->sh_offset,
1402 (unsigned int) shdr->sh_link,
1403- elf_strptr (ebl->elf, shstrndx,
1404- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1405- &glink)->sh_name));
1406+ elf_strptr (ebl->elf, shstrndx, glink->sh_name));
1407
1408 /* Now we can finally look at the actual contents of this section. */
1409 for (unsigned int cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
1410@@ -2609,7 +2631,17 @@
1411 for (Elf32_Word cnt = 0; cnt < nbucket; ++cnt)
1412 ++counts[lengths[cnt]];
1413
1414- GElf_Shdr glink;
1415+ GElf_Shdr glink_mem;
1416+ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf,
1417+ shdr->sh_link),
1418+ &glink_mem);
1419+ if (glink == NULL)
1420+ {
1421+ error (0, 0, gettext ("invalid sh_link value in section %Zu"),
1422+ elf_ndxscn (scn));
1423+ return;
1424+ }
1425+
1426 printf (ngettext ("\
1427 \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",
1428 "\
1429@@ -2622,9 +2654,7 @@
1430 shdr->sh_addr,
1431 shdr->sh_offset,
1432 (unsigned int) shdr->sh_link,
1433- elf_strptr (ebl->elf, shstrndx,
1434- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link),
1435- &glink)->sh_name));
1436+ elf_strptr (ebl->elf, shstrndx, glink->sh_name));
1437
1438 if (extrastr != NULL)
1439 fputs (extrastr, stdout);
1440@@ -4312,6 +4342,16 @@
1441 return;
1442 }
1443
1444+ GElf_Shdr glink_mem;
1445+ GElf_Shdr *glink;
1446+ glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &glink_mem);
1447+ if (glink == NULL)
1448+ {
1449+ error (0, 0, gettext ("invalid sh_link value in section %Zu"),
1450+ elf_ndxscn (scn));
1451+ return;
1452+ }
1453+
1454 printf (ngettext ("\
1455 \nDWARF section [%2zu] '%s' at offset %#" PRIx64 " contains %zu entry:\n",
1456 "\
1457Index: elfutils-0.148/src/strip.c
1458===================================================================
1459--- elfutils-0.148.orig/src/strip.c 2010-07-03 13:07:10.000000000 +0000
1460+++ elfutils-0.148/src/strip.c 2010-07-03 13:07:11.000000000 +0000
1461@@ -561,6 +561,11 @@
1462 goto fail_close;
1463 }
1464
1465+ if (shstrndx >= shnum)
1466+ goto illformed;
1467+
1468+#define elf_assert(test) do { if (!(test)) goto illformed; } while (0)
1469+
1470 /* Storage for section information. We leave room for two more
1471 entries since we unconditionally create a section header string
1472 table. Maybe some weird tool created an ELF file without one.
1473@@ -582,7 +587,7 @@
1474 {
1475 /* This should always be true (i.e., there should not be any
1476 holes in the numbering). */
1477- assert (elf_ndxscn (scn) == cnt);
1478+ elf_assert (elf_ndxscn (scn) == cnt);
1479
1480 shdr_info[cnt].scn = scn;
1481
1482@@ -595,6 +600,7 @@
1483 shdr_info[cnt].shdr.sh_name);
1484 if (shdr_info[cnt].name == NULL)
1485 {
1486+ illformed:
1487 error (0, 0, gettext ("illformed file '%s'"), fname);
1488 goto fail_close;
1489 }
1490@@ -604,6 +610,8 @@
1491
1492 /* Remember the shdr.sh_link value. */
1493 shdr_info[cnt].old_sh_link = shdr_info[cnt].shdr.sh_link;
1494+ if (shdr_info[cnt].old_sh_link >= shnum)
1495+ goto illformed;
1496
1497 /* Sections in files other than relocatable object files which
1498 are not loaded can be freely moved by us. In relocatable
1499@@ -616,7 +624,7 @@
1500 appropriate reference. */
1501 if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX))
1502 {
1503- assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0);
1504+ elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0);
1505 shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx = cnt;
1506 }
1507 else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GROUP))
1508@@ -633,7 +641,12 @@
1509 for (inner = 1;
1510 inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word);
1511 ++inner)
1512+ {
1513+ if (grpref[inner] < shnum)
1514 shdr_info[grpref[inner]].group_idx = cnt;
1515+ else
1516+ goto illformed;
1517+ }
1518
1519 if (inner == 1 || (inner == 2 && (grpref[0] & GRP_COMDAT) == 0))
1520 /* If the section group contains only one element and this
1521@@ -644,7 +657,7 @@
1522 }
1523 else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym))
1524 {
1525- assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0);
1526+ elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0);
1527 shdr_info[shdr_info[cnt].shdr.sh_link].version_idx = cnt;
1528 }
1529
1530@@ -652,7 +665,7 @@
1531 discarded right away. */
1532 if ((shdr_info[cnt].shdr.sh_flags & SHF_GROUP) != 0)
1533 {
1534- assert (shdr_info[cnt].group_idx != 0);
1535+ elf_assert (shdr_info[cnt].group_idx != 0);
1536
1537 if (shdr_info[shdr_info[cnt].group_idx].idx == 0)
1538 {
1539@@ -727,11 +740,15 @@
1540 {
1541 /* If a relocation section is marked as being removed make
1542 sure the section it is relocating is removed, too. */
1543- if ((shdr_info[cnt].shdr.sh_type == SHT_REL
1544+ if (shdr_info[cnt].shdr.sh_type == SHT_REL
1545 || shdr_info[cnt].shdr.sh_type == SHT_RELA)
1546- && shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0)
1547+ {
1548+ if (shdr_info[cnt].shdr.sh_info >= shnum)
1549+ goto illformed;
1550+ else if (shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0)
1551 shdr_info[cnt].idx = 1;
1552 }
1553+ }
1554
1555 if (shdr_info[cnt].idx == 1)
1556 {
1557@@ -758,7 +775,7 @@
1558 if (shdr_info[cnt].symtab_idx != 0
1559 && shdr_info[shdr_info[cnt].symtab_idx].data == NULL)
1560 {
1561- assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB);
1562+ elf_assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB);
1563
1564 shdr_info[shdr_info[cnt].symtab_idx].data
1565 = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
1566@@ -798,6 +815,9 @@
1567 else if (scnidx == SHN_XINDEX)
1568 scnidx = xndx;
1569
1570+ if (scnidx >= shnum)
1571+ goto illformed;
1572+
1573 if (shdr_info[scnidx].idx == 0)
1574 /* This symbol table has a real symbol in
1575 a discarded section. So preserve the
1576@@ -828,12 +848,16 @@
1577 }
1578
1579 /* Handle references through sh_info. */
1580- if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)
1581- && shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0)
1582+ if (SH_INFO_LINK_P (&shdr_info[cnt].shdr))
1583+ {
1584+ if (shdr_info[cnt].shdr.sh_info >= shnum)
1585+ goto illformed;
1586+ else if ( shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0)
1587 {
1588 shdr_info[shdr_info[cnt].shdr.sh_info].idx = 1;
1589 changes |= shdr_info[cnt].shdr.sh_info < cnt;
1590 }
1591+ }
1592
1593 /* Mark the section as investigated. */
1594 shdr_info[cnt].idx = 2;
1595@@ -972,7 +996,7 @@
1596 error (EXIT_FAILURE, 0, gettext ("while generating output file: %s"),
1597 elf_errmsg (-1));
1598
1599- assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
1600+ elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
1601
1602 /* Add this name to the section header string table. */
1603 shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0);
1604@@ -1009,7 +1033,7 @@
1605 error (EXIT_FAILURE, 0,
1606 gettext ("while create section header section: %s"),
1607 elf_errmsg (-1));
1608- assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
1609+ elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
1610
1611 shdr_info[cnt].data = elf_newdata (shdr_info[cnt].newscn);
1612 if (shdr_info[cnt].data == NULL)
1613@@ -1065,7 +1089,7 @@
1614 error (EXIT_FAILURE, 0,
1615 gettext ("while create section header section: %s"),
1616 elf_errmsg (-1));
1617- assert (elf_ndxscn (shdr_info[cnt].newscn) == idx);
1618+ elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == idx);
1619
1620 /* Finalize the string table and fill in the correct indices in the
1621 section headers. */
1622@@ -1155,20 +1179,20 @@
1623 shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
1624 NULL);
1625
1626- assert ((versiondata->d_size / sizeof (Elf32_Word))
1627+ elf_assert ((versiondata->d_size / sizeof (Elf32_Word))
1628 >= shdr_info[cnt].data->d_size / elsize);
1629 }
1630
1631 if (shdr_info[cnt].version_idx != 0)
1632 {
1633- assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM);
1634+ elf_assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM);
1635 /* This section has associated version
1636 information. We have to modify that
1637 information, too. */
1638 versiondata = elf_getdata (shdr_info[shdr_info[cnt].version_idx].scn,
1639 NULL);
1640
1641- assert ((versiondata->d_size / sizeof (GElf_Versym))
1642+ elf_assert ((versiondata->d_size / sizeof (GElf_Versym))
1643 >= shdr_info[cnt].data->d_size / elsize);
1644 }
1645
1646@@ -1223,7 +1247,7 @@
1647 sec = shdr_info[sym->st_shndx].idx;
1648 else
1649 {
1650- assert (shndxdata != NULL);
1651+ elf_assert (shndxdata != NULL);
1652
1653 sec = shdr_info[xshndx].idx;
1654 }
1655@@ -1244,7 +1268,7 @@
1656 nxshndx = sec;
1657 }
1658
1659- assert (sec < SHN_LORESERVE || shndxdata != NULL);
1660+ elf_assert (sec < SHN_LORESERVE || shndxdata != NULL);
1661
1662 if ((inner != destidx || nshndx != sym->st_shndx
1663 || (shndxdata != NULL && nxshndx != xshndx))
1664@@ -1268,7 +1292,7 @@
1665 || shdr_info[cnt].debug_data == NULL)
1666 /* This is a section symbol for a section which has
1667 been removed. */
1668- assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION);
1669+ elf_assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION);
1670 }
1671
1672 if (destidx != inner)
1673@@ -1455,11 +1479,11 @@
1674 {
1675 GElf_Sym sym_mem;
1676 GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem);
1677- assert (sym != NULL);
1678+ elf_assert (sym != NULL);
1679
1680 const char *name = elf_strptr (elf, strshndx,
1681 sym->st_name);
1682- assert (name != NULL);
1683+ elf_assert (name != NULL);
1684 size_t hidx = elf_hash (name) % nbucket;
1685
1686 if (bucket[hidx] == 0)
1687@@ -1478,7 +1502,7 @@
1688 else
1689 {
1690 /* Alpha and S390 64-bit use 64-bit SHT_HASH entries. */
1691- assert (shdr_info[cnt].shdr.sh_entsize
1692+ elf_assert (shdr_info[cnt].shdr.sh_entsize
1693 == sizeof (Elf64_Xword));
1694
1695 Elf64_Xword *bucket = (Elf64_Xword *) hashd->d_buf;
1696@@ -1509,11 +1533,11 @@
1697 {
1698 GElf_Sym sym_mem;
1699 GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem);
1700- assert (sym != NULL);
1701+ elf_assert (sym != NULL);
1702
1703 const char *name = elf_strptr (elf, strshndx,
1704 sym->st_name);
1705- assert (name != NULL);
1706+ elf_assert (name != NULL);
1707 size_t hidx = elf_hash (name) % nbucket;
1708
1709 if (bucket[hidx] == 0)
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.148/remove-unused.patch b/meta/recipes-devtools/elfutils/elfutils-0.148/remove-unused.patch
new file mode 100644
index 0000000000..6a19791480
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/elfutils-0.148/remove-unused.patch
@@ -0,0 +1,154 @@
1Upstream-Status: Backport
2
3Remove unused variables from the code to prevent -Werror causing a build
4failure on hosts with GCC 4.6.
5
6These changes are all upstream so should not be required once we've updated
7to elfutils 0.152 or later. Therefore this patch consolidates several
8changes from elfutils upstream by Roland McGrath into a single file so that
9it's easier to remove later once we upgrade.
10Links to upstream gitweb of the consolidated commits follow:
11- http://git.fedorahosted.org/git?p=elfutils.git;a=commit;h=7094d00a169afb27e0323f8580e817798ae7c240
12- http://git.fedorahosted.org/git?p=elfutils.git;a=commit;h=fd992543185126eb0280c1ee0883e073020499b4
13- http://git.fedorahosted.org/git?p=elfutils.git;a=commit;h=4db89f04bb59327abd7a3b60e88f2e7e73c65c79
14- http://git.fedorahosted.org/git?p=elfutils.git;a=commit;h=8f6c1795ab9d41f03805eebd55767070ade55aac
15- http://git.fedorahosted.org/git?p=elfutils.git;a=commit;h=240784b48aa276822c5a61c9ad6a4355051ce259
16
17Joshua Lock <josh@linux.intel.com> - 06/04/11
18
19Index: elfutils-0.148/libasm/asm_newscn.c
20===================================================================
21--- elfutils-0.148.orig/libasm/asm_newscn.c
22+++ elfutils-0.148/libasm/asm_newscn.c
23@@ -162,7 +162,6 @@ asm_newscn (ctx, scnname, type, flags)
24 GElf_Xword flags;
25 {
26 size_t scnname_len = strlen (scnname) + 1;
27- unsigned long int hval;
28 AsmScn_t *result;
29
30 /* If no context is given there might be an earlier error. */
31@@ -180,8 +179,6 @@ asm_newscn (ctx, scnname, type, flags)
32 return NULL;
33 }
34
35- hval = elf_hash (scnname);
36-
37 rwlock_wrlock (ctx->lock);
38
39 /* This is a new section. */
40Index: elfutils-0.148/src/elflint.c
41===================================================================
42--- elfutils-0.148.orig/src/elflint.c
43+++ elfutils-0.148/src/elflint.c
44@@ -707,9 +707,10 @@ section [%2d] '%s': symbol %zu: invalid
45 {
46 if (xndxdata == NULL)
47 {
48- ERROR (gettext ("\
49+ if (!no_xndx_warned)
50+ ERROR (gettext ("\
51 section [%2d] '%s': symbol %zu: too large section index but no extended section index section\n"),
52- idx, section_name (ebl, idx), cnt);
53+ idx, section_name (ebl, idx), cnt);
54 no_xndx_warned = true;
55 }
56 else if (xndx < SHN_LORESERVE)
57@@ -1592,10 +1593,6 @@ check_dynamic (Ebl *ebl, GElf_Ehdr *ehdr
58 [DT_STRSZ] = true,
59 [DT_SYMENT] = true
60 };
61- GElf_Addr reladdr = 0;
62- GElf_Word relsz = 0;
63- GElf_Addr pltreladdr = 0;
64- GElf_Word pltrelsz = 0;
65
66 memset (has_dt, '\0', sizeof (has_dt));
67 memset (has_val_dt, '\0', sizeof (has_val_dt));
68@@ -1694,15 +1691,6 @@ section [%2d] '%s': entry %zu: level 2 t
69 section [%2d] '%s': entry %zu: DT_PLTREL value must be DT_REL or DT_RELA\n"),
70 idx, section_name (ebl, idx), cnt);
71
72- if (dyn->d_tag == DT_REL)
73- reladdr = dyn->d_un.d_ptr;
74- if (dyn->d_tag == DT_RELSZ)
75- relsz = dyn->d_un.d_val;
76- if (dyn->d_tag == DT_JMPREL)
77- pltreladdr = dyn->d_un.d_ptr;
78- if (dyn->d_tag == DT_PLTRELSZ)
79- pltrelsz = dyn->d_un.d_val;
80-
81 /* Check that addresses for entries are in loaded segments. */
82 switch (dyn->d_tag)
83 {
84Index: elfutils-0.148/src/ldgeneric.c
85===================================================================
86--- elfutils-0.148.orig/src/ldgeneric.c
87+++ elfutils-0.148/src/ldgeneric.c
88@@ -285,12 +285,10 @@ static int
89 check_for_duplicate2 (struct usedfiles *newp, struct usedfiles *list)
90 {
91 struct usedfiles *first;
92- struct usedfiles *prevp;
93
94 if (list == NULL)
95 return 0;
96
97- prevp = list;
98 list = first = list->next;
99 do
100 {
101Index: elfutils-0.148/src/ldscript.y
102===================================================================
103--- elfutils-0.148.orig/src/ldscript.y
104+++ elfutils-0.148/src/ldscript.y
105@@ -802,12 +802,9 @@ add_versions (struct version *versions)
106
107 do
108 {
109- struct version *oldp;
110-
111 add_id_list (versions->versionname, versions->local_names, true);
112 add_id_list (versions->versionname, versions->global_names, false);
113
114- oldp = versions;
115 versions = versions->next;
116 }
117 while (versions != NULL);
118Index: elfutils-0.148/src/unstrip.c
119===================================================================
120--- elfutils-0.148.orig/src/unstrip.c
121+++ elfutils-0.148/src/unstrip.c
122@@ -1301,7 +1301,6 @@ more sections in stripped file than debu
123 /* Match each debuginfo section with its corresponding stripped section. */
124 bool check_prelink = false;
125 Elf_Scn *unstripped_symtab = NULL;
126- size_t unstripped_strtab_ndx = SHN_UNDEF;
127 size_t alloc_avail = 0;
128 scn = NULL;
129 while ((scn = elf_nextscn (unstripped, scn)) != NULL)
130@@ -1313,7 +1312,6 @@ more sections in stripped file than debu
131 if (shdr->sh_type == SHT_SYMTAB)
132 {
133 unstripped_symtab = scn;
134- unstripped_strtab_ndx = shdr->sh_link;
135 continue;
136 }
137
138Index: elfutils-0.148/src/ldscript.c
139===================================================================
140--- elfutils-0.148.orig/src/ldscript.c
141+++ elfutils-0.148/src/ldscript.c
142@@ -2728,12 +2728,9 @@ add_versions (struct version *versions)
143
144 do
145 {
146- struct version *oldp;
147-
148 add_id_list (versions->versionname, versions->local_names, true);
149 add_id_list (versions->versionname, versions->global_names, false);
150
151- oldp = versions;
152 versions = versions->next;
153 }
154 while (versions != NULL);
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.148/testsuite-ignore-elflint.diff b/meta/recipes-devtools/elfutils/elfutils-0.148/testsuite-ignore-elflint.diff
new file mode 100644
index 0000000000..d792d5fd73
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/elfutils-0.148/testsuite-ignore-elflint.diff
@@ -0,0 +1,21 @@
1Upstream-Status: Backport
2
3On many architectures this test fails because binaries/libs produced by
4binutils don't pass elflint. However elfutils shouldn't FTBFS because of this.
5
6So we run the tests on all archs to see what breaks, but if it breaks we ignore
7the result (exitcode 77 means: this test was skipped).
8
9Index: elfutils-0.128/tests/run-elflint-self.sh
10===================================================================
11--- elfutils-0.128.orig/tests/run-elflint-self.sh 2007-07-08 21:46:16.000000000 +0000
12+++ elfutils-0.128/tests/run-elflint-self.sh 2007-07-08 21:46:49.000000000 +0000
13@@ -32,7 +32,7 @@
14 # echo $1
15 if [ -f $1 ]; then
16 testrun ../src/elflint --quiet --gnu-ld $1 ||
17- { echo "*** failure in $1"; status=1; }
18+ { echo "*** failure in $1"; status=77; }
19 fi
20 }
21