summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/elfutils/elfutils-0.148/mips_backend.diff
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/elfutils/elfutils-0.148/mips_backend.diff')
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.148/mips_backend.diff713
1 files changed, 713 insertions, 0 deletions
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: *; };' \