summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/elfutils/elfutils-0.161/mips_backend.diff
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/elfutils/elfutils-0.161/mips_backend.diff')
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.161/mips_backend.diff712
1 files changed, 712 insertions, 0 deletions
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.161/mips_backend.diff b/meta/recipes-devtools/elfutils/elfutils-0.161/mips_backend.diff
new file mode 100644
index 0000000000..d73a3f2869
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/elfutils-0.161/mips_backend.diff
@@ -0,0 +1,712 @@
1Index: elfutils-0.158/backends/mips_init.c
2===================================================================
3--- /dev/null 1970-01-01 00:00:00.000000000 +0000
4+++ elfutils-0.158/backends/mips_init.c 2014-04-21 11:13:36.910235965 +0000
5@@ -0,0 +1,60 @@
6+/* Initialization of mips specific backend library.
7+ Copyright (C) 2006 Red Hat, Inc.
8+ This file is part of Red Hat elfutils.
9+
10+ Red Hat elfutils is free software; you can redistribute it and/or modify
11+ it under the terms of the GNU General Public License as published by the
12+ Free Software Foundation; version 2 of the License.
13+
14+ Red Hat elfutils is distributed in the hope that it will be useful, but
15+ WITHOUT ANY WARRANTY; without even the implied warranty of
16+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+ General Public License for more details.
18+
19+ You should have received a copy of the GNU General Public License along
20+ with Red Hat elfutils; if not, write to the Free Software Foundation,
21+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
22+
23+ Red Hat elfutils is an included package of the Open Invention Network.
24+ An included package of the Open Invention Network is a package for which
25+ Open Invention Network licensees cross-license their patents. No patent
26+ license is granted, either expressly or impliedly, by designation as an
27+ included package. Should you wish to participate in the Open Invention
28+ Network licensing program, please visit www.openinventionnetwork.com
29+ <http://www.openinventionnetwork.com>. */
30+
31+#ifdef HAVE_CONFIG_H
32+# include <config.h>
33+#endif
34+
35+#define BACKEND mips_
36+#define RELOC_PREFIX R_MIPS_
37+#include "libebl_CPU.h"
38+
39+/* This defines the common reloc hooks based on mips_reloc.def. */
40+#include "common-reloc.c"
41+
42+const char *
43+mips_init (elf, machine, eh, ehlen)
44+ Elf *elf __attribute__ ((unused));
45+ GElf_Half machine __attribute__ ((unused));
46+ Ebl *eh;
47+ size_t ehlen;
48+{
49+ /* Check whether the Elf_BH object has a sufficent size. */
50+ if (ehlen < sizeof (Ebl))
51+ return NULL;
52+
53+ /* We handle it. */
54+ if (machine == EM_MIPS)
55+ eh->name = "MIPS R3000 big-endian";
56+ else if (machine == EM_MIPS_RS3_LE)
57+ eh->name = "MIPS R3000 little-endian";
58+
59+ mips_init_reloc (eh);
60+ HOOK (eh, reloc_simple_type);
61+ HOOK (eh, return_value_location);
62+ HOOK (eh, register_info);
63+
64+ return MODVERSION;
65+}
66Index: elfutils-0.158/backends/mips_regs.c
67===================================================================
68--- /dev/null 1970-01-01 00:00:00.000000000 +0000
69+++ elfutils-0.158/backends/mips_regs.c 2014-04-21 11:13:36.910235965 +0000
70@@ -0,0 +1,104 @@
71+/* Register names and numbers for MIPS DWARF.
72+ Copyright (C) 2006 Red Hat, Inc.
73+ This file is part of Red Hat elfutils.
74+
75+ Red Hat elfutils is free software; you can redistribute it and/or modify
76+ it under the terms of the GNU General Public License as published by the
77+ Free Software Foundation; version 2 of the License.
78+
79+ Red Hat elfutils is distributed in the hope that it will be useful, but
80+ WITHOUT ANY WARRANTY; without even the implied warranty of
81+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
82+ General Public License for more details.
83+
84+ You should have received a copy of the GNU General Public License along
85+ with Red Hat elfutils; if not, write to the Free Software Foundation,
86+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
87+
88+ Red Hat elfutils is an included package of the Open Invention Network.
89+ An included package of the Open Invention Network is a package for which
90+ Open Invention Network licensees cross-license their patents. No patent
91+ license is granted, either expressly or impliedly, by designation as an
92+ included package. Should you wish to participate in the Open Invention
93+ Network licensing program, please visit www.openinventionnetwork.com
94+ <http://www.openinventionnetwork.com>. */
95+
96+#ifdef HAVE_CONFIG_H
97+# include <config.h>
98+#endif
99+
100+#include <string.h>
101+#include <dwarf.h>
102+
103+#define BACKEND mips_
104+#include "libebl_CPU.h"
105+
106+ssize_t
107+mips_register_info (Ebl *ebl __attribute__((unused)),
108+ int regno, char *name, size_t namelen,
109+ const char **prefix, const char **setname,
110+ int *bits, int *type)
111+{
112+ if (name == NULL)
113+ return 66;
114+
115+ if (regno < 0 || regno > 65 || namelen < 4)
116+ return -1;
117+
118+ *prefix = "$";
119+
120+ if (regno < 32)
121+ {
122+ *setname = "integer";
123+ *type = DW_ATE_signed;
124+ *bits = 32;
125+ if (regno < 32 + 10)
126+ {
127+ name[0] = regno + '0';
128+ namelen = 1;
129+ }
130+ else
131+ {
132+ name[0] = (regno / 10) + '0';
133+ name[1] = (regno % 10) + '0';
134+ namelen = 2;
135+ }
136+ }
137+ else if (regno < 64)
138+ {
139+ *setname = "FPU";
140+ *type = DW_ATE_float;
141+ *bits = 32;
142+ name[0] = 'f';
143+ if (regno < 32 + 10)
144+ {
145+ name[1] = (regno - 32) + '0';
146+ namelen = 2;
147+ }
148+ else
149+ {
150+ name[1] = (regno - 32) / 10 + '0';
151+ name[2] = (regno - 32) % 10 + '0';
152+ namelen = 3;
153+ }
154+ }
155+ else if (regno == 64)
156+ {
157+ *type = DW_ATE_signed;
158+ *bits = 32;
159+ name[0] = 'h';
160+ name[1] = 'i';
161+ namelen = 2;
162+ }
163+ else
164+ {
165+ *type = DW_ATE_signed;
166+ *bits = 32;
167+ name[0] = 'l';
168+ name[1] = 'o';
169+ namelen = 2;
170+ }
171+
172+ name[namelen++] = '\0';
173+ return namelen;
174+}
175Index: elfutils-0.158/backends/mips_reloc.def
176===================================================================
177--- /dev/null 1970-01-01 00:00:00.000000000 +0000
178+++ elfutils-0.158/backends/mips_reloc.def 2014-04-21 11:13:36.910235965 +0000
179@@ -0,0 +1,79 @@
180+/* List the relocation types for mips. -*- C -*-
181+ Copyright (C) 2006 Red Hat, Inc.
182+ This file is part of Red Hat elfutils.
183+
184+ Red Hat elfutils is free software; you can redistribute it and/or modify
185+ it under the terms of the GNU General Public License as published by the
186+ Free Software Foundation; version 2 of the License.
187+
188+ Red Hat elfutils is distributed in the hope that it will be useful, but
189+ WITHOUT ANY WARRANTY; without even the implied warranty of
190+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
191+ General Public License for more details.
192+
193+ You should have received a copy of the GNU General Public License along
194+ with Red Hat elfutils; if not, write to the Free Software Foundation,
195+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
196+
197+ Red Hat elfutils is an included package of the Open Invention Network.
198+ An included package of the Open Invention Network is a package for which
199+ Open Invention Network licensees cross-license their patents. No patent
200+ license is granted, either expressly or impliedly, by designation as an
201+ included package. Should you wish to participate in the Open Invention
202+ Network licensing program, please visit www.openinventionnetwork.com
203+ <http://www.openinventionnetwork.com>. */
204+
205+/* NAME, REL|EXEC|DYN */
206+
207+RELOC_TYPE (NONE, 0)
208+RELOC_TYPE (16, 0)
209+RELOC_TYPE (32, 0)
210+RELOC_TYPE (REL32, 0)
211+RELOC_TYPE (26, 0)
212+RELOC_TYPE (HI16, 0)
213+RELOC_TYPE (LO16, 0)
214+RELOC_TYPE (GPREL16, 0)
215+RELOC_TYPE (LITERAL, 0)
216+RELOC_TYPE (GOT16, 0)
217+RELOC_TYPE (PC16, 0)
218+RELOC_TYPE (CALL16, 0)
219+RELOC_TYPE (GPREL32, 0)
220+
221+RELOC_TYPE (SHIFT5, 0)
222+RELOC_TYPE (SHIFT6, 0)
223+RELOC_TYPE (64, 0)
224+RELOC_TYPE (GOT_DISP, 0)
225+RELOC_TYPE (GOT_PAGE, 0)
226+RELOC_TYPE (GOT_OFST, 0)
227+RELOC_TYPE (GOT_HI16, 0)
228+RELOC_TYPE (GOT_LO16, 0)
229+RELOC_TYPE (SUB, 0)
230+RELOC_TYPE (INSERT_A, 0)
231+RELOC_TYPE (INSERT_B, 0)
232+RELOC_TYPE (DELETE, 0)
233+RELOC_TYPE (HIGHER, 0)
234+RELOC_TYPE (HIGHEST, 0)
235+RELOC_TYPE (CALL_HI16, 0)
236+RELOC_TYPE (CALL_LO16, 0)
237+RELOC_TYPE (SCN_DISP, 0)
238+RELOC_TYPE (REL16, 0)
239+RELOC_TYPE (ADD_IMMEDIATE, 0)
240+RELOC_TYPE (PJUMP, 0)
241+RELOC_TYPE (RELGOT, 0)
242+RELOC_TYPE (JALR, 0)
243+RELOC_TYPE (TLS_DTPMOD32, 0)
244+RELOC_TYPE (TLS_DTPREL32, 0)
245+RELOC_TYPE (TLS_DTPMOD64, 0)
246+RELOC_TYPE (TLS_DTPREL64, 0)
247+RELOC_TYPE (TLS_GD, 0)
248+RELOC_TYPE (TLS_LDM, 0)
249+RELOC_TYPE (TLS_DTPREL_HI16, 0)
250+RELOC_TYPE (TLS_DTPREL_LO16, 0)
251+RELOC_TYPE (TLS_GOTTPREL, 0)
252+RELOC_TYPE (TLS_TPREL32, 0)
253+RELOC_TYPE (TLS_TPREL64, 0)
254+RELOC_TYPE (TLS_TPREL_HI16, 0)
255+RELOC_TYPE (TLS_TPREL_LO16, 0)
256+
257+#define NO_COPY_RELOC 1
258+#define NO_RELATIVE_RELOC 1
259Index: elfutils-0.158/backends/mips_retval.c
260===================================================================
261--- /dev/null 1970-01-01 00:00:00.000000000 +0000
262+++ elfutils-0.158/backends/mips_retval.c 2014-04-21 11:13:36.910235965 +0000
263@@ -0,0 +1,321 @@
264+/* Function return value location for Linux/mips ABI.
265+ Copyright (C) 2005 Red Hat, Inc.
266+ This file is part of Red Hat elfutils.
267+
268+ Red Hat elfutils is free software; you can redistribute it and/or modify
269+ it under the terms of the GNU General Public License as published by the
270+ Free Software Foundation; version 2 of the License.
271+
272+ Red Hat elfutils is distributed in the hope that it will be useful, but
273+ WITHOUT ANY WARRANTY; without even the implied warranty of
274+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
275+ General Public License for more details.
276+
277+ You should have received a copy of the GNU General Public License along
278+ with Red Hat elfutils; if not, write to the Free Software Foundation,
279+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
280+
281+ Red Hat elfutils is an included package of the Open Invention Network.
282+ An included package of the Open Invention Network is a package for which
283+ Open Invention Network licensees cross-license their patents. No patent
284+ license is granted, either expressly or impliedly, by designation as an
285+ included package. Should you wish to participate in the Open Invention
286+ Network licensing program, please visit www.openinventionnetwork.com
287+ <http://www.openinventionnetwork.com>. */
288+
289+#ifdef HAVE_CONFIG_H
290+# include <config.h>
291+#endif
292+
293+#include <string.h>
294+#include <assert.h>
295+#include <dwarf.h>
296+#include <elf.h>
297+
298+#include "../libebl/libeblP.h"
299+#include "../libdw/libdwP.h"
300+
301+#define BACKEND mips_
302+#include "libebl_CPU.h"
303+
304+/* The ABI of the file. Also see EF_MIPS_ABI2 above. */
305+#define EF_MIPS_ABI 0x0000F000
306+
307+/* The original o32 abi. */
308+#define E_MIPS_ABI_O32 0x00001000
309+
310+/* O32 extended to work on 64 bit architectures */
311+#define E_MIPS_ABI_O64 0x00002000
312+
313+/* EABI in 32 bit mode */
314+#define E_MIPS_ABI_EABI32 0x00003000
315+
316+/* EABI in 64 bit mode */
317+#define E_MIPS_ABI_EABI64 0x00004000
318+
319+/* All the possible MIPS ABIs. */
320+enum mips_abi
321+ {
322+ MIPS_ABI_UNKNOWN = 0,
323+ MIPS_ABI_N32,
324+ MIPS_ABI_O32,
325+ MIPS_ABI_N64,
326+ MIPS_ABI_O64,
327+ MIPS_ABI_EABI32,
328+ MIPS_ABI_EABI64,
329+ MIPS_ABI_LAST
330+ };
331+
332+/* Find the mips ABI of the current file */
333+enum mips_abi find_mips_abi(Elf *elf)
334+{
335+ GElf_Ehdr ehdr_mem;
336+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
337+
338+ if (ehdr == NULL)
339+ return MIPS_ABI_LAST;
340+
341+ GElf_Word elf_flags = ehdr->e_flags;
342+
343+ /* Check elf_flags to see if it specifies the ABI being used. */
344+ switch ((elf_flags & EF_MIPS_ABI))
345+ {
346+ case E_MIPS_ABI_O32:
347+ return MIPS_ABI_O32;
348+ case E_MIPS_ABI_O64:
349+ return MIPS_ABI_O64;
350+ case E_MIPS_ABI_EABI32:
351+ return MIPS_ABI_EABI32;
352+ case E_MIPS_ABI_EABI64:
353+ return MIPS_ABI_EABI64;
354+ default:
355+ if ((elf_flags & EF_MIPS_ABI2))
356+ return MIPS_ABI_N32;
357+ }
358+
359+ /* GCC creates a pseudo-section whose name describes the ABI. */
360+ size_t shstrndx;
361+ if (elf_getshdrstrndx (elf, &shstrndx) < 0)
362+ return MIPS_ABI_LAST;
363+
364+ const char *name;
365+ Elf_Scn *scn = NULL;
366+ while ((scn = elf_nextscn (elf, scn)) != NULL)
367+ {
368+ GElf_Shdr shdr_mem;
369+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
370+ if (shdr == NULL)
371+ return MIPS_ABI_LAST;
372+
373+ name = elf_strptr (elf, shstrndx, shdr->sh_name) ?: "";
374+ if (strncmp (name, ".mdebug.", 8) != 0)
375+ continue;
376+
377+ if (strcmp (name, ".mdebug.abi32") == 0)
378+ return MIPS_ABI_O32;
379+ else if (strcmp (name, ".mdebug.abiN32") == 0)
380+ return MIPS_ABI_N32;
381+ else if (strcmp (name, ".mdebug.abi64") == 0)
382+ return MIPS_ABI_N64;
383+ else if (strcmp (name, ".mdebug.abiO64") == 0)
384+ return MIPS_ABI_O64;
385+ else if (strcmp (name, ".mdebug.eabi32") == 0)
386+ return MIPS_ABI_EABI32;
387+ else if (strcmp (name, ".mdebug.eabi64") == 0)
388+ return MIPS_ABI_EABI64;
389+ else
390+ return MIPS_ABI_UNKNOWN;
391+ }
392+
393+ return MIPS_ABI_UNKNOWN;
394+}
395+
396+unsigned int
397+mips_abi_regsize (enum mips_abi abi)
398+{
399+ switch (abi)
400+ {
401+ case MIPS_ABI_EABI32:
402+ case MIPS_ABI_O32:
403+ return 4;
404+ case MIPS_ABI_N32:
405+ case MIPS_ABI_N64:
406+ case MIPS_ABI_O64:
407+ case MIPS_ABI_EABI64:
408+ return 8;
409+ case MIPS_ABI_UNKNOWN:
410+ case MIPS_ABI_LAST:
411+ default:
412+ return 0;
413+ }
414+}
415+
416+
417+/* $v0 or pair $v0, $v1 */
418+static const Dwarf_Op loc_intreg_o32[] =
419+ {
420+ { .atom = DW_OP_reg2 }, { .atom = DW_OP_piece, .number = 4 },
421+ { .atom = DW_OP_reg3 }, { .atom = DW_OP_piece, .number = 4 },
422+ };
423+
424+static const Dwarf_Op loc_intreg[] =
425+ {
426+ { .atom = DW_OP_reg2 }, { .atom = DW_OP_piece, .number = 8 },
427+ { .atom = DW_OP_reg3 }, { .atom = DW_OP_piece, .number = 8 },
428+ };
429+#define nloc_intreg 1
430+#define nloc_intregpair 4
431+
432+/* $f0 (float), or pair $f0, $f1 (double).
433+ * f2/f3 are used for COMPLEX (= 2 doubles) returns in Fortran */
434+static const Dwarf_Op loc_fpreg_o32[] =
435+ {
436+ { .atom = DW_OP_regx, .number = 32 }, { .atom = DW_OP_piece, .number = 4 },
437+ { .atom = DW_OP_regx, .number = 33 }, { .atom = DW_OP_piece, .number = 4 },
438+ { .atom = DW_OP_regx, .number = 34 }, { .atom = DW_OP_piece, .number = 4 },
439+ { .atom = DW_OP_regx, .number = 35 }, { .atom = DW_OP_piece, .number = 4 },
440+ };
441+
442+/* $f0, or pair $f0, $f2. */
443+static const Dwarf_Op loc_fpreg[] =
444+ {
445+ { .atom = DW_OP_regx, .number = 32 }, { .atom = DW_OP_piece, .number = 8 },
446+ { .atom = DW_OP_regx, .number = 34 }, { .atom = DW_OP_piece, .number = 8 },
447+ };
448+#define nloc_fpreg 1
449+#define nloc_fpregpair 4
450+#define nloc_fpregquad 8
451+
452+/* The return value is a structure and is actually stored in stack space
453+ passed in a hidden argument by the caller. But, the compiler
454+ helpfully returns the address of that space in $v0. */
455+static const Dwarf_Op loc_aggregate[] =
456+ {
457+ { .atom = DW_OP_breg2, .number = 0 }
458+ };
459+#define nloc_aggregate 1
460+
461+int
462+mips_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
463+{
464+ /* First find the ABI used by the elf object */
465+ enum mips_abi abi = find_mips_abi(functypedie->cu->dbg->elf);
466+
467+ /* Something went seriously wrong while trying to figure out the ABI */
468+ if (abi == MIPS_ABI_LAST)
469+ return -1;
470+
471+ /* We couldn't identify the ABI, but the file seems valid */
472+ if (abi == MIPS_ABI_UNKNOWN)
473+ return -2;
474+
475+ /* Can't handle EABI variants */
476+ if ((abi == MIPS_ABI_EABI32) || (abi == MIPS_ABI_EABI64))
477+ return -2;
478+
479+ unsigned int regsize = mips_abi_regsize (abi);
480+ if (!regsize)
481+ return -2;
482+
483+ /* Start with the function's type, and get the DW_AT_type attribute,
484+ which is the type of the return value. */
485+
486+ Dwarf_Attribute attr_mem;
487+ Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type, &attr_mem);
488+ if (attr == NULL)
489+ /* The function has no return value, like a `void' function in C. */
490+ return 0;
491+
492+ Dwarf_Die die_mem;
493+ Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
494+ int tag = dwarf_tag (typedie);
495+
496+ /* Follow typedefs and qualifiers to get to the actual type. */
497+ while (tag == DW_TAG_typedef
498+ || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
499+ || tag == DW_TAG_restrict_type)
500+ {
501+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
502+ typedie = dwarf_formref_die (attr, &die_mem);
503+ tag = dwarf_tag (typedie);
504+ }
505+
506+ switch (tag)
507+ {
508+ case -1:
509+ return -1;
510+
511+ case DW_TAG_subrange_type:
512+ if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
513+ {
514+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
515+ typedie = dwarf_formref_die (attr, &die_mem);
516+ tag = dwarf_tag (typedie);
517+ }
518+ /* Fall through. */
519+
520+ case DW_TAG_base_type:
521+ case DW_TAG_enumeration_type:
522+ case DW_TAG_pointer_type:
523+ case DW_TAG_ptr_to_member_type:
524+ {
525+ Dwarf_Word size;
526+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
527+ &attr_mem), &size) != 0)
528+ {
529+ if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
530+ size = regsize;
531+ else
532+ return -1;
533+ }
534+ if (tag == DW_TAG_base_type)
535+ {
536+ Dwarf_Word encoding;
537+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
538+ &attr_mem), &encoding) != 0)
539+ return -1;
540+
541+#define ABI_LOC(loc, regsize) ((regsize) == 4 ? (loc ## _o32) : (loc))
542+
543+ if (encoding == DW_ATE_float)
544+ {
545+ *locp = ABI_LOC(loc_fpreg, regsize);
546+ if (size <= regsize)
547+ return nloc_fpreg;
548+
549+ if (size <= 2*regsize)
550+ return nloc_fpregpair;
551+
552+ if (size <= 4*regsize && abi == MIPS_ABI_O32)
553+ return nloc_fpregquad;
554+
555+ goto aggregate;
556+ }
557+ }
558+ *locp = ABI_LOC(loc_intreg, regsize);
559+ if (size <= regsize)
560+ return nloc_intreg;
561+ if (size <= 2*regsize)
562+ return nloc_intregpair;
563+
564+ /* Else fall through. Shouldn't happen though (at least with gcc) */
565+ }
566+
567+ case DW_TAG_structure_type:
568+ case DW_TAG_class_type:
569+ case DW_TAG_union_type:
570+ case DW_TAG_array_type:
571+ aggregate:
572+ /* XXX TODO: Can't handle structure return with other ABI's yet :-/ */
573+ if ((abi != MIPS_ABI_O32) && (abi != MIPS_ABI_O64))
574+ return -2;
575+
576+ *locp = loc_aggregate;
577+ return nloc_aggregate;
578+ }
579+
580+ /* XXX We don't have a good way to return specific errors from ebl calls.
581+ This value means we do not understand the type, but it is well-formed
582+ DWARF and might be valid. */
583+ return -2;
584+}
585Index: elfutils-0.158/backends/mips_symbol.c
586===================================================================
587--- /dev/null 1970-01-01 00:00:00.000000000 +0000
588+++ elfutils-0.158/backends/mips_symbol.c 2014-04-21 11:13:36.910235965 +0000
589@@ -0,0 +1,52 @@
590+/* MIPS specific symbolic name handling.
591+ Copyright (C) 2002, 2003, 2005 Red Hat, Inc.
592+ This file is part of Red Hat elfutils.
593+ Written by Jakub Jelinek <jakub@redhat.com>, 2002.
594+
595+ Red Hat elfutils is free software; you can redistribute it and/or modify
596+ it under the terms of the GNU General Public License as published by the
597+ Free Software Foundation; version 2 of the License.
598+
599+ Red Hat elfutils is distributed in the hope that it will be useful, but
600+ WITHOUT ANY WARRANTY; without even the implied warranty of
601+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
602+ General Public License for more details.
603+
604+ You should have received a copy of the GNU General Public License along
605+ with Red Hat elfutils; if not, write to the Free Software Foundation,
606+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
607+
608+ Red Hat elfutils is an included package of the Open Invention Network.
609+ An included package of the Open Invention Network is a package for which
610+ Open Invention Network licensees cross-license their patents. No patent
611+ license is granted, either expressly or impliedly, by designation as an
612+ included package. Should you wish to participate in the Open Invention
613+ Network licensing program, please visit www.openinventionnetwork.com
614+ <http://www.openinventionnetwork.com>. */
615+
616+#ifdef HAVE_CONFIG_H
617+# include <config.h>
618+#endif
619+
620+#include <elf.h>
621+#include <stddef.h>
622+
623+#define BACKEND mips_
624+#include "libebl_CPU.h"
625+
626+/* Check for the simple reloc types. */
627+Elf_Type
628+mips_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
629+{
630+ switch (type)
631+ {
632+ case R_MIPS_16:
633+ return ELF_T_HALF;
634+ case R_MIPS_32:
635+ return ELF_T_WORD;
636+ case R_MIPS_64:
637+ return ELF_T_XWORD;
638+ default:
639+ return ELF_T_NUM;
640+ }
641+}
642Index: elfutils-0.158/libebl/eblopenbackend.c
643===================================================================
644--- elfutils-0.158.orig/libebl/eblopenbackend.c 2014-04-21 11:13:36.914235875 +0000
645+++ elfutils-0.158/libebl/eblopenbackend.c 2014-04-21 11:13:36.910235965 +0000
646@@ -71,6 +71,8 @@
647 { "sparc", "elf_sparc", "sparc", 5, EM_SPARC, 0, 0 },
648 { "sparc", "elf_sparcv8plus", "sparc", 5, EM_SPARC32PLUS, 0, 0 },
649 { "s390", "ebl_s390", "s390", 4, EM_S390, 0, 0 },
650+ { "mips", "elf_mips", "mips", 4, EM_MIPS, 0, 0 },
651+ { "mips", "elf_mipsel", "mipsel", 4, EM_MIPS_RS3_LE, 0, 0 },
652
653 { "m32", "elf_m32", "m32", 3, EM_M32, 0, 0 },
654 { "m68k", "elf_m68k", "m68k", 4, EM_68K, 0, 0 },
655Index: elfutils-0.158/backends/common-reloc.c
656===================================================================
657--- elfutils-0.158.orig/backends/common-reloc.c 2014-04-21 11:13:36.914235875 +0000
658+++ elfutils-0.158/backends/common-reloc.c 2014-04-21 11:13:36.910235965 +0000
659@@ -112,11 +112,13 @@
660 }
661
662
663+#ifndef NO_COPY_RELOC
664 bool
665 EBLHOOK(copy_reloc_p) (int reloc)
666 {
667 return reloc == R_TYPE (COPY);
668 }
669+#endif
670
671 bool
672 EBLHOOK(none_reloc_p) (int reloc)
673@@ -138,7 +140,9 @@
674 ebl->reloc_type_name = EBLHOOK(reloc_type_name);
675 ebl->reloc_type_check = EBLHOOK(reloc_type_check);
676 ebl->reloc_valid_use = EBLHOOK(reloc_valid_use);
677+#ifndef NO_COPY_RELOC
678 ebl->copy_reloc_p = EBLHOOK(copy_reloc_p);
679+#endif
680 ebl->none_reloc_p = EBLHOOK(none_reloc_p);
681 #ifndef NO_RELATIVE_RELOC
682 ebl->relative_reloc_p = EBLHOOK(relative_reloc_p);
683Index: elfutils-0.158/backends/Makefile.am
684===================================================================
685--- elfutils-0.158.orig/backends/Makefile.am 2014-04-21 11:13:36.914235875 +0000
686+++ elfutils-0.158/backends/Makefile.am 2014-04-21 11:14:10.841468934 +0000
687@@ -33,12 +33,12 @@
688
689
690 modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \
691- tilegx parisc
692+ tilegx parisc mips
693 libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \
694 libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \
695 libebl_aarch64_pic.a libebl_sparc_pic.a libebl_ppc_pic.a \
696 libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a \
697- libebl_parisc_pic.a
698+ libebl_parisc_pic.a libebl_mips_pic.a
699 noinst_LIBRARIES = $(libebl_pic)
700 noinst_DATA = $(libebl_pic:_pic.a=.so)
701
702@@ -121,6 +121,10 @@
703 libebl_parisc_pic_a_SOURCES = $(parisc_SRCS)
704 am_libebl_parisc_pic_a_OBJECTS = $(parisc_SRCS:.c=.os)
705
706+mips_SRCS = mips_init.c mips_symbol.c mips_regs.c mips_retval.c
707+libebl_mips_pic_a_SOURCES = $(mips_SRCS)
708+am_libebl_mips_pic_a_OBJECTS = $(mips_SRCS:.c=.os)
709+
710 libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw)
711 @rm -f $(@:.so=.map)
712 echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: *; };' \