summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/elfutils/elfutils-0.158/m68k_backend.diff
blob: 48bffdad0c6e6fac736c42e91c959ca3d5058396 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
From: Kurt Roeckx <kurt@roeckx.be>
From: Thorsten Glaser <tg@mirbsd.de>
Subject: m68k support

Written by Kurt Roeckx, except for the retval support which was written
by Thorsten Glaser


Index: elfutils-0.158/backends/m68k_init.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ elfutils-0.158/backends/m68k_init.c	2014-04-21 11:14:23.813175704 +0000
@@ -0,0 +1,50 @@
+/* Initialization of m68k specific backend library.
+   Copyright (C) 2007 Kurt Roeckx <kurt@roeckx.be>
+
+   This software is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   This softare is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this software; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#define BACKEND		m68k_
+#define RELOC_PREFIX	R_68K_
+#include "libebl_CPU.h"
+
+/* This defines the common reloc hooks based on m68k_reloc.def.  */
+#include "common-reloc.c"
+
+
+const char *
+m68k_init (elf, machine, eh, ehlen)
+     Elf *elf __attribute__ ((unused));
+     GElf_Half machine __attribute__ ((unused));
+     Ebl *eh;
+     size_t ehlen;
+{
+  /* Check whether the Elf_BH object has a sufficent size.  */
+  if (ehlen < sizeof (Ebl))
+    return NULL;
+
+  /* We handle it.  */
+  eh->name = "m68k";
+  m68k_init_reloc (eh);
+  HOOK (eh, reloc_simple_type);
+  HOOK (eh, return_value_location);
+  HOOK (eh, register_info);
+
+  return MODVERSION;
+}
Index: elfutils-0.158/backends/m68k_regs.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ elfutils-0.158/backends/m68k_regs.c	2014-04-21 11:14:23.813175704 +0000
@@ -0,0 +1,106 @@
+/* Register names and numbers for m68k DWARF.
+   Copyright (C) 2007 Kurt Roeckx <kurt@roeckx.be>
+
+   This software is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   This software is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this software; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <string.h>
+#include <dwarf.h>
+
+#define BACKEND m68k_
+#include "libebl_CPU.h"
+
+ssize_t
+m68k_register_info (Ebl *ebl __attribute__ ((unused)),
+		   int regno, char *name, size_t namelen,
+		   const char **prefix, const char **setname,
+		   int *bits, int *type)
+{
+	if (name == NULL)
+		return 25;
+
+	if (regno < 0 || regno > 24 || namelen < 5)
+		return -1;
+
+	*prefix = "%";
+	*bits = 32;
+	*type = (regno < 8 ? DW_ATE_signed
+		: regno < 16 ? DW_ATE_address : DW_ATE_float);
+
+	if (regno < 8)
+	{
+		*setname = "integer";
+	}
+	else if (regno < 16)
+	{
+		*setname = "address";
+	}
+	else if (regno < 24)
+	{
+		*setname = "FPU";
+	}
+	else
+	{
+		*setname = "address";
+		*type = DW_ATE_address;
+	}
+
+	switch (regno)
+	{
+	case 0 ... 7:
+		name[0] = 'd';
+		name[1] = regno + '0';
+		namelen = 2;
+		break;
+
+	case 8 ... 13:
+		name[0] = 'a';
+		name[1] = regno - 8 + '0';
+		namelen = 2;
+		break;
+
+	case 14:
+		name[0] = 'f';
+		name[1] = 'p';
+   		namelen = 2;
+		break;
+
+	case 15:
+		name[0] = 's';
+		name[1] = 'p';
+   		namelen = 2;
+		break;
+
+	case 16 ... 23:
+		name[0] = 'f';
+		name[1] = 'p';
+		name[2] = regno - 16 + '0';
+   		namelen = 3;
+		break;
+
+	case 24:
+		name[0] = 'p';
+		name[1] = 'c';
+		namelen = 2;
+	}
+
+	name[namelen++] = '\0';
+	return namelen;
+}
+
Index: elfutils-0.158/backends/m68k_reloc.def
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ elfutils-0.158/backends/m68k_reloc.def	2014-04-21 11:14:23.813175704 +0000
@@ -0,0 +1,45 @@
+/* List the relocation types for m68k.  -*- C -*-
+   Copyright (C) 2007 Kurt Roeckx <kurt@roeckx.be>
+
+   This software is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   This software is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this software; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+*/
+
+/* 	    NAME,		REL|EXEC|DYN	*/
+
+RELOC_TYPE (NONE,		0)
+RELOC_TYPE (32,			REL|EXEC|DYN)
+RELOC_TYPE (16,			REL)
+RELOC_TYPE (8,			REL)
+RELOC_TYPE (PC32,		REL|EXEC|DYN)
+RELOC_TYPE (PC16,		REL)
+RELOC_TYPE (PC8,		REL)
+RELOC_TYPE (GOT32,		REL)
+RELOC_TYPE (GOT16,		REL)
+RELOC_TYPE (GOT8,		REL)
+RELOC_TYPE (GOT32O,		REL)
+RELOC_TYPE (GOT16O,		REL)
+RELOC_TYPE (GOT8O,		REL)
+RELOC_TYPE (PLT32,		REL)
+RELOC_TYPE (PLT16,		REL)
+RELOC_TYPE (PLT8,		REL)
+RELOC_TYPE (PLT32O,		REL)
+RELOC_TYPE (PLT16O,		REL)
+RELOC_TYPE (PLT8O,		REL)
+RELOC_TYPE (COPY,		EXEC)
+RELOC_TYPE (GLOB_DAT,		EXEC|DYN)
+RELOC_TYPE (JMP_SLOT,		EXEC|DYN)
+RELOC_TYPE (RELATIVE,		EXEC|DYN)
+RELOC_TYPE (GNU_VTINHERIT,	REL)
+RELOC_TYPE (GNU_VTENTRY,	REL)
+
Index: elfutils-0.158/libelf/elf.h
===================================================================
--- elfutils-0.158.orig/libelf/elf.h	2014-04-21 11:14:23.813175704 +0000
+++ elfutils-0.158/libelf/elf.h	2014-04-21 11:14:23.813175704 +0000
@@ -1157,6 +1157,9 @@
 #define R_68K_GLOB_DAT	20		/* Create GOT entry */
 #define R_68K_JMP_SLOT	21		/* Create PLT entry */
 #define R_68K_RELATIVE	22		/* Adjust by program base */
+/* The next 2 are GNU extensions to enable C++ vtable garbage collection.  */
+#define R_68K_GNU_VTINHERIT 23
+#define R_68K_GNU_VTENTRY   24
 #define R_68K_TLS_GD32      25          /* 32 bit GOT offset for GD */
 #define R_68K_TLS_GD16      26          /* 16 bit GOT offset for GD */
 #define R_68K_TLS_GD8       27          /* 8 bit GOT offset for GD */
Index: elfutils-0.158/backends/Makefile.am
===================================================================
--- elfutils-0.158.orig/backends/Makefile.am	2014-04-21 11:14:23.813175704 +0000
+++ elfutils-0.158/backends/Makefile.am	2014-04-21 11:14:48.344621167 +0000
@@ -33,12 +33,12 @@
 
 
 modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \
-	  tilegx parisc mips
+	  tilegx parisc mips m68k
 libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a    \
 	     libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a    \
 	     libebl_aarch64_pic.a libebl_sparc_pic.a libebl_ppc_pic.a \
 	     libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a \
-	     libebl_parisc_pic.a libebl_mips_pic.a
+	     libebl_parisc_pic.a libebl_mips_pic.a libebl_m68k_pic.a
 noinst_LIBRARIES = $(libebl_pic)
 noinst_DATA = $(libebl_pic:_pic.a=.so)
 
@@ -125,6 +125,10 @@
 libebl_mips_pic_a_SOURCES = $(mips_SRCS)
 am_libebl_mips_pic_a_OBJECTS = $(mips_SRCS:.c=.os)
 
