blob: afcc30abfef3b426006a40dc48dfeb1374aef243 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001From 8fe468682c550606ea961a1f996a8618940eb084 Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Fri, 16 Jul 2010 12:26:46 +0800
4Subject: [PATCH] elfutils: upgrade to version 0.148
5
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08006Upstream-Status: Pending [from debian]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08007Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08008
Brad Bishop19323692019-04-05 15:28:33 -04009---
10 backends/Makefile.am | 8 +-
11 backends/libebl_parisc.h | 9 ++
12 backends/parisc_init.c | 73 +++++++++++++
13 backends/parisc_regs.c | 159 ++++++++++++++++++++++++++++
14 backends/parisc_reloc.def | 128 +++++++++++++++++++++++
15 backends/parisc_retval.c | 213 ++++++++++++++++++++++++++++++++++++++
16 backends/parisc_symbol.c | 113 ++++++++++++++++++++
17 libelf/elf.h | 11 ++
18 8 files changed, 712 insertions(+), 2 deletions(-)
19 create mode 100644 backends/libebl_parisc.h
20 create mode 100644 backends/parisc_init.c
21 create mode 100644 backends/parisc_regs.c
22 create mode 100644 backends/parisc_reloc.def
23 create mode 100644 backends/parisc_retval.c
24 create mode 100644 backends/parisc_symbol.c
25
26diff --git a/backends/Makefile.am b/backends/Makefile.am
27index 2126a2e..5671a32 100644
28--- a/backends/Makefile.am
29+++ b/backends/Makefile.am
30@@ -33,12 +33,13 @@ AM_CPPFLAGS += -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \
31
32
33 modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \
34- tilegx m68k bpf riscv
35+ tilegx m68k bpf riscv parisc
36 libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \
37 libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \
38 libebl_aarch64_pic.a libebl_sparc_pic.a libebl_ppc_pic.a \
39 libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a \
40- libebl_m68k_pic.a libebl_bpf_pic.a libebl_riscv_pic.a
41+ libebl_m68k_pic.a libebl_bpf_pic.a libebl_riscv_pic.a \
42+ libebl_parisc_pic.a
43 noinst_LIBRARIES = $(libebl_pic)
44 noinst_DATA = $(libebl_pic:_pic.a=.so)
45
46@@ -136,6 +137,9 @@ riscv_SRCS = riscv_init.c riscv_symbol.c riscv_cfi.c riscv_regs.c \
47 libebl_riscv_pic_a_SOURCES = $(riscv_SRCS)
48 am_libebl_riscv_pic_a_OBJECTS = $(riscv_SRCS:.c=.os)
49
50+parisc_SRCS = parisc_init.c parisc_symbol.c parisc_regs.c parisc_retval.c
51+libebl_parisc_pic_a_SOURCES = $(parisc_SRCS)
52+am_libebl_parisc_pic_a_OBJECTS = $(parisc_SRCS:.c=.os)
53
54 libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw) $(libeu)
55 @rm -f $(@:.so=.map)
56diff --git a/backends/libebl_parisc.h b/backends/libebl_parisc.h
57new file mode 100644
58index 0000000..f473b79
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080059--- /dev/null
Brad Bishop19323692019-04-05 15:28:33 -040060+++ b/backends/libebl_parisc.h
61@@ -0,0 +1,9 @@
62+#ifndef _LIBEBL_HPPA_H
63+#define _LIBEBL_HPPA_H 1
64+
65+#include <libdw.h>
66+
67+extern int parisc_return_value_location_32(Dwarf_Die *, const Dwarf_Op **locp);
68+extern int parisc_return_value_location_64(Dwarf_Die *, const Dwarf_Op **locp);
69+
70+#endif
71diff --git a/backends/parisc_init.c b/backends/parisc_init.c
72new file mode 100644
73index 0000000..f1e401c
74--- /dev/null
75+++ b/backends/parisc_init.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080076@@ -0,0 +1,73 @@
77+/* Initialization of PA-RISC specific backend library.
78+ Copyright (C) 2002, 2005, 2006 Red Hat, Inc.
79+ This file is part of Red Hat elfutils.
80+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
81+
82+ Red Hat elfutils is free software; you can redistribute it and/or modify
83+ it under the terms of the GNU General Public License as published by the
84+ Free Software Foundation; version 2 of the License.
85+
86+ Red Hat elfutils is distributed in the hope that it will be useful, but
87+ WITHOUT ANY WARRANTY; without even the implied warranty of
88+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
89+ General Public License for more details.
90+
91+ You should have received a copy of the GNU General Public License along
92+ with Red Hat elfutils; if not, write to the Free Software Foundation,
93+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
94+
95+ Red Hat elfutils is an included package of the Open Invention Network.
96+ An included package of the Open Invention Network is a package for which
97+ Open Invention Network licensees cross-license their patents. No patent
98+ license is granted, either expressly or impliedly, by designation as an
99+ included package. Should you wish to participate in the Open Invention
100+ Network licensing program, please visit www.openinventionnetwork.com
101+ <http://www.openinventionnetwork.com>. */
102+
103+#ifdef HAVE_CONFIG_H
104+# include <config.h>
105+#endif
106+
107+#define BACKEND parisc_
108+#define RELOC_PREFIX R_PARISC_
109+#include "libebl_CPU.h"
110+#include "libebl_parisc.h"
111+
112+/* This defines the common reloc hooks based on parisc_reloc.def. */
113+#include "common-reloc.c"
114+
115+
116+const char *
117+parisc_init (Elf *elf __attribute__ ((unused)),
118+ GElf_Half machine __attribute__ ((unused)),
119+ Ebl *eh,
120+ size_t ehlen)
121+{
122+ int pa64 = 0;
123+
124+ /* Check whether the Elf_BH object has a sufficent size. */
125+ if (ehlen < sizeof (Ebl))
126+ return NULL;
127+
128+ if (elf) {
129+ GElf_Ehdr ehdr_mem;
130+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
131+ if (ehdr && (ehdr->e_flags & EF_PARISC_WIDE))
132+ pa64 = 1;
133+ }
134+ /* We handle it. */
135+ eh->name = "PA-RISC";
136+ parisc_init_reloc (eh);
137+ HOOK (eh, reloc_simple_type);
138+ HOOK (eh, machine_flag_check);
139+ HOOK (eh, symbol_type_name);
140+ HOOK (eh, segment_type_name);
141+ HOOK (eh, section_type_name);
142+ HOOK (eh, register_info);
143+ if (pa64)
144+ eh->return_value_location = parisc_return_value_location_64;
145+ else
146+ eh->return_value_location = parisc_return_value_location_32;
147+
148+ return MODVERSION;
149+}
Brad Bishop19323692019-04-05 15:28:33 -0400150diff --git a/backends/parisc_regs.c b/backends/parisc_regs.c
151new file mode 100644
152index 0000000..3895f8e
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800153--- /dev/null
Brad Bishop19323692019-04-05 15:28:33 -0400154+++ b/backends/parisc_regs.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800155@@ -0,0 +1,159 @@
156+/* Register names and numbers for PA-RISC DWARF.
157+ Copyright (C) 2005, 2006 Red Hat, Inc.
158+ This file is part of Red Hat elfutils.
159+
160+ Red Hat elfutils is free software; you can redistribute it and/or modify
161+ it under the terms of the GNU General Public License as published by the
162+ Free Software Foundation; version 2 of the License.
163+
164+ Red Hat elfutils is distributed in the hope that it will be useful, but
165+ WITHOUT ANY WARRANTY; without even the implied warranty of
166+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
167+ General Public License for more details.
168+
169+ You should have received a copy of the GNU General Public License along
170+ with Red Hat elfutils; if not, write to the Free Software Foundation,
171+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
172+
173+ Red Hat elfutils is an included package of the Open Invention Network.
174+ An included package of the Open Invention Network is a package for which
175+ Open Invention Network licensees cross-license their patents. No patent
176+ license is granted, either expressly or impliedly, by designation as an
177+ included package. Should you wish to participate in the Open Invention
178+ Network licensing program, please visit www.openinventionnetwork.com
179+ <http://www.openinventionnetwork.com>. */
180+
181+#ifdef HAVE_CONFIG_H
182+# include <config.h>
183+#endif
184+
185+#include <string.h>
186+#include <dwarf.h>
187+
188+#define BACKEND parisc_
189+#include "libebl_CPU.h"
190+
191+ssize_t
192+parisc_register_info (Ebl *ebl, int regno, char *name, size_t namelen,
193+ const char **prefix, const char **setname,
194+ int *bits, int *type)
195+{
196+ int pa64 = 0;
197+
198+ if (ebl->elf) {
199+ GElf_Ehdr ehdr_mem;
200+ GElf_Ehdr *ehdr = gelf_getehdr (ebl->elf, &ehdr_mem);
201+ if (ehdr->e_flags & EF_PARISC_WIDE)
202+ pa64 = 1;
203+ }
204+
205+ int nregs = pa64 ? 127 : 128;
206+
207+ if (name == NULL)
208+ return nregs;
209+
210+ if (regno < 0 || regno >= nregs || namelen < 6)
211+ return -1;
212+
213+ *prefix = "%";
214+
215+ if (regno < 32)
216+ {
217+ *setname = "integer";
218+ *type = DW_ATE_signed;
219+ if (pa64)
220+ {
221+ *bits = 64;
222+ }
223+ else
224+ {
225+ *bits = 32;
226+ }
227+ }
228+ else if (regno == 32)
229+ {
230+ *setname = "special";
231+ if (pa64)
232+ {
233+ *bits = 6;
234+ }
235+ else
236+ {
237+ *bits = 5;
238+ }
239+ *type = DW_ATE_unsigned;
240+ }
241+ else
242+ {
243+ *setname = "FPU";
244+ *type = DW_ATE_float;
245+ if (pa64)
246+ {
247+ *bits = 64;
248+ }
249+ else
250+ {
251+ *bits = 32;
252+ }
253+ }
254+
255+ if (regno < 33) {
256+ switch (regno)
257+ {
258+ case 0 ... 9:
259+ name[0] = 'r';
260+ name[1] = regno + '0';
261+ namelen = 2;
262+ break;
263+ case 10 ... 31:
264+ name[0] = 'r';
265+ name[1] = regno / 10 + '0';
266+ name[2] = regno % 10 + '0';
267+ namelen = 3;
268+ break;
269+ case 32:
270+ *prefix = NULL;
271+ name[0] = 'S';
272+ name[1] = 'A';
273+ name[2] = 'R';
274+ namelen = 3;
275+ break;
276+ }
277+ }
278+ else {
279+ if (pa64 && ((regno - 72) % 2)) {
280+ *setname = NULL;
281+ return 0;
282+ }
283+
284+ switch (regno)
285+ {
286+ case 72 + 0 ... 72 + 11:
287+ name[0] = 'f';
288+ name[1] = 'r';
289+ name[2] = (regno + 8 - 72) / 2 + '0';
290+ namelen = 3;
291+ if ((regno + 8 - 72) % 2) {
292+ name[3] = 'R';
293+ namelen++;
294+ }
295+ break;
296+ case 72 + 12 ... 72 + 55:
297+ name[0] = 'f';
298+ name[1] = 'r';
299+ name[2] = (regno + 8 - 72) / 2 / 10 + '0';
300+ name[3] = (regno + 8 - 72) / 2 % 10 + '0';
301+ namelen = 4;
302+ if ((regno + 8 - 72) % 2) {
303+ name[4] = 'R';
304+ namelen++;
305+ }
306+ break;
307+ default:
308+ *setname = NULL;
309+ return 0;
310+ }
311+ }
312+ name[namelen++] = '\0';
313+ return namelen;
314+}
Brad Bishop19323692019-04-05 15:28:33 -0400315diff --git a/backends/parisc_reloc.def b/backends/parisc_reloc.def
316new file mode 100644
317index 0000000..1f875ba
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800318--- /dev/null
Brad Bishop19323692019-04-05 15:28:33 -0400319+++ b/backends/parisc_reloc.def
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800320@@ -0,0 +1,128 @@
321+/* List the relocation types for PA-RISC. -*- C -*-
322+ Copyright (C) 2005 Red Hat, Inc.
323+ This file is part of Red Hat elfutils.
324+
325+ Red Hat elfutils is free software; you can redistribute it and/or modify
326+ it under the terms of the GNU General Public License as published by the
327+ Free Software Foundation; version 2 of the License.
328+
329+ Red Hat elfutils is distributed in the hope that it will be useful, but
330+ WITHOUT ANY WARRANTY; without even the implied warranty of
331+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
332+ General Public License for more details.
333+
334+ You should have received a copy of the GNU General Public License along
335+ with Red Hat elfutils; if not, write to the Free Software Foundation,
336+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
337+
338+ Red Hat elfutils is an included package of the Open Invention Network.
339+ An included package of the Open Invention Network is a package for which
340+ Open Invention Network licensees cross-license their patents. No patent
341+ license is granted, either expressly or impliedly, by designation as an
342+ included package. Should you wish to participate in the Open Invention
343+ Network licensing program, please visit www.openinventionnetwork.com
344+ <http://www.openinventionnetwork.com>. */
345+
346+/* NAME, REL|EXEC|DYN */
347+
348+RELOC_TYPE (NONE, EXEC|DYN)
349+RELOC_TYPE (DIR32, REL|EXEC|DYN)
350+RELOC_TYPE (DIR21L, REL|EXEC|DYN)
351+RELOC_TYPE (DIR17R, REL)
352+RELOC_TYPE (DIR17F, REL)
353+RELOC_TYPE (DIR14R, REL|DYN)
354+RELOC_TYPE (PCREL32, REL)
355+RELOC_TYPE (PCREL21L, REL)
356+RELOC_TYPE (PCREL17R, REL)
357+RELOC_TYPE (PCREL17F, REL)
358+RELOC_TYPE (PCREL14R, REL|EXEC)
359+RELOC_TYPE (DPREL21L, REL)
360+RELOC_TYPE (DPREL14WR, REL)
361+RELOC_TYPE (DPREL14DR, REL)
362+RELOC_TYPE (DPREL14R, REL)
363+RELOC_TYPE (GPREL21L, 0)
364+RELOC_TYPE (GPREL14R, 0)
365+RELOC_TYPE (LTOFF21L, REL)
366+RELOC_TYPE (LTOFF14R, REL)
367+RELOC_TYPE (DLTIND14F, 0)
368+RELOC_TYPE (SETBASE, 0)
369+RELOC_TYPE (SECREL32, REL)
370+RELOC_TYPE (BASEREL21L, 0)
371+RELOC_TYPE (BASEREL17R, 0)
372+RELOC_TYPE (BASEREL14R, 0)
373+RELOC_TYPE (SEGBASE, 0)
374+RELOC_TYPE (SEGREL32, REL)
375+RELOC_TYPE (PLTOFF21L, 0)
376+RELOC_TYPE (PLTOFF14R, 0)
377+RELOC_TYPE (PLTOFF14F, 0)
378+RELOC_TYPE (LTOFF_FPTR32, 0)
379+RELOC_TYPE (LTOFF_FPTR21L, 0)
380+RELOC_TYPE (LTOFF_FPTR14R, 0)
381+RELOC_TYPE (FPTR64, 0)
382+RELOC_TYPE (PLABEL32, REL|DYN)
383+RELOC_TYPE (PCREL64, 0)
384+RELOC_TYPE (PCREL22C, 0)
385+RELOC_TYPE (PCREL22F, 0)
386+RELOC_TYPE (PCREL14WR, 0)
387+RELOC_TYPE (PCREL14DR, 0)
388+RELOC_TYPE (PCREL16F, 0)
389+RELOC_TYPE (PCREL16WF, 0)
390+RELOC_TYPE (PCREL16DF, 0)
391+RELOC_TYPE (DIR64, REL|DYN)
392+RELOC_TYPE (DIR14WR, REL)
393+RELOC_TYPE (DIR14DR, REL)
394+RELOC_TYPE (DIR16F, REL)
395+RELOC_TYPE (DIR16WF, REL)
396+RELOC_TYPE (DIR16DF, REL)
397+RELOC_TYPE (GPREL64, 0)
398+RELOC_TYPE (GPREL14WR, 0)
399+RELOC_TYPE (GPREL14DR, 0)
400+RELOC_TYPE (GPREL16F, 0)
401+RELOC_TYPE (GPREL16WF, 0)
402+RELOC_TYPE (GPREL16DF, 0)
403+RELOC_TYPE (LTOFF64, 0)
404+RELOC_TYPE (LTOFF14WR, 0)
405+RELOC_TYPE (LTOFF14DR, 0)
406+RELOC_TYPE (LTOFF16F, 0)
407+RELOC_TYPE (LTOFF16WF, 0)
408+RELOC_TYPE (LTOFF16DF, 0)
409+RELOC_TYPE (SECREL64, 0)
410+RELOC_TYPE (BASEREL14WR, 0)
411+RELOC_TYPE (BASEREL14DR, 0)
412+RELOC_TYPE (SEGREL64, 0)
413+RELOC_TYPE (PLTOFF14WR, 0)
414+RELOC_TYPE (PLTOFF14DR, 0)
415+RELOC_TYPE (PLTOFF16F, 0)
416+RELOC_TYPE (PLTOFF16WF, 0)
417+RELOC_TYPE (PLTOFF16DF, 0)
418+RELOC_TYPE (LTOFF_FPTR64, 0)
419+RELOC_TYPE (LTOFF_FPTR14WR, 0)
420+RELOC_TYPE (LTOFF_FPTR14DR, 0)
421+RELOC_TYPE (LTOFF_FPTR16F, 0)
422+RELOC_TYPE (LTOFF_FPTR16WF, 0)
423+RELOC_TYPE (LTOFF_FPTR16DF, 0)
424+RELOC_TYPE (COPY, EXEC)
425+RELOC_TYPE (IPLT, EXEC|DYN)
426+RELOC_TYPE (EPLT, 0)
427+RELOC_TYPE (TPREL32, DYN)
428+RELOC_TYPE (TPREL21L, 0)
429+RELOC_TYPE (TPREL14R, 0)
430+RELOC_TYPE (LTOFF_TP21L, 0)
431+RELOC_TYPE (LTOFF_TP14R, 0)
432+RELOC_TYPE (LTOFF_TP14F, 0)
433+RELOC_TYPE (TPREL64, 0)
434+RELOC_TYPE (TPREL14WR, 0)
435+RELOC_TYPE (TPREL14DR, 0)
436+RELOC_TYPE (TPREL16F, 0)
437+RELOC_TYPE (TPREL16WF, 0)
438+RELOC_TYPE (TPREL16DF, 0)
439+RELOC_TYPE (LTOFF_TP64, 0)
440+RELOC_TYPE (LTOFF_TP14WR, 0)
441+RELOC_TYPE (LTOFF_TP14DR, 0)
442+RELOC_TYPE (LTOFF_TP16F, 0)
443+RELOC_TYPE (LTOFF_TP16WF, 0)
444+RELOC_TYPE (LTOFF_TP16DF, 0)
445+RELOC_TYPE (TLS_DTPMOD32, DYN)
446+RELOC_TYPE (TLS_DTPMOD64, DYN)
447+
448+#define NO_RELATIVE_RELOC 1
Brad Bishop19323692019-04-05 15:28:33 -0400449diff --git a/backends/parisc_retval.c b/backends/parisc_retval.c
450new file mode 100644
451index 0000000..df7ec3a
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800452--- /dev/null
Brad Bishop19323692019-04-05 15:28:33 -0400453+++ b/backends/parisc_retval.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800454@@ -0,0 +1,213 @@
455+/* Function return value location for Linux/PA-RISC ABI.
456+ Copyright (C) 2005 Red Hat, Inc.
457+ This file is part of Red Hat elfutils.
458+
459+ Red Hat elfutils is free software; you can redistribute it and/or modify
460+ it under the terms of the GNU General Public License as published by the
461+ Free Software Foundation; version 2 of the License.
462+
463+ Red Hat elfutils is distributed in the hope that it will be useful, but
464+ WITHOUT ANY WARRANTY; without even the implied warranty of
465+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
466+ General Public License for more details.
467+
468+ You should have received a copy of the GNU General Public License along
469+ with Red Hat elfutils; if not, write to the Free Software Foundation,
470+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
471+
472+ Red Hat elfutils is an included package of the Open Invention Network.
473+ An included package of the Open Invention Network is a package for which
474+ Open Invention Network licensees cross-license their patents. No patent
475+ license is granted, either expressly or impliedly, by designation as an
476+ included package. Should you wish to participate in the Open Invention
477+ Network licensing program, please visit www.openinventionnetwork.com
478+ <http://www.openinventionnetwork.com>. */
479+
480+#ifdef HAVE_CONFIG_H
481+# include <config.h>
482+#endif
483+
484+#include <assert.h>
485+#include <dwarf.h>
486+
487+#define BACKEND parisc_
488+#include "libebl_CPU.h"
489+#include "libebl_parisc.h"
490+
491+/* %r28, or pair %r28, %r29. */
492+static const Dwarf_Op loc_intreg32[] =
493+ {
494+ { .atom = DW_OP_reg28 }, { .atom = DW_OP_piece, .number = 4 },
495+ { .atom = DW_OP_reg29 }, { .atom = DW_OP_piece, .number = 4 },
496+ };
497+
498+static const Dwarf_Op loc_intreg[] =
499+ {
500+ { .atom = DW_OP_reg28 }, { .atom = DW_OP_piece, .number = 8 },
501+ { .atom = DW_OP_reg29 }, { .atom = DW_OP_piece, .number = 8 },
502+ };
503+#define nloc_intreg 1
504+#define nloc_intregpair 4
505+
506+/* %fr4L, or pair %fr4L, %fr4R on pa-32 */
507+static const Dwarf_Op loc_fpreg32[] =
508+ {
509+ { .atom = DW_OP_regx, .number = 72 }, { .atom = DW_OP_piece, .number = 4 },
510+ { .atom = DW_OP_regx, .number = 73 }, { .atom = DW_OP_piece, .number = 4 },
511+ };
512+#define nloc_fpreg32 2
513+#define nloc_fpregpair32 4
514+
515+/* $fr4 */
516+static const Dwarf_Op loc_fpreg[] =
517+ {
518+ { .atom = DW_OP_regx, .number = 72 },
519+ };
520+#define nloc_fpreg 1
521+
522+#if 0
523+/* The return value is a structure and is actually stored in stack space
524+ passed in a hidden argument by the caller. Address of the location is stored
525+ in %r28 before function call, but it may be changed by function. */
526+static const Dwarf_Op loc_aggregate[] =
527+ {
528+ { .atom = DW_OP_breg28 },
529+ };
530+#define nloc_aggregate 1
531+#endif
532+
533+static int
534+parisc_return_value_location_ (Dwarf_Die *functypedie, const Dwarf_Op **locp, int pa64)
535+{
536+ Dwarf_Word regsize = pa64 ? 8 : 4;
537+
538+ /* Start with the function's type, and get the DW_AT_type attribute,
539+ which is the type of the return value. */
540+
541+ Dwarf_Attribute attr_mem;
542+ Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type, &attr_mem);
543+ if (attr == NULL)
544+ /* The function has no return value, like a `void' function in C. */
545+ return 0;
546+
547+ Dwarf_Die die_mem;
548+ Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
549+ int tag = dwarf_tag (typedie);
550+
551+ /* Follow typedefs and qualifiers to get to the actual type. */
552+ while (tag == DW_TAG_typedef
553+ || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
554+ || tag == DW_TAG_restrict_type)
555+ {
556+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
557+ typedie = dwarf_formref_die (attr, &die_mem);
558+ tag = dwarf_tag (typedie);
559+ }
560+
561+ switch (tag)
562+ {
563+ case -1:
564+ return -1;
565+
566+ case DW_TAG_subrange_type:
567+ if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
568+ {
569+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
570+ typedie = dwarf_formref_die (attr, &die_mem);
571+ tag = dwarf_tag (typedie);
572+ }
573+ /* Fall through. */
574+
575+ case DW_TAG_base_type:
576+ case DW_TAG_enumeration_type:
577+ case DW_TAG_pointer_type:
578+ case DW_TAG_ptr_to_member_type:
579+ {
580+ Dwarf_Word size;
581+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
582+ &attr_mem), &size) != 0)
583+ {
584+ if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
585+ size = 4;
586+ else
587+ return -1;
588+ }
589+ if (tag == DW_TAG_base_type)
590+ {
591+ Dwarf_Word encoding;
592+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
593+ &attr_mem), &encoding) != 0)
594+ return -1;
595+
596+ if (encoding == DW_ATE_float)
597+ {
598+ if (pa64) {
599+ *locp = loc_fpreg;
600+ if (size <= 8)
601+ return nloc_fpreg;
602+ }
603+ else {
604+ *locp = loc_fpreg32;
605+ if (size <= 4)
606+ return nloc_fpreg32;
607+ else if (size <= 8)
608+ return nloc_fpregpair32;
609+ }
610+ goto aggregate;
611+ }
612+ }
613+ if (pa64)
614+ *locp = loc_intreg;
615+ else
616+ *locp = loc_intreg32;
617+ if (size <= regsize)
618+ return nloc_intreg;
619+ if (size <= 2 * regsize)
620+ return nloc_intregpair;
621+
622+ /* Else fall through. */
623+ }
624+
625+ case DW_TAG_structure_type:
626+ case DW_TAG_class_type:
627+ case DW_TAG_union_type:
628+ case DW_TAG_array_type:
629+ aggregate: {
630+ Dwarf_Word size;
631+ if (dwarf_aggregate_size (typedie, &size) != 0)
632+ return -1;
633+ if (pa64)
634+ *locp = loc_intreg;
635+ else
636+ *locp = loc_intreg32;
637+ if (size <= regsize)
638+ return nloc_intreg;
639+ if (size <= 2 * regsize)
640+ return nloc_intregpair;
641+#if 0
642+ /* there should be some way to know this location... But I do not see it. */
643+ *locp = loc_aggregate;
644+ return nloc_aggregate;
645+#endif
646+ /* fall through. */
647+ }
648+ }
649+
650+ /* XXX We don't have a good way to return specific errors from ebl calls.
651+ This value means we do not understand the type, but it is well-formed
652+ DWARF and might be valid. */
653+ return -2;
654+}
655+
656+int
657+parisc_return_value_location_32 (Dwarf_Die *functypedie, const Dwarf_Op **locp)
658+{
659+ return parisc_return_value_location_ (functypedie, locp, 0);
660+}
661+
662+int
663+parisc_return_value_location_64 (Dwarf_Die *functypedie, const Dwarf_Op **locp)
664+{
665+ return parisc_return_value_location_ (functypedie, locp, 1);
666+}
667+
Brad Bishop19323692019-04-05 15:28:33 -0400668diff --git a/backends/parisc_symbol.c b/backends/parisc_symbol.c
669new file mode 100644
670index 0000000..5754bd8
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800671--- /dev/null
Brad Bishop19323692019-04-05 15:28:33 -0400672+++ b/backends/parisc_symbol.c
Brad Bishopa5c52ff2018-11-23 10:55:50 +1300673@@ -0,0 +1,113 @@
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800674+/* PA-RISC specific symbolic name handling.
675+ Copyright (C) 2002, 2005 Red Hat, Inc.
676+ This file is part of Red Hat elfutils.
677+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
678+
679+ Red Hat elfutils is free software; you can redistribute it and/or modify
680+ it under the terms of the GNU General Public License as published by the
681+ Free Software Foundation; version 2 of the License.
682+
683+ Red Hat elfutils is distributed in the hope that it will be useful, but
684+ WITHOUT ANY WARRANTY; without even the implied warranty of
685+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
686+ General Public License for more details.
687+
688+ You should have received a copy of the GNU General Public License along
689+ with Red Hat elfutils; if not, write to the Free Software Foundation,
690+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
691+
692+ Red Hat elfutils is an included package of the Open Invention Network.
693+ An included package of the Open Invention Network is a package for which
694+ Open Invention Network licensees cross-license their patents. No patent
695+ license is granted, either expressly or impliedly, by designation as an
696+ included package. Should you wish to participate in the Open Invention
697+ Network licensing program, please visit www.openinventionnetwork.com
698+ <http://www.openinventionnetwork.com>. */
699+
700+#ifdef HAVE_CONFIG_H
701+# include <config.h>
702+#endif
703+
704+#include <elf.h>
705+#include <stddef.h>
706+
707+#define BACKEND parisc_
708+#include "libebl_CPU.h"
709+
710+const char *
711+parisc_segment_type_name (int segment, char *buf __attribute__ ((unused)),
712+ size_t len __attribute__ ((unused)))
713+{
714+ switch (segment)
715+ {
716+ case PT_PARISC_ARCHEXT:
717+ return "PARISC_ARCHEXT";
718+ case PT_PARISC_UNWIND:
719+ return "PARISC_UNWIND";
720+ default:
721+ break;
722+ }
723+ return NULL;
724+}
725+
726+/* Return symbolic representation of symbol type. */
727+const char *
728+parisc_symbol_type_name(int symbol, char *buf __attribute__ ((unused)),
729+ size_t len __attribute__ ((unused)))
730+{
731+ if (symbol == STT_PARISC_MILLICODE)
732+ return "PARISC_MILLI";
733+ return NULL;
734+}
735+
736+/* Return symbolic representation of section type. */
737+const char *
738+parisc_section_type_name (int type,
739+ char *buf __attribute__ ((unused)),
740+ size_t len __attribute__ ((unused)))
741+{
742+ switch (type)
743+ {
744+ case SHT_PARISC_EXT:
745+ return "PARISC_EXT";
746+ case SHT_PARISC_UNWIND:
747+ return "PARISC_UNWIND";
748+ case SHT_PARISC_DOC:
749+ return "PARISC_DOC";
750+ }
751+
752+ return NULL;
753+}
754+
755+/* Check whether machine flags are valid. */
756+bool
757+parisc_machine_flag_check (GElf_Word flags)
758+{
759+ if (flags &~ (EF_PARISC_TRAPNIL | EF_PARISC_EXT | EF_PARISC_LSB |
760+ EF_PARISC_WIDE | EF_PARISC_NO_KABP |
761+ EF_PARISC_LAZYSWAP | EF_PARISC_ARCH))
762+ return 0;
763+
764+ GElf_Word arch = flags & EF_PARISC_ARCH;
765+
766+ return ((arch == EFA_PARISC_1_0) || (arch == EFA_PARISC_1_1) ||
767+ (arch == EFA_PARISC_2_0));
768+}
769+
770+/* Check for the simple reloc types. */
771+Elf_Type
Brad Bishopa5c52ff2018-11-23 10:55:50 +1300772+parisc_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type,
773+ int *addsub __attribute__ ((unused)))
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800774+{
775+ switch (type)
776+ {
777+ case R_PARISC_DIR64:
778+ case R_PARISC_SECREL64:
779+ return ELF_T_XWORD;
780+ case R_PARISC_DIR32:
781+ case R_PARISC_SECREL32:
782+ return ELF_T_WORD;
783+ default:
784+ return ELF_T_NUM;
785+ }
786+}
Brad Bishop19323692019-04-05 15:28:33 -0400787diff --git a/libelf/elf.h b/libelf/elf.h
788index 75043bc..6310054 100644
789--- a/libelf/elf.h
790+++ b/libelf/elf.h
Brad Bishopa5c52ff2018-11-23 10:55:50 +1300791@@ -2155,16 +2155,24 @@ enum
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800792 #define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */
793 #define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */
794 #define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */
795+#define R_PARISC_DPREL14WR 19
796+#define R_PARISC_DPREL14DR 20
797 #define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */
798 #define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */
799 #define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */
800 #define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */
801 #define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */
802+#define R_PARISC_DLTIND14F 39
803+#define R_PARISC_SETBASE 40
804 #define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */
805+#define R_PARISC_BASEREL21L 42
806+#define R_PARISC_BASEREL17R 43
807+#define R_PARISC_BASEREL14R 46
808 #define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */
809 #define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */
810 #define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */
811 #define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */
812+#define R_PARISC_PLTOFF14F 55
813 #define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */
814 #define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */
815 #define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */
Brad Bishopa5c52ff2018-11-23 10:55:50 +1300816@@ -2173,6 +2181,7 @@ enum
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800817 #define R_PARISC_PLABEL21L 66 /* Left 21 bits of fdesc address. */
818 #define R_PARISC_PLABEL14R 70 /* Right 14 bits of fdesc address. */
819 #define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */
820+#define R_PARISC_PCREL22C 73
821 #define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */
822 #define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */
823 #define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */
Brad Bishopa5c52ff2018-11-23 10:55:50 +1300824@@ -2198,6 +2207,8 @@ enum
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800825 #define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */
826 #define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */
827 #define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */
828+#define R_PARISC_BASEREL14WR 107
829+#define R_PARISC_BASEREL14DR 108
830 #define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */
831 #define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */
832 #define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */