summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/elfutils/elfutils-0.158/m68k_backend.diff
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/elfutils/elfutils-0.158/m68k_backend.diff')
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.158/m68k_backend.diff493
1 files changed, 493 insertions, 0 deletions
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.158/m68k_backend.diff b/meta/recipes-devtools/elfutils/elfutils-0.158/m68k_backend.diff
new file mode 100644
index 0000000000..48bffdad0c
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/elfutils-0.158/m68k_backend.diff
@@ -0,0 +1,493 @@
1From: Kurt Roeckx <kurt@roeckx.be>
2From: Thorsten Glaser <tg@mirbsd.de>
3Subject: m68k support
4
5Written by Kurt Roeckx, except for the retval support which was written
6by Thorsten Glaser
7
8
9Index: elfutils-0.158/backends/m68k_init.c
10===================================================================
11--- /dev/null 1970-01-01 00:00:00.000000000 +0000
12+++ elfutils-0.158/backends/m68k_init.c 2014-04-21 11:14:23.813175704 +0000
13@@ -0,0 +1,50 @@
14+/* Initialization of m68k specific backend library.
15+ Copyright (C) 2007 Kurt Roeckx <kurt@roeckx.be>
16+
17+ This software is free software; you can redistribute it and/or modify
18+ it under the terms of the GNU General Public License as published by the
19+ Free Software Foundation; version 2 of the License.
20+
21+ This softare is distributed in the hope that it will be useful, but
22+ WITHOUT ANY WARRANTY; without even the implied warranty of
23+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24+ General Public License for more details.
25+
26+ You should have received a copy of the GNU General Public License along
27+ with this software; if not, write to the Free Software Foundation,
28+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
29+
30+*/
31+
32+#ifdef HAVE_CONFIG_H
33+# include <config.h>
34+#endif
35+
36+#define BACKEND m68k_
37+#define RELOC_PREFIX R_68K_
38+#include "libebl_CPU.h"
39+
40+/* This defines the common reloc hooks based on m68k_reloc.def. */
41+#include "common-reloc.c"
42+
43+
44+const char *
45+m68k_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+ eh->name = "m68k";
57+ m68k_init_reloc (eh);
58+ HOOK (eh, reloc_simple_type);
59+ HOOK (eh, return_value_location);
60+ HOOK (eh, register_info);
61+
62+ return MODVERSION;
63+}
64Index: elfutils-0.158/backends/m68k_regs.c
65===================================================================
66--- /dev/null 1970-01-01 00:00:00.000000000 +0000
67+++ elfutils-0.158/backends/m68k_regs.c 2014-04-21 11:14:23.813175704 +0000
68@@ -0,0 +1,106 @@
69+/* Register names and numbers for m68k DWARF.
70+ Copyright (C) 2007 Kurt Roeckx <kurt@roeckx.be>
71+
72+ This software is free software; you can redistribute it and/or modify
73+ it under the terms of the GNU General Public License as published by the
74+ Free Software Foundation; version 2 of the License.
75+
76+ This software is distributed in the hope that it will be useful, but
77+ WITHOUT ANY WARRANTY; without even the implied warranty of
78+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
79+ General Public License for more details.
80+
81+ You should have received a copy of the GNU General Public License along
82+ with this software; if not, write to the Free Software Foundation,
83+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
84+
85+ */
86+
87+#ifdef HAVE_CONFIG_H
88+# include <config.h>
89+#endif
90+
91+#include <string.h>
92+#include <dwarf.h>
93+
94+#define BACKEND m68k_
95+#include "libebl_CPU.h"
96+
97+ssize_t
98+m68k_register_info (Ebl *ebl __attribute__ ((unused)),
99+ int regno, char *name, size_t namelen,
100+ const char **prefix, const char **setname,
101+ int *bits, int *type)
102+{
103+ if (name == NULL)
104+ return 25;
105+
106+ if (regno < 0 || regno > 24 || namelen < 5)
107+ return -1;
108+
109+ *prefix = "%";
110+ *bits = 32;
111+ *type = (regno < 8 ? DW_ATE_signed
112+ : regno < 16 ? DW_ATE_address : DW_ATE_float);
113+
114+ if (regno < 8)
115+ {
116+ *setname = "integer";
117+ }
118+ else if (regno < 16)
119+ {
120+ *setname = "address";
121+ }
122+ else if (regno < 24)
123+ {
124+ *setname = "FPU";
125+ }
126+ else
127+ {
128+ *setname = "address";
129+ *type = DW_ATE_address;
130+ }
131+
132+ switch (regno)
133+ {
134+ case 0 ... 7:
135+ name[0] = 'd';
136+ name[1] = regno + '0';
137+ namelen = 2;
138+ break;
139+
140+ case 8 ... 13:
141+ name[0] = 'a';
142+ name[1] = regno - 8 + '0';
143+ namelen = 2;
144+ break;
145+
146+ case 14:
147+ name[0] = 'f';
148+ name[1] = 'p';
149+ namelen = 2;
150+ break;
151+
152+ case 15:
153+ name[0] = 's';
154+ name[1] = 'p';
155+ namelen = 2;
156+ break;
157+
158+ case 16 ... 23:
159+ name[0] = 'f';
160+ name[1] = 'p';
161+ name[2] = regno - 16 + '0';
162+ namelen = 3;
163+ break;
164+
165+ case 24:
166+ name[0] = 'p';
167+ name[1] = 'c';
168+ namelen = 2;
169+ }
170+
171+ name[namelen++] = '\0';
172+ return namelen;
173+}
174+
175Index: elfutils-0.158/backends/m68k_reloc.def
176===================================================================
177--- /dev/null 1970-01-01 00:00:00.000000000 +0000
178+++ elfutils-0.158/backends/m68k_reloc.def 2014-04-21 11:14:23.813175704 +0000
179@@ -0,0 +1,45 @@
180+/* List the relocation types for m68k. -*- C -*-
181+ Copyright (C) 2007 Kurt Roeckx <kurt@roeckx.be>
182+
183+ This software 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+ This software 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 this software; if not, write to the Free Software Foundation,
194+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
195+*/
196+
197+/* NAME, REL|EXEC|DYN */
198+
199+RELOC_TYPE (NONE, 0)
200+RELOC_TYPE (32, REL|EXEC|DYN)
201+RELOC_TYPE (16, REL)
202+RELOC_TYPE (8, REL)
203+RELOC_TYPE (PC32, REL|EXEC|DYN)
204+RELOC_TYPE (PC16, REL)
205+RELOC_TYPE (PC8, REL)
206+RELOC_TYPE (GOT32, REL)
207+RELOC_TYPE (GOT16, REL)
208+RELOC_TYPE (GOT8, REL)
209+RELOC_TYPE (GOT32O, REL)
210+RELOC_TYPE (GOT16O, REL)
211+RELOC_TYPE (GOT8O, REL)
212+RELOC_TYPE (PLT32, REL)
213+RELOC_TYPE (PLT16, REL)
214+RELOC_TYPE (PLT8, REL)
215+RELOC_TYPE (PLT32O, REL)
216+RELOC_TYPE (PLT16O, REL)
217+RELOC_TYPE (PLT8O, REL)
218+RELOC_TYPE (COPY, EXEC)
219+RELOC_TYPE (GLOB_DAT, EXEC|DYN)
220+RELOC_TYPE (JMP_SLOT, EXEC|DYN)
221+RELOC_TYPE (RELATIVE, EXEC|DYN)
222+RELOC_TYPE (GNU_VTINHERIT, REL)
223+RELOC_TYPE (GNU_VTENTRY, REL)
224+
225Index: elfutils-0.158/libelf/elf.h
226===================================================================
227--- elfutils-0.158.orig/libelf/elf.h 2014-04-21 11:14:23.813175704 +0000
228+++ elfutils-0.158/libelf/elf.h 2014-04-21 11:14:23.813175704 +0000
229@@ -1157,6 +1157,9 @@
230 #define R_68K_GLOB_DAT 20 /* Create GOT entry */
231 #define R_68K_JMP_SLOT 21 /* Create PLT entry */
232 #define R_68K_RELATIVE 22 /* Adjust by program base */
233+/* The next 2 are GNU extensions to enable C++ vtable garbage collection. */
234+#define R_68K_GNU_VTINHERIT 23
235+#define R_68K_GNU_VTENTRY 24
236 #define R_68K_TLS_GD32 25 /* 32 bit GOT offset for GD */
237 #define R_68K_TLS_GD16 26 /* 16 bit GOT offset for GD */
238 #define R_68K_TLS_GD8 27 /* 8 bit GOT offset for GD */
239Index: elfutils-0.158/backends/Makefile.am
240===================================================================
241--- elfutils-0.158.orig/backends/Makefile.am 2014-04-21 11:14:23.813175704 +0000
242+++ elfutils-0.158/backends/Makefile.am 2014-04-21 11:14:48.344621167 +0000
243@@ -33,12 +33,12 @@
244
245
246 modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \
247- tilegx parisc mips
248+ tilegx parisc mips m68k
249 libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \
250 libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \
251 libebl_aarch64_pic.a libebl_sparc_pic.a libebl_ppc_pic.a \
252 libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a \
253- libebl_parisc_pic.a libebl_mips_pic.a
254+ libebl_parisc_pic.a libebl_mips_pic.a libebl_m68k_pic.a
255 noinst_LIBRARIES = $(libebl_pic)
256 noinst_DATA = $(libebl_pic:_pic.a=.so)
257
258@@ -125,6 +125,10 @@
259 libebl_mips_pic_a_SOURCES = $(mips_SRCS)
260 am_libebl_mips_pic_a_OBJECTS = $(mips_SRCS:.c=.os)
261
262+m68k_SRCS = m68k_init.c m68k_symbol.c m68k_regs.c m68k_retval.c
263+libebl_m68k_pic_a_SOURCES = $(m68k_SRCS)
264+am_libebl_m68k_pic_a_OBJECTS = $(m68k_SRCS:.c=.os)
265+
266 libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw)
267 @rm -f $(@:.so=.map)
268 echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: *; };' \
269Index: elfutils-0.158/backends/m68k_symbol.c
270===================================================================
271--- /dev/null 1970-01-01 00:00:00.000000000 +0000
272+++ elfutils-0.158/backends/m68k_symbol.c 2014-04-21 11:14:23.813175704 +0000
273@@ -0,0 +1,43 @@
274+/* m68k specific symbolic name handling.
275+ Copyright (C) 2007 Kurt Roeckx <kurt@roeckx.be>
276+
277+ This software is free software; you can redistribute it and/or modify
278+ it under the terms of the GNU General Public License as published by the
279+ Free Software Foundation; version 2 of the License.
280+
281+ This software distributed in the hope that it will be useful, but
282+ WITHOUT ANY WARRANTY; without even the implied warranty of
283+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
284+ General Public License for more details.
285+
286+ You should have received a copy of the GNU General Public License along
287+ with this software; if not, write to the Free Software Foundation,
288+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
289+*/
290+
291+#ifdef HAVE_CONFIG_H
292+# include <config.h>
293+#endif
294+
295+#include <elf.h>
296+#include <stddef.h>
297+
298+#define BACKEND m68k_
299+#include "libebl_CPU.h"
300+
301+/* Check for the simple reloc types. */
302+Elf_Type
303+m68k_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
304+{
305+ switch (type)
306+ {
307+ case R_68K_32:
308+ return ELF_T_SWORD;
309+ case R_68K_16:
310+ return ELF_T_HALF;
311+ case R_68K_8:
312+ return ELF_T_BYTE;
313+ default:
314+ return ELF_T_NUM;
315+ }
316+}
317Index: elfutils-0.158/backends/m68k_retval.c
318===================================================================
319--- /dev/null 1970-01-01 00:00:00.000000000 +0000
320+++ elfutils-0.158/backends/m68k_retval.c 2014-04-21 11:14:23.813175704 +0000
321@@ -0,0 +1,172 @@
322+/* Function return value location for Linux/m68k ABI.
323+ Copyright (C) 2005-2010 Red Hat, Inc.
324+ Copyright (c) 2011 Thorsten Glaser, Debian.
325+ This file is part of Red Hat elfutils.
326+
327+ Red Hat elfutils is free software; you can redistribute it and/or modify
328+ it under the terms of the GNU General Public License as published by the
329+ Free Software Foundation; version 2 of the License.
330+
331+ Red Hat elfutils is distributed in the hope that it will be useful, but
332+ WITHOUT ANY WARRANTY; without even the implied warranty of
333+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
334+ General Public License for more details.
335+
336+ You should have received a copy of the GNU General Public License along
337+ with Red Hat elfutils; if not, write to the Free Software Foundation,
338+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
339+
340+ Red Hat elfutils is an included package of the Open Invention Network.
341+ An included package of the Open Invention Network is a package for which
342+ Open Invention Network licensees cross-license their patents. No patent
343+ license is granted, either expressly or impliedly, by designation as an
344+ included package. Should you wish to participate in the Open Invention
345+ Network licensing program, please visit www.openinventionnetwork.com
346+ <http://www.openinventionnetwork.com>. */
347+
348+#ifdef HAVE_CONFIG_H
349+# include <config.h>
350+#endif
351+
352+#include <assert.h>
353+#include <dwarf.h>
354+
355+#define BACKEND m68k_
356+#include "libebl_CPU.h"
357+
358+
359+/* %d0, or pair %d0, %d1, or %a0 */
360+static const Dwarf_Op loc_intreg[] =
361+ {
362+ { .atom = DW_OP_reg0 }, { .atom = DW_OP_piece, .number = 4 },
363+ { .atom = DW_OP_reg1 }, { .atom = DW_OP_piece, .number = 4 },
364+ };
365+static const Dwarf_Op loc_ptrreg[] =
366+ {
367+ { .atom = DW_OP_reg8 },
368+ };
369+#define nloc_intreg 1
370+#define nloc_intregpair 4
371+#define nloc_ptrreg 1
372+
373+/* %f0 */
374+static const Dwarf_Op loc_fpreg[] =
375+ {
376+ { .atom = DW_OP_reg16 }
377+ };
378+#define nloc_fpreg 1
379+
380+/* Structures are a bit more complicated - small structures are returned
381+ in %d0 / %d1 (-freg-struct-return which is enabled by default), large
382+ structures use %a1 (in constrast to the SYSV psABI which says %a0) as
383+ reentrant storage space indicator. */
384+static const Dwarf_Op loc_aggregate[] =
385+ {
386+ { .atom = DW_OP_breg9, .number = 0 }
387+ };
388+#define nloc_aggregate 1
389+
390+int
391+m68k_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
392+{
393+ Dwarf_Word size;
394+
395+ /* Start with the function's type, and get the DW_AT_type attribute,
396+ which is the type of the return value. */
397+
398+ Dwarf_Attribute attr_mem;
399+ Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type,
400+ &attr_mem);
401+ if (attr == NULL)
402+ /* The function has no return value, like a `void' function in C. */
403+ return 0;
404+
405+ Dwarf_Die die_mem;
406+ Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
407+ int tag = dwarf_tag (typedie);
408+
409+ /* Follow typedefs and qualifiers to get to the actual type. */
410+ while (tag == DW_TAG_typedef
411+ || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
412+ || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
413+ {
414+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
415+ typedie = dwarf_formref_die (attr, &die_mem);
416+ tag = dwarf_tag (typedie);
417+ }
418+
419+ switch (tag)
420+ {
421+ case -1:
422+ return -1;
423+
424+ case DW_TAG_subrange_type:
425+ if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
426+ {
427+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
428+ typedie = dwarf_formref_die (attr, &die_mem);
429+ tag = dwarf_tag (typedie);
430+ }
431+ /* Fall through. */
432+
433+ case DW_TAG_base_type:
434+ case DW_TAG_enumeration_type:
435+ case DW_TAG_pointer_type:
436+ case DW_TAG_ptr_to_member_type:
437+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
438+ &attr_mem), &size) != 0)
439+ {
440+ if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
441+ size = 4;
442+ else
443+ return -1;
444+ }
445+ if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
446+ {
447+ *locp = loc_ptrreg;
448+ return nloc_ptrreg;
449+ }
450+ if (tag == DW_TAG_base_type)
451+ {
452+ Dwarf_Word encoding;
453+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
454+ &attr_mem),
455+ &encoding) != 0)
456+ return -1;
457+ if (encoding == DW_ATE_float)
458+ {
459+ /* XXX really 10? */
460+ if (size > 10)
461+ return -2;
462+ *locp = loc_fpreg;
463+ return nloc_fpreg;
464+ }
465+ }
466+ if (size <= 8)
467+ {
468+ intreg:
469+ /* XXX check endianness of dword pair, int64 vs aggregate */
470+ *locp = loc_intreg;
471+ return size <= 4 ? nloc_intreg : nloc_intregpair;
472+ }
473+
474+ aggregate:
475+ *locp = loc_aggregate;
476+ return nloc_aggregate;
477+
478+ case DW_TAG_structure_type:
479+ case DW_TAG_class_type:
480+ case DW_TAG_union_type:
481+ case DW_TAG_array_type:
482+ if (dwarf_aggregate_size (typedie, &size) == 0
483+ && size > 0 && size <= 8)
484+ /* not accurate for a struct whose only member is a float */
485+ goto intreg;
486+ goto aggregate;
487+ }
488+
489+ /* XXX We don't have a good way to return specific errors from ebl calls.
490+ This value means we do not understand the type, but it is well-formed
491+ DWARF and might be valid. */
492+ return -2;
493+}