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