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