+m68k_SRCS = m68k_init.c m68k_symbol.c m68k_regs.c m68k_retval.c
+libebl_m68k_pic_a_SOURCES = $(m68k_SRCS)
+am_libebl_m68k_pic_a_OBJECTS = $(m68k_SRCS:.c=.os)
+
 libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw)
 	@rm -f $(@:.so=.map)
 	echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: *; };' \
Index: elfutils-0.158/backends/m68k_symbol.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ elfutils-0.158/backends/m68k_symbol.c	2014-04-21 11:14:23.813175704 +0000
@@ -0,0 +1,43 @@
+/* m68k specific symbolic name handling.
+   Copyright (C) 2007 Kurt Roeckx <kurt@roeckx.be>
+
+   This software is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   This software distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this software; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+*/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <elf.h>
+#include <stddef.h>
+
+#define BACKEND		m68k_
+#include "libebl_CPU.h"
+
+/* Check for the simple reloc types.  */
+Elf_Type
+m68k_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
+{
+  switch (type)
+    {
+    case R_68K_32:
+      return ELF_T_SWORD;
+    case R_68K_16:
+      return ELF_T_HALF;
+    case R_68K_8:
+      return ELF_T_BYTE;
+    default:
+      return ELF_T_NUM;
+    }
+}
Index: elfutils-0.158/backends/m68k_retval.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ elfutils-0.158/backends/m68k_retval.c	2014-04-21 11:14:23.813175704 +0000
@@ -0,0 +1,172 @@
+/* Function return value location for Linux/m68k ABI.
+   Copyright (C) 2005-2010 Red Hat, Inc.
+   Copyright (c) 2011 Thorsten Glaser, Debian.
+   This file is part of Red Hat elfutils.
+
+   Red Hat elfutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <assert.h>
+#include <dwarf.h>
+
+#define BACKEND m68k_
+#include "libebl_CPU.h"
+
+
+/* %d0, or pair %d0, %d1, or %a0 */
+static const Dwarf_Op loc_intreg[] =
+  {
+    { .atom = DW_OP_reg0 }, { .atom = DW_OP_piece, .number = 4 },
+    { .atom = DW_OP_reg1 }, { .atom = DW_OP_piece, .number = 4 },
+  };
+static const Dwarf_Op loc_ptrreg[] =
+  {
+    { .atom = DW_OP_reg8 },
+  };
+#define nloc_intreg	1
+#define nloc_intregpair	4
+#define nloc_ptrreg	1
+
+/* %f0 */
+static const Dwarf_Op loc_fpreg[] =
+  {
+    { .atom = DW_OP_reg16 }
+  };
+#define nloc_fpreg	1
+
+/* Structures are a bit more complicated - small structures are returned
+   in %d0 / %d1 (-freg-struct-return which is enabled by default), large
+   structures use %a1 (in constrast to the SYSV psABI which says %a0) as
+   reentrant storage space indicator.  */
+static const Dwarf_Op loc_aggregate[] =
+  {
+    { .atom = DW_OP_breg9, .number = 0 }
+  };
+#define nloc_aggregate 1
+
+int
+m68k_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
+{
+  Dwarf_Word size;
+
+  /* Start with the function's type, and get the DW_AT_type attribute,
+     which is the type of the return value.  */
+
+  Dwarf_Attribute attr_mem;
+  Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type,
+						&attr_mem);
+  if (attr == NULL)
+    /* The function has no return value, like a `void' function in C.  */
+    return 0;
+
+  Dwarf_Die die_mem;
+  Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
+  int tag = dwarf_tag (typedie);
+
+  /* Follow typedefs and qualifiers to get to the actual type.  */
+  while (tag == DW_TAG_typedef
+	 || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
+	 || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
+    {
+      attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
+      typedie = dwarf_formref_die (attr, &die_mem);
+      tag = dwarf_tag (typedie);
+    }
+
+  switch (tag)
+    {
+    case -1:
+      return -1;
+
+    case DW_TAG_subrange_type:
+      if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
+	{
+	  attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
+	  typedie = dwarf_formref_die (attr, &die_mem);
+	  tag = dwarf_tag (typedie);
+	}
+      /* Fall through.  */
+
+    case DW_TAG_base_type:
+    case DW_TAG_enumeration_type:
+    case DW_TAG_pointer_type:
+    case DW_TAG_ptr_to_member_type:
+      if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
+						 &attr_mem), &size) != 0)
+	{
+	  if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
+	    size = 4;
+	  else
+	    return -1;
+	}
+      if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
+	{
+	  *locp = loc_ptrreg;
+          return nloc_ptrreg;
+	}
+      if (tag == DW_TAG_base_type)
+	{
+	  Dwarf_Word encoding;
+	  if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
+						     &attr_mem),
+			       &encoding) != 0)
+	    return -1;
+	  if (encoding == DW_ATE_float)
+	    {
+	      /* XXX really 10? */
+              if (size > 10)
+                return -2;
+              *locp = loc_fpreg;
+              return nloc_fpreg;
+	    }
+	}
+      if (size <= 8)
+	{
+	intreg:
+	  /* XXX check endianness of dword pair, int64 vs aggregate */
+	  *locp = loc_intreg;
+	  return size <= 4 ? nloc_intreg : nloc_intregpair;
+	}
+
+    aggregate:
+      *locp = loc_aggregate;
+      return nloc_aggregate;
+
+    case DW_TAG_structure_type:
+    case DW_TAG_class_type:
+    case DW_TAG_union_type:
+    case DW_TAG_array_type:
+      if (dwarf_aggregate_size (typedie, &size) == 0
+	  && size > 0 && size <= 8)
+	/* not accurate for a struct whose only member is a float */
+	goto intreg;
+      goto aggregate;
+    }
+
+  /* XXX We don't have a good way to return specific errors from ebl calls.
+     This value means we do not understand the type, but it is well-formed
+     DWARF and might be valid.  */
+  return -2;
+}