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