summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/elfutils/files/debian
diff options
context:
space:
mode:
authorHongxu Jia <hongxu.jia@windriver.com>2017-08-16 04:31:18 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-08-18 10:40:26 +0100
commit70de26076f36205b914be1b1911e5fc0afd65edb (patch)
tree8462c68ee795e2ac168c81db0ed52fae670f554a /meta/recipes-devtools/elfutils/files/debian
parenta02826add027f71d1fca56547b2b72db28b1005f (diff)
downloadpoky-70de26076f36205b914be1b1911e5fc0afd65edb.tar.gz
elfutils: 0.168 -> 0.170
The 0.170 Fixed CVE issues - CVE-2017-7608 - CVE-2017-7612 - CVE-2017-7611 - CVE-2017-7610 - CVE-2016-10255 - CVE-2017-7613 - CVE-2017-7609 - CVE-2016-10254 - CVE-2017-7607 Rebase patches to 0.170 - dso-link-change.patch -> 0001 - Fix_elf_cvt_gunhash.patch -> 0002 - fixheadercheck.patch -> 0003 - 0001-remove-the-unneed-checking.patch -> 0004 - 0001-fix-a-stack-usage-warning.patch -> 0005 - aarch64_uio.patch -> 0006 - shadow.patch -> 0007 - 0001-build-Provide-alternatives-for-glibc-assumptions-hel.patch -> 0008 - debian/mips_backend.diff -> debian/mips_backend.patch Drop obsolete patches - 0001-elf_getarsym-Silence-Werror-maybe-uninitialized-fals.patch Upstream fixed it https://sourceware.org/git/?p=elfutils.git;a=commit;h=7114c513fbebcca8b76796b7f64b57447ba383e1 - Fix_one_GCC7_warning.patch It is a backported patch https://sourceware.org/git/?p=elfutils.git;a=commit;h=93c51144c3f664d4e9709da75a1d0fa00ea0fe95 - Drop debian patches, they modify test case. debian/testsuite-ignore-elflint.diff debian/kfreebsd_path.patch debian/hurd_path.patch debian/ignore_strmerge.diff (From OE-Core rev: 4ca17f9275c81f27498b7ac07d9fe7e8193fdd71) Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/elfutils/files/debian')
-rw-r--r--meta/recipes-devtools/elfutils/files/debian/0001-Ignore-differences-between-mips-machine-identifiers.patch35
-rw-r--r--meta/recipes-devtools/elfutils/files/debian/0002-Add-support-for-mips64-abis-in-mips_retval.c.patch171
-rw-r--r--meta/recipes-devtools/elfutils/files/debian/0003-Add-mips-n64-relocation-format-hack.patch229
-rw-r--r--meta/recipes-devtools/elfutils/files/debian/arm_backend.diff603
-rw-r--r--meta/recipes-devtools/elfutils/files/debian/fallthrough.patch36
-rw-r--r--meta/recipes-devtools/elfutils/files/debian/hppa_backend.diff802
-rw-r--r--meta/recipes-devtools/elfutils/files/debian/mips_backend.patch715
-rw-r--r--meta/recipes-devtools/elfutils/files/debian/mips_readelf_w.patch25
8 files changed, 2616 insertions, 0 deletions
diff --git a/meta/recipes-devtools/elfutils/files/debian/0001-Ignore-differences-between-mips-machine-identifiers.patch b/meta/recipes-devtools/elfutils/files/debian/0001-Ignore-differences-between-mips-machine-identifiers.patch
new file mode 100644
index 0000000000..e0291b4cf3
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/debian/0001-Ignore-differences-between-mips-machine-identifiers.patch
@@ -0,0 +1,35 @@
1From 77cb4a53c270d5854d3af24f19547bc3de825233 Mon Sep 17 00:00:00 2001
2From: James Cowgill <james410@cowgill.org.uk>
3Date: Mon, 5 Jan 2015 15:16:58 +0000
4Subject: [PATCH 1/3] Ignore differences between mips machine identifiers
5
6Little endian binaries actually use EM_MIPS so you can't tell the endianness
7from the elf machine id. Also, the EM_MIPS_RS3_LE machine is dead anyway (the
8kernel will not load binaries containing it).
9
10Signed-off-by: James Cowgill <james410@cowgill.org.uk>
11
12Upstream-Status: Backport [from debian]
13Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
14
15---
16 backends/mips_init.c | 6 +-----
17 1 file changed, 1 insertion(+), 5 deletions(-)
18
19Index: b/backends/mips_init.c
20===================================================================
21--- a/backends/mips_init.c
22+++ b/backends/mips_init.c
23@@ -45,11 +45,7 @@ mips_init (Elf *elf __attribute__ ((unus
24 return NULL;
25
26 /* We handle it. */
27- if (machine == EM_MIPS)
28- eh->name = "MIPS R3000 big-endian";
29- else if (machine == EM_MIPS_RS3_LE)
30- eh->name = "MIPS R3000 little-endian";
31-
32+ eh->name = "MIPS";
33 mips_init_reloc (eh);
34 HOOK (eh, reloc_simple_type);
35 HOOK (eh, return_value_location);
diff --git a/meta/recipes-devtools/elfutils/files/debian/0002-Add-support-for-mips64-abis-in-mips_retval.c.patch b/meta/recipes-devtools/elfutils/files/debian/0002-Add-support-for-mips64-abis-in-mips_retval.c.patch
new file mode 100644
index 0000000000..b17498f5fa
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/debian/0002-Add-support-for-mips64-abis-in-mips_retval.c.patch
@@ -0,0 +1,171 @@
1From fdaab18a65ed2529656baa64cb6169f34d7e507b Mon Sep 17 00:00:00 2001
2From: James Cowgill <james410@cowgill.org.uk>
3Date: Mon, 5 Jan 2015 15:17:01 +0000
4Subject: [PATCH 2/3] Add support for mips64 abis in mips_retval.c
5
6Signed-off-by: James Cowgill <james410@cowgill.org.uk>
7
8Upstream-Status: Backport [from debian]
9Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
10---
11 backends/mips_retval.c | 104 ++++++++++++++++++++++++++++++++++++++++++++-----
12 1 file changed, 94 insertions(+), 10 deletions(-)
13
14diff --git a/backends/mips_retval.c b/backends/mips_retval.c
15index 33f12a7..d5c6ef0 100644
16--- a/backends/mips_retval.c
17+++ b/backends/mips_retval.c
18@@ -91,6 +91,8 @@ enum mips_abi find_mips_abi(Elf *elf)
19 default:
20 if ((elf_flags & EF_MIPS_ABI2))
21 return MIPS_ABI_N32;
22+ else if ((ehdr->e_ident[EI_CLASS] == ELFCLASS64))
23+ return MIPS_ABI_N64;
24 }
25
26 /* GCC creates a pseudo-section whose name describes the ABI. */
27@@ -195,6 +197,57 @@ static const Dwarf_Op loc_aggregate[] =
28 };
29 #define nloc_aggregate 1
30
31+/* Test if a struct member is a float */
32+static int is_float_child(Dwarf_Die *childdie)
33+{
34+ /* Test if this is actually a struct member */
35+ if (dwarf_tag(childdie) != DW_TAG_member)
36+ return 0;
37+
38+ /* Get type of member */
39+ Dwarf_Attribute attr_mem;
40+ Dwarf_Die child_type_mem;
41+ Dwarf_Die *child_typedie =
42+ dwarf_formref_die(dwarf_attr_integrate(childdie,
43+ DW_AT_type,
44+ &attr_mem), &child_type_mem);
45+
46+ if (dwarf_tag(child_typedie) != DW_TAG_base_type)
47+ return 0;
48+
49+ /* Get base subtype */
50+ Dwarf_Word encoding;
51+ if (dwarf_formudata (dwarf_attr_integrate (child_typedie,
52+ DW_AT_encoding,
53+ &attr_mem), &encoding) != 0)
54+ return 0;
55+
56+ return encoding == DW_ATE_float;
57+}
58+
59+/* Returns the number of fpregs which can be returned in the given struct */
60+static int get_struct_fpregs(Dwarf_Die *structtypedie)
61+{
62+ Dwarf_Die child_mem;
63+ int fpregs = 0;
64+
65+ /* Get first structure member */
66+ if (dwarf_child(structtypedie, &child_mem) != 0)
67+ return 0;
68+
69+ do
70+ {
71+ /* Ensure this register is a float */
72+ if (!is_float_child(&child_mem))
73+ return 0;
74+
75+ fpregs++;
76+ }
77+ while (dwarf_siblingof (&child_mem, &child_mem) == 0);
78+
79+ return fpregs;
80+}
81+
82 int
83 mips_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
84 {
85@@ -240,6 +293,7 @@ mips_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
86 tag = dwarf_tag (typedie);
87 }
88
89+ Dwarf_Word size;
90 switch (tag)
91 {
92 case -1:
93@@ -258,8 +312,6 @@ mips_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
94 case DW_TAG_enumeration_type:
95 case DW_TAG_pointer_type:
96 case DW_TAG_ptr_to_member_type:
97- {
98- Dwarf_Word size;
99 if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
100 &attr_mem), &size) != 0)
101 {
102@@ -289,7 +341,7 @@ mips_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
103 if (size <= 4*regsize && abi == MIPS_ABI_O32)
104 return nloc_fpregquad;
105
106- goto aggregate;
107+ goto large;
108 }
109 }
110 *locp = ABI_LOC(loc_intreg, regsize);
111@@ -298,18 +350,50 @@ mips_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
112 if (size <= 2*regsize)
113 return nloc_intregpair;
114
115- /* Else fall through. Shouldn't happen though (at least with gcc) */
116- }
117+ /* Else pass in memory. Shouldn't happen though (at least with gcc) */
118+ goto large;
119
120 case DW_TAG_structure_type:
121 case DW_TAG_class_type:
122 case DW_TAG_union_type:
123- case DW_TAG_array_type:
124- aggregate:
125- /* XXX TODO: Can't handle structure return with other ABI's yet :-/ */
126- if ((abi != MIPS_ABI_O32) && (abi != MIPS_ABI_O64))
127- return -2;
128+ /* Handle special cases for structures <= 128 bytes in newer ABIs */
129+ if (abi == MIPS_ABI_EABI32 || abi == MIPS_ABI_EABI64 ||
130+ abi == MIPS_ABI_N32 || abi == MIPS_ABI_N64)
131+ {
132+ if (dwarf_aggregate_size (typedie, &size) == 0 && size <= 16)
133+ {
134+ /*
135+ * Special case in N64 / N32 -
136+ * structures containing only floats are returned in fp regs.
137+ * Everything else is returned in integer regs.
138+ */
139+ if (tag != DW_TAG_union_type &&
140+ (abi == MIPS_ABI_N32 || abi == MIPS_ABI_N64))
141+ {
142+ int num_fpregs = get_struct_fpregs(typedie);
143+ if (num_fpregs == 1 || num_fpregs == 2)
144+ {
145+ *locp = loc_fpreg;
146+ if (num_fpregs == 1)
147+ return nloc_fpreg;
148+ else
149+ return nloc_fpregpair;
150+ }
151+ }
152+
153+ *locp = loc_intreg;
154+ if (size <= 8)
155+ return nloc_intreg;
156+ else
157+ return nloc_intregpair;
158+ }
159+ }
160+
161+ /* Fallthrough to handle large types */
162
163+ case DW_TAG_array_type:
164+ large:
165+ /* Return large structures in memory */
166 *locp = loc_aggregate;
167 return nloc_aggregate;
168 }
169--
1702.1.4
171
diff --git a/meta/recipes-devtools/elfutils/files/debian/0003-Add-mips-n64-relocation-format-hack.patch b/meta/recipes-devtools/elfutils/files/debian/0003-Add-mips-n64-relocation-format-hack.patch
new file mode 100644
index 0000000000..2a5f8628d9
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/debian/0003-Add-mips-n64-relocation-format-hack.patch
@@ -0,0 +1,229 @@
1From 59d4b8c48e5040af7e02b34eb26ea602ec82a38e Mon Sep 17 00:00:00 2001
2From: James Cowgill <james410@cowgill.org.uk>
3Date: Mon, 5 Jan 2015 15:17:02 +0000
4Subject: [PATCH 3/3] Add mips n64 relocation format hack
5
6MIPSEL N64 ELF files use a slightly different format for storing relocation
7entries which is incompatible with the normal R_SYM / R_INFO macros.
8To workaround this, we rearrange the bytes in the relocation's r_info field
9when reading and writing the relocations.
10
11This patch also ensures that strip.c sets the correct value of e_machine
12before manipulating relocations so that these changes take effect.
13
14Signed-off-by: James Cowgill <james410@cowgill.org.uk>
15
16Upstream-Status: Backport [from debian]
17Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
18---
19 libelf/gelf_getrel.c | 25 +++++++++++++++++++++++--
20 libelf/gelf_getrela.c | 25 +++++++++++++++++++++++--
21 libelf/gelf_update_rel.c | 20 +++++++++++++++++++-
22 libelf/gelf_update_rela.c | 20 +++++++++++++++++++-
23 src/strip.c | 17 +++++++++++++++++
24 5 files changed, 101 insertions(+), 6 deletions(-)
25
26Index: b/libelf/gelf_getrel.c
27===================================================================
28--- a/libelf/gelf_getrel.c
29+++ b/libelf/gelf_getrel.c
30@@ -36,6 +36,7 @@
31
32 #include "libelfP.h"
33
34+#define EF_MIPS_ABI 0x0000F000
35
36 GElf_Rel *
37 gelf_getrel (Elf_Data *data, int ndx, GElf_Rel *dst)
38@@ -89,8 +90,28 @@ gelf_getrel (Elf_Data *data, int ndx, GE
39 result = NULL;
40 }
41 else
42- result = memcpy (dst, &((Elf64_Rel *) data_scn->d.d_buf)[ndx],
43- sizeof (Elf64_Rel));
44+ {
45+ GElf_Ehdr hdr;
46+ result = memcpy (dst, &((Elf64_Rel *) data_scn->d.d_buf)[ndx],
47+ sizeof (Elf64_Rel));
48+
49+ if (gelf_getehdr(scn->elf, &hdr) != NULL &&
50+ hdr.e_ident[EI_DATA] == ELFDATA2LSB &&
51+ hdr.e_machine == EM_MIPS &&
52+ (hdr.e_flags & EF_MIPS_ABI) == 0)
53+ {
54+ /*
55+ * The relocation format is mangled on MIPSEL N64
56+ * We'll adjust it so at least R_SYM will work on it
57+ */
58+ GElf_Xword r_info = dst->r_info;
59+ dst->r_info = (r_info << 32) |
60+ ((r_info >> 8) & 0xFF000000) |
61+ ((r_info >> 24) & 0x00FF0000) |
62+ ((r_info >> 40) & 0x0000FF00) |
63+ ((r_info >> 56) & 0x000000FF);
64+ }
65+ }
66 }
67
68 rwlock_unlock (scn->elf->lock);
69Index: b/libelf/gelf_getrela.c
70===================================================================
71--- a/libelf/gelf_getrela.c
72+++ b/libelf/gelf_getrela.c
73@@ -36,6 +36,7 @@
74
75 #include "libelfP.h"
76
77+#define EF_MIPS_ABI 0x0000F000
78
79 GElf_Rela *
80 gelf_getrela (Elf_Data *data, int ndx, GElf_Rela *dst)
81@@ -90,8 +91,28 @@ gelf_getrela (Elf_Data *data, int ndx, G
82 result = NULL;
83 }
84 else
85- result = memcpy (dst, &((Elf64_Rela *) data_scn->d.d_buf)[ndx],
86- sizeof (Elf64_Rela));
87+ {
88+ GElf_Ehdr hdr;
89+ result = memcpy (dst, &((Elf64_Rela *) data_scn->d.d_buf)[ndx],
90+ sizeof (Elf64_Rela));
91+
92+ if (gelf_getehdr(scn->elf, &hdr) != NULL &&
93+ hdr.e_ident[EI_DATA] == ELFDATA2LSB &&
94+ hdr.e_machine == EM_MIPS &&
95+ (hdr.e_flags & EF_MIPS_ABI) == 0)
96+ {
97+ /*
98+ * The relocation format is mangled on MIPSEL N64
99+ * We'll adjust it so at least R_SYM will work on it
100+ */
101+ GElf_Xword r_info = dst->r_info;
102+ dst->r_info = (r_info << 32) |
103+ ((r_info >> 8) & 0xFF000000) |
104+ ((r_info >> 24) & 0x00FF0000) |
105+ ((r_info >> 40) & 0x0000FF00) |
106+ ((r_info >> 56) & 0x000000FF);
107+ }
108+ }
109 }
110
111 rwlock_unlock (scn->elf->lock);
112Index: b/libelf/gelf_update_rel.c
113===================================================================
114--- a/libelf/gelf_update_rel.c
115+++ b/libelf/gelf_update_rel.c
116@@ -36,6 +36,7 @@
117
118 #include "libelfP.h"
119
120+#define EF_MIPS_ABI 0x0000F000
121
122 int
123 gelf_update_rel (Elf_Data *dst, int ndx, GElf_Rel *src)
124@@ -86,6 +87,9 @@ gelf_update_rel (Elf_Data *dst, int ndx,
125 }
126 else
127 {
128+ GElf_Ehdr hdr;
129+ GElf_Rel value = *src;
130+
131 /* Check whether we have to resize the data buffer. */
132 if (INVALID_NDX (ndx, Elf64_Rel, &data_scn->d))
133 {
134@@ -93,7 +97,21 @@ gelf_update_rel (Elf_Data *dst, int ndx,
135 goto out;
136 }
137
138- ((Elf64_Rel *) data_scn->d.d_buf)[ndx] = *src;
139+ if (gelf_getehdr(scn->elf, &hdr) != NULL &&
140+ hdr.e_ident[EI_DATA] == ELFDATA2LSB &&
141+ hdr.e_machine == EM_MIPS &&
142+ (hdr.e_flags & EF_MIPS_ABI) == 0)
143+ {
144+ /* Undo the MIPSEL N64 hack from gelf_getrel */
145+ GElf_Xword r_info = value.r_info;
146+ value.r_info = (r_info >> 32) |
147+ ((r_info << 8) & 0x000000FF00000000) |
148+ ((r_info << 24) & 0x0000FF0000000000) |
149+ ((r_info << 40) & 0x00FF000000000000) |
150+ ((r_info << 56) & 0xFF00000000000000);
151+ }
152+
153+ ((Elf64_Rel *) data_scn->d.d_buf)[ndx] = value;
154 }
155
156 result = 1;
157Index: b/libelf/gelf_update_rela.c
158===================================================================
159--- a/libelf/gelf_update_rela.c
160+++ b/libelf/gelf_update_rela.c
161@@ -36,6 +36,7 @@
162
163 #include "libelfP.h"
164
165+#define EF_MIPS_ABI 0x0000F000
166
167 int
168 gelf_update_rela (Elf_Data *dst, int ndx, GElf_Rela *src)
169@@ -89,6 +90,9 @@ gelf_update_rela (Elf_Data *dst, int ndx
170 }
171 else
172 {
173+ GElf_Ehdr hdr;
174+ GElf_Rela value = *src;
175+
176 /* Check whether we have to resize the data buffer. */
177 if (INVALID_NDX (ndx, Elf64_Rela, &data_scn->d))
178 {
179@@ -96,7 +100,21 @@ gelf_update_rela (Elf_Data *dst, int ndx
180 goto out;
181 }
182
183- ((Elf64_Rela *) data_scn->d.d_buf)[ndx] = *src;
184+ if (gelf_getehdr(scn->elf, &hdr) != NULL &&
185+ hdr.e_ident[EI_DATA] == ELFDATA2LSB &&
186+ hdr.e_machine == EM_MIPS &&
187+ (hdr.e_flags & EF_MIPS_ABI) == 0)
188+ {
189+ /* Undo the MIPSEL N64 hack from gelf_getrel */
190+ GElf_Xword r_info = value.r_info;
191+ value.r_info = (r_info >> 32) |
192+ ((r_info << 8) & 0x000000FF00000000) |
193+ ((r_info << 24) & 0x0000FF0000000000) |
194+ ((r_info << 40) & 0x00FF000000000000) |
195+ ((r_info << 56) & 0xFF00000000000000);
196+ }
197+
198+ ((Elf64_Rela *) data_scn->d.d_buf)[ndx] = value;
199 }
200
201 result = 1;
202Index: b/src/strip.c
203===================================================================
204--- a/src/strip.c
205+++ b/src/strip.c
206@@ -532,6 +532,23 @@ handle_elf (int fd, Elf *elf, const char
207 goto fail;
208 }
209
210+ /* Copy identity part of the ELF header now */
211+ newehdr = gelf_getehdr (newelf, &newehdr_mem);
212+ if (newehdr == NULL)
213+ INTERNAL_ERROR (fname);
214+
215+ memcpy (newehdr->e_ident, ehdr->e_ident, EI_NIDENT);
216+ newehdr->e_type = ehdr->e_type;
217+ newehdr->e_machine = ehdr->e_machine;
218+ newehdr->e_version = ehdr->e_version;
219+
220+ if (gelf_update_ehdr (newelf, newehdr) == 0)
221+ {
222+ error (0, 0, gettext ("%s: error while creating ELF header: %s"),
223+ fname, elf_errmsg (-1));
224+ return 1;
225+ }
226+
227 /* Copy over the old program header if needed. */
228 if (ehdr->e_type != ET_REL)
229 for (cnt = 0; cnt < phnum; ++cnt)
diff --git a/meta/recipes-devtools/elfutils/files/debian/arm_backend.diff b/meta/recipes-devtools/elfutils/files/debian/arm_backend.diff
new file mode 100644
index 0000000000..50f4b059e3
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/debian/arm_backend.diff
@@ -0,0 +1,603 @@
1Upstream-Status: Backport [from debian]
2Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
3
4Index: b/backends/arm_init.c
5===================================================================
6--- a/backends/arm_init.c
7+++ b/backends/arm_init.c
8@@ -35,20 +35,31 @@
9 #define RELOC_PREFIX R_ARM_
10 #include "libebl_CPU.h"
11
12+#include "libebl_arm.h"
13+
14 /* This defines the common reloc hooks based on arm_reloc.def. */
15 #include "common-reloc.c"
16
17
18 const char *
19-arm_init (Elf *elf __attribute__ ((unused)),
20+arm_init (Elf *elf,
21 GElf_Half machine __attribute__ ((unused)),
22 Ebl *eh,
23 size_t ehlen)
24 {
25+ int soft_float = 0;
26+
27 /* Check whether the Elf_BH object has a sufficent size. */
28 if (ehlen < sizeof (Ebl))
29 return NULL;
30
31+ if (elf) {
32+ GElf_Ehdr ehdr_mem;
33+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
34+ if (ehdr && (ehdr->e_flags & EF_ARM_SOFT_FLOAT))
35+ soft_float = 1;
36+ }
37+
38 /* We handle it. */
39 eh->name = "ARM";
40 arm_init_reloc (eh);
41@@ -60,7 +71,10 @@ arm_init (Elf *elf __attribute__ ((unuse
42 HOOK (eh, core_note);
43 HOOK (eh, auxv_info);
44 HOOK (eh, check_object_attribute);
45- HOOK (eh, return_value_location);
46+ if (soft_float)
47+ eh->return_value_location = arm_return_value_location_soft;
48+ else
49+ eh->return_value_location = arm_return_value_location_hard;
50 HOOK (eh, abi_cfi);
51 HOOK (eh, check_reloc_target_type);
52 HOOK (eh, symbol_type_name);
53Index: b/backends/arm_regs.c
54===================================================================
55--- a/backends/arm_regs.c
56+++ b/backends/arm_regs.c
57@@ -31,6 +31,7 @@
58 #endif
59
60 #include <string.h>
61+#include <stdio.h>
62 #include <dwarf.h>
63
64 #define BACKEND arm_
65@@ -76,6 +77,9 @@ arm_register_info (Ebl *ebl __attribute_
66 break;
67
68 case 16 + 0 ... 16 + 7:
69+ /* AADWARF says that there are no registers in that range,
70+ * but gcc maps FPA registers here
71+ */
72 regno += 96 - 16;
73 /* Fall through. */
74 case 96 + 0 ... 96 + 7:
75@@ -87,11 +91,139 @@ arm_register_info (Ebl *ebl __attribute_
76 namelen = 2;
77 break;
78
79+ case 64 + 0 ... 64 + 9:
80+ *setname = "VFP";
81+ *bits = 32;
82+ *type = DW_ATE_float;
83+ name[0] = 's';
84+ name[1] = regno - 64 + '0';
85+ namelen = 2;
86+ break;
87+
88+ case 64 + 10 ... 64 + 31:
89+ *setname = "VFP";
90+ *bits = 32;
91+ *type = DW_ATE_float;
92+ name[0] = 's';
93+ name[1] = (regno - 64) / 10 + '0';
94+ name[2] = (regno - 64) % 10 + '0';
95+ namelen = 3;
96+ break;
97+
98+ case 104 + 0 ... 104 + 7:
99+ /* XXX TODO:
100+ * This can be either intel wireless MMX general purpose/control
101+ * registers or xscale accumulator, which have different usage.
102+ * We only have the intel wireless MMX here now.
103+ * The name needs to be changed for the xscale accumulator too. */
104+ *setname = "MMX";
105+ *type = DW_ATE_unsigned;
106+ *bits = 32;
107+ memcpy(name, "wcgr", 4);
108+ name[4] = regno - 104 + '0';
109+ namelen = 5;
110+ break;
111+
112+ case 112 + 0 ... 112 + 9:
113+ *setname = "MMX";
114+ *type = DW_ATE_unsigned;
115+ *bits = 64;
116+ name[0] = 'w';
117+ name[1] = 'r';
118+ name[2] = regno - 112 + '0';
119+ namelen = 3;
120+ break;
121+
122+ case 112 + 10 ... 112 + 15:
123+ *setname = "MMX";
124+ *type = DW_ATE_unsigned;
125+ *bits = 64;
126+ name[0] = 'w';
127+ name[1] = 'r';
128+ name[2] = '1';
129+ name[3] = regno - 112 - 10 + '0';
130+ namelen = 4;
131+ break;
132+
133 case 128:
134+ *setname = "state";
135 *type = DW_ATE_unsigned;
136 return stpcpy (name, "spsr") + 1 - name;
137
138+ case 129:
139+ *setname = "state";
140+ *type = DW_ATE_unsigned;
141+ return stpcpy(name, "spsr_fiq") + 1 - name;
142+
143+ case 130:
144+ *setname = "state";
145+ *type = DW_ATE_unsigned;
146+ return stpcpy(name, "spsr_irq") + 1 - name;
147+
148+ case 131:
149+ *setname = "state";
150+ *type = DW_ATE_unsigned;
151+ return stpcpy(name, "spsr_abt") + 1 - name;
152+
153+ case 132:
154+ *setname = "state";
155+ *type = DW_ATE_unsigned;
156+ return stpcpy(name, "spsr_und") + 1 - name;
157+
158+ case 133:
159+ *setname = "state";
160+ *type = DW_ATE_unsigned;
161+ return stpcpy(name, "spsr_svc") + 1 - name;
162+
163+ case 144 ... 150:
164+ *setname = "integer";
165+ *type = DW_ATE_signed;
166+ *bits = 32;
167+ return sprintf(name, "r%d_usr", regno - 144 + 8) + 1;
168+
169+ case 151 ... 157:
170+ *setname = "integer";
171+ *type = DW_ATE_signed;
172+ *bits = 32;
173+ return sprintf(name, "r%d_fiq", regno - 151 + 8) + 1;
174+
175+ case 158 ... 159:
176+ *setname = "integer";
177+ *type = DW_ATE_signed;
178+ *bits = 32;
179+ return sprintf(name, "r%d_irq", regno - 158 + 13) + 1;
180+
181+ case 160 ... 161:
182+ *setname = "integer";
183+ *type = DW_ATE_signed;
184+ *bits = 32;
185+ return sprintf(name, "r%d_abt", regno - 160 + 13) + 1;
186+
187+ case 162 ... 163:
188+ *setname = "integer";
189+ *type = DW_ATE_signed;
190+ *bits = 32;
191+ return sprintf(name, "r%d_und", regno - 162 + 13) + 1;
192+
193+ case 164 ... 165:
194+ *setname = "integer";
195+ *type = DW_ATE_signed;
196+ *bits = 32;
197+ return sprintf(name, "r%d_svc", regno - 164 + 13) + 1;
198+
199+ case 192 ... 199:
200+ *setname = "MMX";
201+ *bits = 32;
202+ *type = DW_ATE_unsigned;
203+ name[0] = 'w';
204+ name[1] = 'c';
205+ name[2] = regno - 192 + '0';
206+ namelen = 3;
207+ break;
208+
209 case 256 + 0 ... 256 + 9:
210+ /* XXX TODO: Neon also uses those registers and can contain
211+ * both float and integers */
212 *setname = "VFP";
213 *type = DW_ATE_float;
214 *bits = 64;
215Index: b/backends/arm_retval.c
216===================================================================
217--- a/backends/arm_retval.c
218+++ b/backends/arm_retval.c
219@@ -48,6 +48,13 @@ static const Dwarf_Op loc_intreg[] =
220 #define nloc_intreg 1
221 #define nloc_intregs(n) (2 * (n))
222
223+/* f1 */ /* XXX TODO: f0 can also have number 96 if program was compiled with -mabi=aapcs */
224+static const Dwarf_Op loc_fpreg[] =
225+ {
226+ { .atom = DW_OP_reg16 },
227+ };
228+#define nloc_fpreg 1
229+
230 /* The return value is a structure and is actually stored in stack space
231 passed in a hidden argument by the caller. But, the compiler
232 helpfully returns the address of that space in r0. */
233@@ -58,8 +65,9 @@ static const Dwarf_Op loc_aggregate[] =
234 #define nloc_aggregate 1
235
236
237-int
238-arm_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
239+static int
240+arm_return_value_location_ (Dwarf_Die *functypedie, const Dwarf_Op **locp,
241+ int soft_float)
242 {
243 /* Start with the function's type, and get the DW_AT_type attribute,
244 which is the type of the return value. */
245@@ -98,6 +106,21 @@ arm_return_value_location (Dwarf_Die *fu
246 else
247 return -1;
248 }
249+ if (tag == DW_TAG_base_type)
250+ {
251+ Dwarf_Word encoding;
252+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
253+ &attr_mem), &encoding) != 0)
254+ return -1;
255+
256+ if ((encoding == DW_ATE_float) && !soft_float)
257+ {
258+ *locp = loc_fpreg;
259+ if (size <= 8)
260+ return nloc_fpreg;
261+ goto aggregate;
262+ }
263+ }
264 if (size <= 16)
265 {
266 intreg:
267@@ -106,6 +129,7 @@ arm_return_value_location (Dwarf_Die *fu
268 }
269
270 aggregate:
271+ /* XXX TODO sometimes aggregates are returned in r0 (-mabi=aapcs) */
272 *locp = loc_aggregate;
273 return nloc_aggregate;
274 }
275@@ -125,3 +149,18 @@ arm_return_value_location (Dwarf_Die *fu
276 DWARF and might be valid. */
277 return -2;
278 }
279+
280+/* return location for -mabi=apcs-gnu -msoft-float */
281+int
282+arm_return_value_location_soft (Dwarf_Die *functypedie, const Dwarf_Op **locp)
283+{
284+ return arm_return_value_location_ (functypedie, locp, 1);
285+}
286+
287+/* return location for -mabi=apcs-gnu -mhard-float (current default) */
288+int
289+arm_return_value_location_hard (Dwarf_Die *functypedie, const Dwarf_Op **locp)
290+{
291+ return arm_return_value_location_ (functypedie, locp, 0);
292+}
293+
294Index: b/libelf/elf.h
295===================================================================
296--- a/libelf/elf.h
297+++ b/libelf/elf.h
298@@ -2593,6 +2593,9 @@ enum
299 #define EF_ARM_EABI_VER4 0x04000000
300 #define EF_ARM_EABI_VER5 0x05000000
301
302+/* EI_OSABI values */
303+#define ELFOSABI_ARM_AEABI 64 /* Contains symbol versioning. */
304+
305 /* Additional symbol types for Thumb. */
306 #define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */
307 #define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */
308@@ -2610,12 +2613,19 @@ enum
309
310 /* Processor specific values for the Phdr p_type field. */
311 #define PT_ARM_EXIDX (PT_LOPROC + 1) /* ARM unwind segment. */
312+#define PT_ARM_UNWIND PT_ARM_EXIDX
313
314 /* Processor specific values for the Shdr sh_type field. */
315 #define SHT_ARM_EXIDX (SHT_LOPROC + 1) /* ARM unwind section. */
316 #define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) /* Preemption details. */
317 #define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) /* ARM attributes section. */
318
319+/* Processor specific values for the Dyn d_tag field. */
320+#define DT_ARM_RESERVED1 (DT_LOPROC + 0)
321+#define DT_ARM_SYMTABSZ (DT_LOPROC + 1)
322+#define DT_ARM_PREEMTMAB (DT_LOPROC + 2)
323+#define DT_ARM_RESERVED2 (DT_LOPROC + 3)
324+#define DT_ARM_NUM 4
325
326 /* AArch64 relocs. */
327
328@@ -2908,6 +2918,7 @@ enum
329 TLS block (LDR, STR). */
330 #define R_ARM_TLS_IE12GP 111 /* 12 bit GOT entry relative
331 to GOT origin (LDR). */
332+/* 112 - 127 private range */
333 #define R_ARM_ME_TOO 128 /* Obsolete. */
334 #define R_ARM_THM_TLS_DESCSEQ 129
335 #define R_ARM_THM_TLS_DESCSEQ16 129
336Index: b/backends/libebl_arm.h
337===================================================================
338--- /dev/null
339+++ b/backends/libebl_arm.h
340@@ -0,0 +1,9 @@
341+#ifndef _LIBEBL_ARM_H
342+#define _LIBEBL_ARM_H 1
343+
344+#include <libdw.h>
345+
346+extern int arm_return_value_location_soft(Dwarf_Die *, const Dwarf_Op **locp);
347+extern int arm_return_value_location_hard(Dwarf_Die *, const Dwarf_Op **locp);
348+
349+#endif
350Index: b/tests/run-allregs.sh
351===================================================================
352--- a/tests/run-allregs.sh
353+++ b/tests/run-allregs.sh
354@@ -2672,7 +2672,28 @@ integer registers:
355 13: sp (sp), address 32 bits
356 14: lr (lr), address 32 bits
357 15: pc (pc), address 32 bits
358- 128: spsr (spsr), unsigned 32 bits
359+ 144: r8_usr (r8_usr), signed 32 bits
360+ 145: r9_usr (r9_usr), signed 32 bits
361+ 146: r10_usr (r10_usr), signed 32 bits
362+ 147: r11_usr (r11_usr), signed 32 bits
363+ 148: r12_usr (r12_usr), signed 32 bits
364+ 149: r13_usr (r13_usr), signed 32 bits
365+ 150: r14_usr (r14_usr), signed 32 bits
366+ 151: r8_fiq (r8_fiq), signed 32 bits
367+ 152: r9_fiq (r9_fiq), signed 32 bits
368+ 153: r10_fiq (r10_fiq), signed 32 bits
369+ 154: r11_fiq (r11_fiq), signed 32 bits
370+ 155: r12_fiq (r12_fiq), signed 32 bits
371+ 156: r13_fiq (r13_fiq), signed 32 bits
372+ 157: r14_fiq (r14_fiq), signed 32 bits
373+ 158: r13_irq (r13_irq), signed 32 bits
374+ 159: r14_irq (r14_irq), signed 32 bits
375+ 160: r13_abt (r13_abt), signed 32 bits
376+ 161: r14_abt (r14_abt), signed 32 bits
377+ 162: r13_und (r13_und), signed 32 bits
378+ 163: r14_und (r14_und), signed 32 bits
379+ 164: r13_svc (r13_svc), signed 32 bits
380+ 165: r14_svc (r14_svc), signed 32 bits
381 FPA registers:
382 16: f0 (f0), float 96 bits
383 17: f1 (f1), float 96 bits
384@@ -2690,7 +2711,72 @@ FPA registers:
385 101: f5 (f5), float 96 bits
386 102: f6 (f6), float 96 bits
387 103: f7 (f7), float 96 bits
388+MMX registers:
389+ 104: wcgr0 (wcgr0), unsigned 32 bits
390+ 105: wcgr1 (wcgr1), unsigned 32 bits
391+ 106: wcgr2 (wcgr2), unsigned 32 bits
392+ 107: wcgr3 (wcgr3), unsigned 32 bits
393+ 108: wcgr4 (wcgr4), unsigned 32 bits
394+ 109: wcgr5 (wcgr5), unsigned 32 bits
395+ 110: wcgr6 (wcgr6), unsigned 32 bits
396+ 111: wcgr7 (wcgr7), unsigned 32 bits
397+ 112: wr0 (wr0), unsigned 64 bits
398+ 113: wr1 (wr1), unsigned 64 bits
399+ 114: wr2 (wr2), unsigned 64 bits
400+ 115: wr3 (wr3), unsigned 64 bits
401+ 116: wr4 (wr4), unsigned 64 bits
402+ 117: wr5 (wr5), unsigned 64 bits
403+ 118: wr6 (wr6), unsigned 64 bits
404+ 119: wr7 (wr7), unsigned 64 bits
405+ 120: wr8 (wr8), unsigned 64 bits
406+ 121: wr9 (wr9), unsigned 64 bits
407+ 122: wr10 (wr10), unsigned 64 bits
408+ 123: wr11 (wr11), unsigned 64 bits
409+ 124: wr12 (wr12), unsigned 64 bits
410+ 125: wr13 (wr13), unsigned 64 bits
411+ 126: wr14 (wr14), unsigned 64 bits
412+ 127: wr15 (wr15), unsigned 64 bits
413+ 192: wc0 (wc0), unsigned 32 bits
414+ 193: wc1 (wc1), unsigned 32 bits
415+ 194: wc2 (wc2), unsigned 32 bits
416+ 195: wc3 (wc3), unsigned 32 bits
417+ 196: wc4 (wc4), unsigned 32 bits
418+ 197: wc5 (wc5), unsigned 32 bits
419+ 198: wc6 (wc6), unsigned 32 bits
420+ 199: wc7 (wc7), unsigned 32 bits
421 VFP registers:
422+ 64: s0 (s0), float 32 bits
423+ 65: s1 (s1), float 32 bits
424+ 66: s2 (s2), float 32 bits
425+ 67: s3 (s3), float 32 bits
426+ 68: s4 (s4), float 32 bits
427+ 69: s5 (s5), float 32 bits
428+ 70: s6 (s6), float 32 bits
429+ 71: s7 (s7), float 32 bits
430+ 72: s8 (s8), float 32 bits
431+ 73: s9 (s9), float 32 bits
432+ 74: s10 (s10), float 32 bits
433+ 75: s11 (s11), float 32 bits
434+ 76: s12 (s12), float 32 bits
435+ 77: s13 (s13), float 32 bits
436+ 78: s14 (s14), float 32 bits
437+ 79: s15 (s15), float 32 bits
438+ 80: s16 (s16), float 32 bits
439+ 81: s17 (s17), float 32 bits
440+ 82: s18 (s18), float 32 bits
441+ 83: s19 (s19), float 32 bits
442+ 84: s20 (s20), float 32 bits
443+ 85: s21 (s21), float 32 bits
444+ 86: s22 (s22), float 32 bits
445+ 87: s23 (s23), float 32 bits
446+ 88: s24 (s24), float 32 bits
447+ 89: s25 (s25), float 32 bits
448+ 90: s26 (s26), float 32 bits
449+ 91: s27 (s27), float 32 bits
450+ 92: s28 (s28), float 32 bits
451+ 93: s29 (s29), float 32 bits
452+ 94: s30 (s30), float 32 bits
453+ 95: s31 (s31), float 32 bits
454 256: d0 (d0), float 64 bits
455 257: d1 (d1), float 64 bits
456 258: d2 (d2), float 64 bits
457@@ -2723,6 +2809,13 @@ VFP registers:
458 285: d29 (d29), float 64 bits
459 286: d30 (d30), float 64 bits
460 287: d31 (d31), float 64 bits
461+state registers:
462+ 128: spsr (spsr), unsigned 32 bits
463+ 129: spsr_fiq (spsr_fiq), unsigned 32 bits
464+ 130: spsr_irq (spsr_irq), unsigned 32 bits
465+ 131: spsr_abt (spsr_abt), unsigned 32 bits
466+ 132: spsr_und (spsr_und), unsigned 32 bits
467+ 133: spsr_svc (spsr_svc), unsigned 32 bits
468 EOF
469
470 # See run-readelf-mixed-corenote.sh for instructions to regenerate
471Index: b/tests/run-readelf-mixed-corenote.sh
472===================================================================
473--- a/tests/run-readelf-mixed-corenote.sh
474+++ b/tests/run-readelf-mixed-corenote.sh
475@@ -31,12 +31,11 @@ Note segment of 892 bytes at offset 0x27
476 pid: 11087, ppid: 11063, pgrp: 11087, sid: 11063
477 utime: 0.000000, stime: 0.010000, cutime: 0.000000, cstime: 0.000000
478 orig_r0: -1, fpvalid: 1
479- r0: 1 r1: -1091672508 r2: -1091672500
480- r3: 0 r4: 0 r5: 0
481- r6: 33728 r7: 0 r8: 0
482- r9: 0 r10: -1225703496 r11: -1091672844
483- r12: 0 sp: 0xbeee64f4 lr: 0xb6dc3f48
484- pc: 0x00008500 spsr: 0x60000010
485+ r0: 1 r1: -1091672508 r2: -1091672500 r3: 0
486+ r4: 0 r5: 0 r6: 33728 r7: 0
487+ r8: 0 r9: 0 r10: -1225703496 r11: -1091672844
488+ r12: 0 sp: 0xbeee64f4 lr: 0xb6dc3f48 pc: 0x00008500
489+ spsr: 0x60000010
490 CORE 124 PRPSINFO
491 state: 0, sname: R, zomb: 0, nice: 0, flag: 0x00400500
492 uid: 0, gid: 0, pid: 11087, ppid: 11063, pgrp: 11087, sid: 11063
493Index: b/tests/run-addrcfi.sh
494===================================================================
495--- a/tests/run-addrcfi.sh
496+++ b/tests/run-addrcfi.sh
497@@ -3554,6 +3554,38 @@ dwarf_cfi_addrframe (.eh_frame): no matc
498 FPA reg21 (f5): undefined
499 FPA reg22 (f6): undefined
500 FPA reg23 (f7): undefined
501+ VFP reg64 (s0): undefined
502+ VFP reg65 (s1): undefined
503+ VFP reg66 (s2): undefined
504+ VFP reg67 (s3): undefined
505+ VFP reg68 (s4): undefined
506+ VFP reg69 (s5): undefined
507+ VFP reg70 (s6): undefined
508+ VFP reg71 (s7): undefined
509+ VFP reg72 (s8): undefined
510+ VFP reg73 (s9): undefined
511+ VFP reg74 (s10): undefined
512+ VFP reg75 (s11): undefined
513+ VFP reg76 (s12): undefined
514+ VFP reg77 (s13): undefined
515+ VFP reg78 (s14): undefined
516+ VFP reg79 (s15): undefined
517+ VFP reg80 (s16): undefined
518+ VFP reg81 (s17): undefined
519+ VFP reg82 (s18): undefined
520+ VFP reg83 (s19): undefined
521+ VFP reg84 (s20): undefined
522+ VFP reg85 (s21): undefined
523+ VFP reg86 (s22): undefined
524+ VFP reg87 (s23): undefined
525+ VFP reg88 (s24): undefined
526+ VFP reg89 (s25): undefined
527+ VFP reg90 (s26): undefined
528+ VFP reg91 (s27): undefined
529+ VFP reg92 (s28): undefined
530+ VFP reg93 (s29): undefined
531+ VFP reg94 (s30): undefined
532+ VFP reg95 (s31): undefined
533 FPA reg96 (f0): undefined
534 FPA reg97 (f1): undefined
535 FPA reg98 (f2): undefined
536@@ -3562,7 +3594,66 @@ dwarf_cfi_addrframe (.eh_frame): no matc
537 FPA reg101 (f5): undefined
538 FPA reg102 (f6): undefined
539 FPA reg103 (f7): undefined
540- integer reg128 (spsr): undefined
541+ MMX reg104 (wcgr0): undefined
542+ MMX reg105 (wcgr1): undefined
543+ MMX reg106 (wcgr2): undefined
544+ MMX reg107 (wcgr3): undefined
545+ MMX reg108 (wcgr4): undefined
546+ MMX reg109 (wcgr5): undefined
547+ MMX reg110 (wcgr6): undefined
548+ MMX reg111 (wcgr7): undefined
549+ MMX reg112 (wr0): undefined
550+ MMX reg113 (wr1): undefined
551+ MMX reg114 (wr2): undefined
552+ MMX reg115 (wr3): undefined
553+ MMX reg116 (wr4): undefined
554+ MMX reg117 (wr5): undefined
555+ MMX reg118 (wr6): undefined
556+ MMX reg119 (wr7): undefined
557+ MMX reg120 (wr8): undefined
558+ MMX reg121 (wr9): undefined
559+ MMX reg122 (wr10): undefined
560+ MMX reg123 (wr11): undefined
561+ MMX reg124 (wr12): undefined
562+ MMX reg125 (wr13): undefined
563+ MMX reg126 (wr14): undefined
564+ MMX reg127 (wr15): undefined
565+ state reg128 (spsr): undefined
566+ state reg129 (spsr_fiq): undefined
567+ state reg130 (spsr_irq): undefined
568+ state reg131 (spsr_abt): undefined
569+ state reg132 (spsr_und): undefined
570+ state reg133 (spsr_svc): undefined
571+ integer reg144 (r8_usr): undefined
572+ integer reg145 (r9_usr): undefined
573+ integer reg146 (r10_usr): undefined
574+ integer reg147 (r11_usr): undefined
575+ integer reg148 (r12_usr): undefined
576+ integer reg149 (r13_usr): undefined
577+ integer reg150 (r14_usr): undefined
578+ integer reg151 (r8_fiq): undefined
579+ integer reg152 (r9_fiq): undefined
580+ integer reg153 (r10_fiq): undefined
581+ integer reg154 (r11_fiq): undefined
582+ integer reg155 (r12_fiq): undefined
583+ integer reg156 (r13_fiq): undefined
584+ integer reg157 (r14_fiq): undefined
585+ integer reg158 (r13_irq): undefined
586+ integer reg159 (r14_irq): undefined
587+ integer reg160 (r13_abt): undefined
588+ integer reg161 (r14_abt): undefined
589+ integer reg162 (r13_und): undefined
590+ integer reg163 (r14_und): undefined
591+ integer reg164 (r13_svc): undefined
592+ integer reg165 (r14_svc): undefined
593+ MMX reg192 (wc0): undefined
594+ MMX reg193 (wc1): undefined
595+ MMX reg194 (wc2): undefined
596+ MMX reg195 (wc3): undefined
597+ MMX reg196 (wc4): undefined
598+ MMX reg197 (wc5): undefined
599+ MMX reg198 (wc6): undefined
600+ MMX reg199 (wc7): undefined
601 VFP reg256 (d0): undefined
602 VFP reg257 (d1): undefined
603 VFP reg258 (d2): undefined
diff --git a/meta/recipes-devtools/elfutils/files/debian/fallthrough.patch b/meta/recipes-devtools/elfutils/files/debian/fallthrough.patch
new file mode 100644
index 0000000000..b2623f9d2e
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/debian/fallthrough.patch
@@ -0,0 +1,36 @@
1GCC7 adds -Wimplicit-fallthrough to warn when a switch case falls through,
2however this causes warnings (which are promoted to errors) with the elfutils
3patches from Debian for mips and parisc, which use fallthrough's by design.
4
5Explicitly mark the intentional fallthrough switch cases with a comment to
6disable the warnings where the fallthrough behaviour is desired.
7
8Upstream-Status: Pending [debian]
9Signed-off-by: Joshua Lock <joshua.g.lock@intel.com>
10
11Index: elfutils-0.168/backends/parisc_retval.c
12===================================================================
13--- elfutils-0.168.orig/backends/parisc_retval.c
14+++ elfutils-0.168/backends/parisc_retval.c
15@@ -166,7 +166,7 @@ parisc_return_value_location_ (Dwarf_Die
16 return nloc_intregpair;
17
18 /* Else fall through. */
19- }
20+ } // fallthrough
21
22 case DW_TAG_structure_type:
23 case DW_TAG_class_type:
24Index: elfutils-0.168/backends/mips_retval.c
25===================================================================
26--- elfutils-0.168.orig/backends/mips_retval.c
27+++ elfutils-0.168/backends/mips_retval.c
28@@ -387,7 +387,7 @@ mips_return_value_location (Dwarf_Die *f
29 else
30 return nloc_intregpair;
31 }
32- }
33+ } // fallthrough
34
35 /* Fallthrough to handle large types */
36
diff --git a/meta/recipes-devtools/elfutils/files/debian/hppa_backend.diff b/meta/recipes-devtools/elfutils/files/debian/hppa_backend.diff
new file mode 100644
index 0000000000..44fda7f305
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/debian/hppa_backend.diff
@@ -0,0 +1,802 @@
1Upstream-Status: Backport [from debian]
2Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
3
4Index: b/backends/parisc_init.c
5===================================================================
6--- /dev/null
7+++ b/backends/parisc_init.c
8@@ -0,0 +1,73 @@
9+/* Initialization of PA-RISC specific backend library.
10+ Copyright (C) 2002, 2005, 2006 Red Hat, Inc.
11+ This file is part of Red Hat elfutils.
12+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
13+
14+ Red Hat elfutils is free software; you can redistribute it and/or modify
15+ it under the terms of the GNU General Public License as published by the
16+ Free Software Foundation; version 2 of the License.
17+
18+ Red Hat elfutils is distributed in the hope that it will be useful, but
19+ WITHOUT ANY WARRANTY; without even the implied warranty of
20+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21+ General Public License for more details.
22+
23+ You should have received a copy of the GNU General Public License along
24+ with Red Hat elfutils; if not, write to the Free Software Foundation,
25+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
26+
27+ Red Hat elfutils is an included package of the Open Invention Network.
28+ An included package of the Open Invention Network is a package for which
29+ Open Invention Network licensees cross-license their patents. No patent
30+ license is granted, either expressly or impliedly, by designation as an
31+ included package. Should you wish to participate in the Open Invention
32+ Network licensing program, please visit www.openinventionnetwork.com
33+ <http://www.openinventionnetwork.com>. */
34+
35+#ifdef HAVE_CONFIG_H
36+# include <config.h>
37+#endif
38+
39+#define BACKEND parisc_
40+#define RELOC_PREFIX R_PARISC_
41+#include "libebl_CPU.h"
42+#include "libebl_parisc.h"
43+
44+/* This defines the common reloc hooks based on parisc_reloc.def. */
45+#include "common-reloc.c"
46+
47+
48+const char *
49+parisc_init (Elf *elf __attribute__ ((unused)),
50+ GElf_Half machine __attribute__ ((unused)),
51+ Ebl *eh,
52+ size_t ehlen)
53+{
54+ int pa64 = 0;
55+
56+ /* Check whether the Elf_BH object has a sufficent size. */
57+ if (ehlen < sizeof (Ebl))
58+ return NULL;
59+
60+ if (elf) {
61+ GElf_Ehdr ehdr_mem;
62+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
63+ if (ehdr && (ehdr->e_flags & EF_PARISC_WIDE))
64+ pa64 = 1;
65+ }
66+ /* We handle it. */
67+ eh->name = "PA-RISC";
68+ parisc_init_reloc (eh);
69+ HOOK (eh, reloc_simple_type);
70+ HOOK (eh, machine_flag_check);
71+ HOOK (eh, symbol_type_name);
72+ HOOK (eh, segment_type_name);
73+ HOOK (eh, section_type_name);
74+ HOOK (eh, register_info);
75+ if (pa64)
76+ eh->return_value_location = parisc_return_value_location_64;
77+ else
78+ eh->return_value_location = parisc_return_value_location_32;
79+
80+ return MODVERSION;
81+}
82Index: b/backends/parisc_regs.c
83===================================================================
84--- /dev/null
85+++ b/backends/parisc_regs.c
86@@ -0,0 +1,159 @@
87+/* Register names and numbers for PA-RISC DWARF.
88+ Copyright (C) 2005, 2006 Red Hat, Inc.
89+ This file is part of Red Hat elfutils.
90+
91+ Red Hat elfutils is free software; you can redistribute it and/or modify
92+ it under the terms of the GNU General Public License as published by the
93+ Free Software Foundation; version 2 of the License.
94+
95+ Red Hat elfutils is distributed in the hope that it will be useful, but
96+ WITHOUT ANY WARRANTY; without even the implied warranty of
97+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
98+ General Public License for more details.
99+
100+ You should have received a copy of the GNU General Public License along
101+ with Red Hat elfutils; if not, write to the Free Software Foundation,
102+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
103+
104+ Red Hat elfutils is an included package of the Open Invention Network.
105+ An included package of the Open Invention Network is a package for which
106+ Open Invention Network licensees cross-license their patents. No patent
107+ license is granted, either expressly or impliedly, by designation as an
108+ included package. Should you wish to participate in the Open Invention
109+ Network licensing program, please visit www.openinventionnetwork.com
110+ <http://www.openinventionnetwork.com>. */
111+
112+#ifdef HAVE_CONFIG_H
113+# include <config.h>
114+#endif
115+
116+#include <string.h>
117+#include <dwarf.h>
118+
119+#define BACKEND parisc_
120+#include "libebl_CPU.h"
121+
122+ssize_t
123+parisc_register_info (Ebl *ebl, int regno, char *name, size_t namelen,
124+ const char **prefix, const char **setname,
125+ int *bits, int *type)
126+{
127+ int pa64 = 0;
128+
129+ if (ebl->elf) {
130+ GElf_Ehdr ehdr_mem;
131+ GElf_Ehdr *ehdr = gelf_getehdr (ebl->elf, &ehdr_mem);
132+ if (ehdr->e_flags & EF_PARISC_WIDE)
133+ pa64 = 1;
134+ }
135+
136+ int nregs = pa64 ? 127 : 128;
137+
138+ if (name == NULL)
139+ return nregs;
140+
141+ if (regno < 0 || regno >= nregs || namelen < 6)
142+ return -1;
143+
144+ *prefix = "%";
145+
146+ if (regno < 32)
147+ {
148+ *setname = "integer";
149+ *type = DW_ATE_signed;
150+ if (pa64)
151+ {
152+ *bits = 64;
153+ }
154+ else
155+ {
156+ *bits = 32;
157+ }
158+ }
159+ else if (regno == 32)
160+ {
161+ *setname = "special";
162+ if (pa64)
163+ {
164+ *bits = 6;
165+ }
166+ else
167+ {
168+ *bits = 5;
169+ }
170+ *type = DW_ATE_unsigned;
171+ }
172+ else
173+ {
174+ *setname = "FPU";
175+ *type = DW_ATE_float;
176+ if (pa64)
177+ {
178+ *bits = 64;
179+ }
180+ else
181+ {
182+ *bits = 32;
183+ }
184+ }
185+
186+ if (regno < 33) {
187+ switch (regno)
188+ {
189+ case 0 ... 9:
190+ name[0] = 'r';
191+ name[1] = regno + '0';
192+ namelen = 2;
193+ break;
194+ case 10 ... 31:
195+ name[0] = 'r';
196+ name[1] = regno / 10 + '0';
197+ name[2] = regno % 10 + '0';
198+ namelen = 3;
199+ break;
200+ case 32:
201+ *prefix = NULL;
202+ name[0] = 'S';
203+ name[1] = 'A';
204+ name[2] = 'R';
205+ namelen = 3;
206+ break;
207+ }
208+ }
209+ else {
210+ if (pa64 && ((regno - 72) % 2)) {
211+ *setname = NULL;
212+ return 0;
213+ }
214+
215+ switch (regno)
216+ {
217+ case 72 + 0 ... 72 + 11:
218+ name[0] = 'f';
219+ name[1] = 'r';
220+ name[2] = (regno + 8 - 72) / 2 + '0';
221+ namelen = 3;
222+ if ((regno + 8 - 72) % 2) {
223+ name[3] = 'R';
224+ namelen++;
225+ }
226+ break;
227+ case 72 + 12 ... 72 + 55:
228+ name[0] = 'f';
229+ name[1] = 'r';
230+ name[2] = (regno + 8 - 72) / 2 / 10 + '0';
231+ name[3] = (regno + 8 - 72) / 2 % 10 + '0';
232+ namelen = 4;
233+ if ((regno + 8 - 72) % 2) {
234+ name[4] = 'R';
235+ namelen++;
236+ }
237+ break;
238+ default:
239+ *setname = NULL;
240+ return 0;
241+ }
242+ }
243+ name[namelen++] = '\0';
244+ return namelen;
245+}
246Index: b/backends/parisc_reloc.def
247===================================================================
248--- /dev/null
249+++ b/backends/parisc_reloc.def
250@@ -0,0 +1,128 @@
251+/* List the relocation types for PA-RISC. -*- C -*-
252+ Copyright (C) 2005 Red Hat, Inc.
253+ This file is part of Red Hat elfutils.
254+
255+ Red Hat elfutils is free software; you can redistribute it and/or modify
256+ it under the terms of the GNU General Public License as published by the
257+ Free Software Foundation; version 2 of the License.
258+
259+ Red Hat elfutils is distributed in the hope that it will be useful, but
260+ WITHOUT ANY WARRANTY; without even the implied warranty of
261+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
262+ General Public License for more details.
263+
264+ You should have received a copy of the GNU General Public License along
265+ with Red Hat elfutils; if not, write to the Free Software Foundation,
266+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
267+
268+ Red Hat elfutils is an included package of the Open Invention Network.
269+ An included package of the Open Invention Network is a package for which
270+ Open Invention Network licensees cross-license their patents. No patent
271+ license is granted, either expressly or impliedly, by designation as an
272+ included package. Should you wish to participate in the Open Invention
273+ Network licensing program, please visit www.openinventionnetwork.com
274+ <http://www.openinventionnetwork.com>. */
275+
276+/* NAME, REL|EXEC|DYN */
277+
278+RELOC_TYPE (NONE, EXEC|DYN)
279+RELOC_TYPE (DIR32, REL|EXEC|DYN)
280+RELOC_TYPE (DIR21L, REL|EXEC|DYN)
281+RELOC_TYPE (DIR17R, REL)
282+RELOC_TYPE (DIR17F, REL)
283+RELOC_TYPE (DIR14R, REL|DYN)
284+RELOC_TYPE (PCREL32, REL)
285+RELOC_TYPE (PCREL21L, REL)
286+RELOC_TYPE (PCREL17R, REL)
287+RELOC_TYPE (PCREL17F, REL)
288+RELOC_TYPE (PCREL14R, REL|EXEC)
289+RELOC_TYPE (DPREL21L, REL)
290+RELOC_TYPE (DPREL14WR, REL)
291+RELOC_TYPE (DPREL14DR, REL)
292+RELOC_TYPE (DPREL14R, REL)
293+RELOC_TYPE (GPREL21L, 0)
294+RELOC_TYPE (GPREL14R, 0)
295+RELOC_TYPE (LTOFF21L, REL)
296+RELOC_TYPE (LTOFF14R, REL)
297+RELOC_TYPE (DLTIND14F, 0)
298+RELOC_TYPE (SETBASE, 0)
299+RELOC_TYPE (SECREL32, REL)
300+RELOC_TYPE (BASEREL21L, 0)
301+RELOC_TYPE (BASEREL17R, 0)
302+RELOC_TYPE (BASEREL14R, 0)
303+RELOC_TYPE (SEGBASE, 0)
304+RELOC_TYPE (SEGREL32, REL)
305+RELOC_TYPE (PLTOFF21L, 0)
306+RELOC_TYPE (PLTOFF14R, 0)
307+RELOC_TYPE (PLTOFF14F, 0)
308+RELOC_TYPE (LTOFF_FPTR32, 0)
309+RELOC_TYPE (LTOFF_FPTR21L, 0)
310+RELOC_TYPE (LTOFF_FPTR14R, 0)
311+RELOC_TYPE (FPTR64, 0)
312+RELOC_TYPE (PLABEL32, REL|DYN)
313+RELOC_TYPE (PCREL64, 0)
314+RELOC_TYPE (PCREL22C, 0)
315+RELOC_TYPE (PCREL22F, 0)
316+RELOC_TYPE (PCREL14WR, 0)
317+RELOC_TYPE (PCREL14DR, 0)
318+RELOC_TYPE (PCREL16F, 0)
319+RELOC_TYPE (PCREL16WF, 0)
320+RELOC_TYPE (PCREL16DF, 0)
321+RELOC_TYPE (DIR64, REL|DYN)
322+RELOC_TYPE (DIR14WR, REL)
323+RELOC_TYPE (DIR14DR, REL)
324+RELOC_TYPE (DIR16F, REL)
325+RELOC_TYPE (DIR16WF, REL)
326+RELOC_TYPE (DIR16DF, REL)
327+RELOC_TYPE (GPREL64, 0)
328+RELOC_TYPE (GPREL14WR, 0)
329+RELOC_TYPE (GPREL14DR, 0)
330+RELOC_TYPE (GPREL16F, 0)
331+RELOC_TYPE (GPREL16WF, 0)
332+RELOC_TYPE (GPREL16DF, 0)
333+RELOC_TYPE (LTOFF64, 0)
334+RELOC_TYPE (LTOFF14WR, 0)
335+RELOC_TYPE (LTOFF14DR, 0)
336+RELOC_TYPE (LTOFF16F, 0)
337+RELOC_TYPE (LTOFF16WF, 0)
338+RELOC_TYPE (LTOFF16DF, 0)
339+RELOC_TYPE (SECREL64, 0)
340+RELOC_TYPE (BASEREL14WR, 0)
341+RELOC_TYPE (BASEREL14DR, 0)
342+RELOC_TYPE (SEGREL64, 0)
343+RELOC_TYPE (PLTOFF14WR, 0)
344+RELOC_TYPE (PLTOFF14DR, 0)
345+RELOC_TYPE (PLTOFF16F, 0)
346+RELOC_TYPE (PLTOFF16WF, 0)
347+RELOC_TYPE (PLTOFF16DF, 0)
348+RELOC_TYPE (LTOFF_FPTR64, 0)
349+RELOC_TYPE (LTOFF_FPTR14WR, 0)
350+RELOC_TYPE (LTOFF_FPTR14DR, 0)
351+RELOC_TYPE (LTOFF_FPTR16F, 0)
352+RELOC_TYPE (LTOFF_FPTR16WF, 0)
353+RELOC_TYPE (LTOFF_FPTR16DF, 0)
354+RELOC_TYPE (COPY, EXEC)
355+RELOC_TYPE (IPLT, EXEC|DYN)
356+RELOC_TYPE (EPLT, 0)
357+RELOC_TYPE (TPREL32, DYN)
358+RELOC_TYPE (TPREL21L, 0)
359+RELOC_TYPE (TPREL14R, 0)
360+RELOC_TYPE (LTOFF_TP21L, 0)
361+RELOC_TYPE (LTOFF_TP14R, 0)
362+RELOC_TYPE (LTOFF_TP14F, 0)
363+RELOC_TYPE (TPREL64, 0)
364+RELOC_TYPE (TPREL14WR, 0)
365+RELOC_TYPE (TPREL14DR, 0)
366+RELOC_TYPE (TPREL16F, 0)
367+RELOC_TYPE (TPREL16WF, 0)
368+RELOC_TYPE (TPREL16DF, 0)
369+RELOC_TYPE (LTOFF_TP64, 0)
370+RELOC_TYPE (LTOFF_TP14WR, 0)
371+RELOC_TYPE (LTOFF_TP14DR, 0)
372+RELOC_TYPE (LTOFF_TP16F, 0)
373+RELOC_TYPE (LTOFF_TP16WF, 0)
374+RELOC_TYPE (LTOFF_TP16DF, 0)
375+RELOC_TYPE (TLS_DTPMOD32, DYN)
376+RELOC_TYPE (TLS_DTPMOD64, DYN)
377+
378+#define NO_RELATIVE_RELOC 1
379Index: b/backends/parisc_retval.c
380===================================================================
381--- /dev/null
382+++ b/backends/parisc_retval.c
383@@ -0,0 +1,213 @@
384+/* Function return value location for Linux/PA-RISC ABI.
385+ Copyright (C) 2005 Red Hat, Inc.
386+ This file is part of Red Hat elfutils.
387+
388+ Red Hat elfutils is free software; you can redistribute it and/or modify
389+ it under the terms of the GNU General Public License as published by the
390+ Free Software Foundation; version 2 of the License.
391+
392+ Red Hat elfutils is distributed in the hope that it will be useful, but
393+ WITHOUT ANY WARRANTY; without even the implied warranty of
394+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
395+ General Public License for more details.
396+
397+ You should have received a copy of the GNU General Public License along
398+ with Red Hat elfutils; if not, write to the Free Software Foundation,
399+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
400+
401+ Red Hat elfutils is an included package of the Open Invention Network.
402+ An included package of the Open Invention Network is a package for which
403+ Open Invention Network licensees cross-license their patents. No patent
404+ license is granted, either expressly or impliedly, by designation as an
405+ included package. Should you wish to participate in the Open Invention
406+ Network licensing program, please visit www.openinventionnetwork.com
407+ <http://www.openinventionnetwork.com>. */
408+
409+#ifdef HAVE_CONFIG_H
410+# include <config.h>
411+#endif
412+
413+#include <assert.h>
414+#include <dwarf.h>
415+
416+#define BACKEND parisc_
417+#include "libebl_CPU.h"
418+#include "libebl_parisc.h"
419+
420+/* %r28, or pair %r28, %r29. */
421+static const Dwarf_Op loc_intreg32[] =
422+ {
423+ { .atom = DW_OP_reg28 }, { .atom = DW_OP_piece, .number = 4 },
424+ { .atom = DW_OP_reg29 }, { .atom = DW_OP_piece, .number = 4 },
425+ };
426+
427+static const Dwarf_Op loc_intreg[] =
428+ {
429+ { .atom = DW_OP_reg28 }, { .atom = DW_OP_piece, .number = 8 },
430+ { .atom = DW_OP_reg29 }, { .atom = DW_OP_piece, .number = 8 },
431+ };
432+#define nloc_intreg 1
433+#define nloc_intregpair 4
434+
435+/* %fr4L, or pair %fr4L, %fr4R on pa-32 */
436+static const Dwarf_Op loc_fpreg32[] =
437+ {
438+ { .atom = DW_OP_regx, .number = 72 }, { .atom = DW_OP_piece, .number = 4 },
439+ { .atom = DW_OP_regx, .number = 73 }, { .atom = DW_OP_piece, .number = 4 },
440+ };
441+#define nloc_fpreg32 2
442+#define nloc_fpregpair32 4
443+
444+/* $fr4 */
445+static const Dwarf_Op loc_fpreg[] =
446+ {
447+ { .atom = DW_OP_regx, .number = 72 },
448+ };
449+#define nloc_fpreg 1
450+
451+#if 0
452+/* The return value is a structure and is actually stored in stack space
453+ passed in a hidden argument by the caller. Address of the location is stored
454+ in %r28 before function call, but it may be changed by function. */
455+static const Dwarf_Op loc_aggregate[] =
456+ {
457+ { .atom = DW_OP_breg28 },
458+ };
459+#define nloc_aggregate 1
460+#endif
461+
462+static int
463+parisc_return_value_location_ (Dwarf_Die *functypedie, const Dwarf_Op **locp, int pa64)
464+{
465+ Dwarf_Word regsize = pa64 ? 8 : 4;
466+
467+ /* Start with the function's type, and get the DW_AT_type attribute,
468+ which is the type of the return value. */
469+
470+ Dwarf_Attribute attr_mem;
471+ Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type, &attr_mem);
472+ if (attr == NULL)
473+ /* The function has no return value, like a `void' function in C. */
474+ return 0;
475+
476+ Dwarf_Die die_mem;
477+ Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
478+ int tag = dwarf_tag (typedie);
479+
480+ /* Follow typedefs and qualifiers to get to the actual type. */
481+ while (tag == DW_TAG_typedef
482+ || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
483+ || tag == DW_TAG_restrict_type)
484+ {
485+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
486+ typedie = dwarf_formref_die (attr, &die_mem);
487+ tag = dwarf_tag (typedie);
488+ }
489+
490+ switch (tag)
491+ {
492+ case -1:
493+ return -1;
494+
495+ case DW_TAG_subrange_type:
496+ if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
497+ {
498+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
499+ typedie = dwarf_formref_die (attr, &die_mem);
500+ tag = dwarf_tag (typedie);
501+ }
502+ /* Fall through. */
503+
504+ case DW_TAG_base_type:
505+ case DW_TAG_enumeration_type:
506+ case DW_TAG_pointer_type:
507+ case DW_TAG_ptr_to_member_type:
508+ {
509+ Dwarf_Word size;
510+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
511+ &attr_mem), &size) != 0)
512+ {
513+ if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
514+ size = 4;
515+ else
516+ return -1;
517+ }
518+ if (tag == DW_TAG_base_type)
519+ {
520+ Dwarf_Word encoding;
521+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
522+ &attr_mem), &encoding) != 0)
523+ return -1;
524+
525+ if (encoding == DW_ATE_float)
526+ {
527+ if (pa64) {
528+ *locp = loc_fpreg;
529+ if (size <= 8)
530+ return nloc_fpreg;
531+ }
532+ else {
533+ *locp = loc_fpreg32;
534+ if (size <= 4)
535+ return nloc_fpreg32;
536+ else if (size <= 8)
537+ return nloc_fpregpair32;
538+ }
539+ goto aggregate;
540+ }
541+ }
542+ if (pa64)
543+ *locp = loc_intreg;
544+ else
545+ *locp = loc_intreg32;
546+ if (size <= regsize)
547+ return nloc_intreg;
548+ if (size <= 2 * regsize)
549+ return nloc_intregpair;
550+
551+ /* Else fall through. */
552+ }
553+
554+ case DW_TAG_structure_type:
555+ case DW_TAG_class_type:
556+ case DW_TAG_union_type:
557+ case DW_TAG_array_type:
558+ aggregate: {
559+ Dwarf_Word size;
560+ if (dwarf_aggregate_size (typedie, &size) != 0)
561+ return -1;
562+ if (pa64)
563+ *locp = loc_intreg;
564+ else
565+ *locp = loc_intreg32;
566+ if (size <= regsize)
567+ return nloc_intreg;
568+ if (size <= 2 * regsize)
569+ return nloc_intregpair;
570+#if 0
571+ /* there should be some way to know this location... But I do not see it. */
572+ *locp = loc_aggregate;
573+ return nloc_aggregate;
574+#endif
575+ /* fall through. */
576+ }
577+ }
578+
579+ /* XXX We don't have a good way to return specific errors from ebl calls.
580+ This value means we do not understand the type, but it is well-formed
581+ DWARF and might be valid. */
582+ return -2;
583+}
584+
585+int
586+parisc_return_value_location_32 (Dwarf_Die *functypedie, const Dwarf_Op **locp)
587+{
588+ return parisc_return_value_location_ (functypedie, locp, 0);
589+}
590+
591+int
592+parisc_return_value_location_64 (Dwarf_Die *functypedie, const Dwarf_Op **locp)
593+{
594+ return parisc_return_value_location_ (functypedie, locp, 1);
595+}
596+
597Index: b/backends/parisc_symbol.c
598===================================================================
599--- /dev/null
600+++ b/backends/parisc_symbol.c
601@@ -0,0 +1,112 @@
602+/* PA-RISC specific symbolic name handling.
603+ Copyright (C) 2002, 2005 Red Hat, Inc.
604+ This file is part of Red Hat elfutils.
605+ Written by Ulrich Drepper <drepper@redhat.com>, 2002.
606+
607+ Red Hat elfutils is free software; you can redistribute it and/or modify
608+ it under the terms of the GNU General Public License as published by the
609+ Free Software Foundation; version 2 of the License.
610+
611+ Red Hat elfutils is distributed in the hope that it will be useful, but
612+ WITHOUT ANY WARRANTY; without even the implied warranty of
613+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
614+ General Public License for more details.
615+
616+ You should have received a copy of the GNU General Public License along
617+ with Red Hat elfutils; if not, write to the Free Software Foundation,
618+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
619+
620+ Red Hat elfutils is an included package of the Open Invention Network.
621+ An included package of the Open Invention Network is a package for which
622+ Open Invention Network licensees cross-license their patents. No patent
623+ license is granted, either expressly or impliedly, by designation as an
624+ included package. Should you wish to participate in the Open Invention
625+ Network licensing program, please visit www.openinventionnetwork.com
626+ <http://www.openinventionnetwork.com>. */
627+
628+#ifdef HAVE_CONFIG_H
629+# include <config.h>
630+#endif
631+
632+#include <elf.h>
633+#include <stddef.h>
634+
635+#define BACKEND parisc_
636+#include "libebl_CPU.h"
637+
638+const char *
639+parisc_segment_type_name (int segment, char *buf __attribute__ ((unused)),
640+ size_t len __attribute__ ((unused)))
641+{
642+ switch (segment)
643+ {
644+ case PT_PARISC_ARCHEXT:
645+ return "PARISC_ARCHEXT";
646+ case PT_PARISC_UNWIND:
647+ return "PARISC_UNWIND";
648+ default:
649+ break;
650+ }
651+ return NULL;
652+}
653+
654+/* Return symbolic representation of symbol type. */
655+const char *
656+parisc_symbol_type_name(int symbol, char *buf __attribute__ ((unused)),
657+ size_t len __attribute__ ((unused)))
658+{
659+ if (symbol == STT_PARISC_MILLICODE)
660+ return "PARISC_MILLI";
661+ return NULL;
662+}
663+
664+/* Return symbolic representation of section type. */
665+const char *
666+parisc_section_type_name (int type,
667+ char *buf __attribute__ ((unused)),
668+ size_t len __attribute__ ((unused)))
669+{
670+ switch (type)
671+ {
672+ case SHT_PARISC_EXT:
673+ return "PARISC_EXT";
674+ case SHT_PARISC_UNWIND:
675+ return "PARISC_UNWIND";
676+ case SHT_PARISC_DOC:
677+ return "PARISC_DOC";
678+ }
679+
680+ return NULL;
681+}
682+
683+/* Check whether machine flags are valid. */
684+bool
685+parisc_machine_flag_check (GElf_Word flags)
686+{
687+ if (flags &~ (EF_PARISC_TRAPNIL | EF_PARISC_EXT | EF_PARISC_LSB |
688+ EF_PARISC_WIDE | EF_PARISC_NO_KABP |
689+ EF_PARISC_LAZYSWAP | EF_PARISC_ARCH))
690+ return 0;
691+
692+ GElf_Word arch = flags & EF_PARISC_ARCH;
693+
694+ return ((arch == EFA_PARISC_1_0) || (arch == EFA_PARISC_1_1) ||
695+ (arch == EFA_PARISC_2_0));
696+}
697+
698+/* Check for the simple reloc types. */
699+Elf_Type
700+parisc_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
701+{
702+ switch (type)
703+ {
704+ case R_PARISC_DIR64:
705+ case R_PARISC_SECREL64:
706+ return ELF_T_XWORD;
707+ case R_PARISC_DIR32:
708+ case R_PARISC_SECREL32:
709+ return ELF_T_WORD;
710+ default:
711+ return ELF_T_NUM;
712+ }
713+}
714Index: b/backends/libebl_parisc.h
715===================================================================
716--- /dev/null
717+++ b/backends/libebl_parisc.h
718@@ -0,0 +1,9 @@
719+#ifndef _LIBEBL_HPPA_H
720+#define _LIBEBL_HPPA_H 1
721+
722+#include <libdw.h>
723+
724+extern int parisc_return_value_location_32(Dwarf_Die *, const Dwarf_Op **locp);
725+extern int parisc_return_value_location_64(Dwarf_Die *, const Dwarf_Op **locp);
726+
727+#endif
728Index: b/backends/Makefile.am
729===================================================================
730--- a/backends/Makefile.am
731+++ b/backends/Makefile.am
732@@ -33,12 +33,12 @@ AM_CPPFLAGS += -I$(top_srcdir)/libebl -I
733
734
735 modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \
736- tilegx m68k bpf
737+ tilegx m68k bpf parisc
738 libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \
739 libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \
740 libebl_aarch64_pic.a libebl_sparc_pic.a libebl_ppc_pic.a \
741 libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a \
742- libebl_m68k_pic.a libebl_bpf_pic.a
743+ libebl_m68k_pic.a libebl_bpf_pic.a libebl_parisc_pic.a
744 noinst_LIBRARIES = $(libebl_pic)
745 noinst_DATA = $(libebl_pic:_pic.a=.so)
746
747@@ -128,6 +128,9 @@ endif
748 libebl_bpf_pic_a_SOURCES = $(bpf_SRCS)
749 am_libebl_bpf_pic_a_OBJECTS = $(bpf_SRCS:.c=.os)
750
751+parisc_SRCS = parisc_init.c parisc_symbol.c parisc_regs.c parisc_retval.c
752+libebl_parisc_pic_a_SOURCES = $(parisc_SRCS)
753+am_libebl_parisc_pic_a_OBJECTS = $(parisc_SRCS:.c=.os)
754
755 libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw)
756 @rm -f $(@:.so=.map)
757Index: b/libelf/elf.h
758===================================================================
759--- a/libelf/elf.h
760+++ b/libelf/elf.h
761@@ -2055,16 +2055,24 @@ enum
762 #define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */
763 #define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */
764 #define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */
765+#define R_PARISC_DPREL14WR 19
766+#define R_PARISC_DPREL14DR 20
767 #define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */
768 #define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */
769 #define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */
770 #define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */
771 #define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */
772+#define R_PARISC_DLTIND14F 39
773+#define R_PARISC_SETBASE 40
774 #define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */
775+#define R_PARISC_BASEREL21L 42
776+#define R_PARISC_BASEREL17R 43
777+#define R_PARISC_BASEREL14R 46
778 #define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */
779 #define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */
780 #define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */
781 #define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */
782+#define R_PARISC_PLTOFF14F 55
783 #define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */
784 #define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */
785 #define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */
786@@ -2073,6 +2081,7 @@ enum
787 #define R_PARISC_PLABEL21L 66 /* Left 21 bits of fdesc address. */
788 #define R_PARISC_PLABEL14R 70 /* Right 14 bits of fdesc address. */
789 #define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */
790+#define R_PARISC_PCREL22C 73
791 #define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */
792 #define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */
793 #define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */
794@@ -2098,6 +2107,8 @@ enum
795 #define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */
796 #define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */
797 #define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */
798+#define R_PARISC_BASEREL14WR 107
799+#define R_PARISC_BASEREL14DR 108
800 #define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */
801 #define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */
802 #define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */
diff --git a/meta/recipes-devtools/elfutils/files/debian/mips_backend.patch b/meta/recipes-devtools/elfutils/files/debian/mips_backend.patch
new file mode 100644
index 0000000000..2e0e54b0c7
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/debian/mips_backend.patch
@@ -0,0 +1,715 @@
1From 46d0d0ca718093486eeeedf1b44134e9e29b56f7 Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Wed, 16 Aug 2017 09:18:59 +0800
4Subject: [PATCH] mips backends
5
6Upstream-Status: Backport [from debian]
7
8Rebase to 0.170
9Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
10---
11 backends/Makefile.am | 8 +-
12 backends/mips_init.c | 59 +++++++++
13 backends/mips_regs.c | 104 ++++++++++++++++
14 backends/mips_reloc.def | 79 ++++++++++++
15 backends/mips_retval.c | 321 ++++++++++++++++++++++++++++++++++++++++++++++++
16 backends/mips_symbol.c | 52 ++++++++
17 libebl/eblopenbackend.c | 2 +
18 7 files changed, 623 insertions(+), 2 deletions(-)
19 create mode 100644 backends/mips_init.c
20 create mode 100644 backends/mips_regs.c
21 create mode 100644 backends/mips_reloc.def
22 create mode 100644 backends/mips_retval.c
23 create mode 100644 backends/mips_symbol.c
24
25diff --git a/backends/Makefile.am b/backends/Makefile.am
26index 7f1f5d4..91baf6e 100644
27--- a/backends/Makefile.am
28+++ b/backends/Makefile.am
29@@ -33,12 +33,12 @@ AM_CPPFLAGS += -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \
30
31
32 modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \
33- tilegx m68k bpf parisc
34+ tilegx m68k bpf parisc mips
35 libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \
36 libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \
37 libebl_aarch64_pic.a libebl_sparc_pic.a libebl_ppc_pic.a \
38 libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a \
39- libebl_m68k_pic.a libebl_bpf_pic.a libebl_parisc_pic.a
40+ libebl_m68k_pic.a libebl_bpf_pic.a libebl_parisc_pic.a libebl_mips_pic.a
41 noinst_LIBRARIES = $(libebl_pic)
42 noinst_DATA = $(libebl_pic:_pic.a=.so)
43
44@@ -128,6 +128,10 @@ parisc_SRCS = parisc_init.c parisc_symbol.c parisc_regs.c parisc_retval.c
45 libebl_parisc_pic_a_SOURCES = $(parisc_SRCS)
46 am_libebl_parisc_pic_a_OBJECTS = $(parisc_SRCS:.c=.os)
47
48+mips_SRCS = mips_init.c mips_symbol.c mips_regs.c mips_retval.c
49+libebl_mips_pic_a_SOURCES = $(mips_SRCS)
50+am_libebl_mips_pic_a_OBJECTS = $(mips_SRCS:.c=.os)
51+
52 libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw) $(libeu)
53 @rm -f $(@:.so=.map)
54 $(AM_V_at)echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: *; };' \
55diff --git a/backends/mips_init.c b/backends/mips_init.c
56new file mode 100644
57index 0000000..975c04e
58--- /dev/null
59+++ b/backends/mips_init.c
60@@ -0,0 +1,59 @@
61+/* Initialization of mips specific backend library.
62+ Copyright (C) 2006 Red Hat, Inc.
63+ This file is part of Red Hat elfutils.
64+
65+ Red Hat elfutils is free software; you can redistribute it and/or modify
66+ it under the terms of the GNU General Public License as published by the
67+ Free Software Foundation; version 2 of the License.
68+
69+ Red Hat elfutils is distributed in the hope that it will be useful, but
70+ WITHOUT ANY WARRANTY; without even the implied warranty of
71+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
72+ General Public License for more details.
73+
74+ You should have received a copy of the GNU General Public License along
75+ with Red Hat elfutils; if not, write to the Free Software Foundation,
76+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
77+
78+ Red Hat elfutils is an included package of the Open Invention Network.
79+ An included package of the Open Invention Network is a package for which
80+ Open Invention Network licensees cross-license their patents. No patent
81+ license is granted, either expressly or impliedly, by designation as an
82+ included package. Should you wish to participate in the Open Invention
83+ Network licensing program, please visit www.openinventionnetwork.com
84+ <http://www.openinventionnetwork.com>. */
85+
86+#ifdef HAVE_CONFIG_H
87+# include <config.h>
88+#endif
89+
90+#define BACKEND mips_
91+#define RELOC_PREFIX R_MIPS_
92+#include "libebl_CPU.h"
93+
94+/* This defines the common reloc hooks based on mips_reloc.def. */
95+#include "common-reloc.c"
96+
97+const char *
98+mips_init (Elf *elf __attribute__ ((unused)),
99+ GElf_Half machine __attribute__ ((unused)),
100+ Ebl *eh,
101+ size_t ehlen)
102+{
103+ /* Check whether the Elf_BH object has a sufficent size. */
104+ if (ehlen < sizeof (Ebl))
105+ return NULL;
106+
107+ /* We handle it. */
108+ if (machine == EM_MIPS)
109+ eh->name = "MIPS R3000 big-endian";
110+ else if (machine == EM_MIPS_RS3_LE)
111+ eh->name = "MIPS R3000 little-endian";
112+
113+ mips_init_reloc (eh);
114+ HOOK (eh, reloc_simple_type);
115+ HOOK (eh, return_value_location);
116+ HOOK (eh, register_info);
117+
118+ return MODVERSION;
119+}
120diff --git a/backends/mips_regs.c b/backends/mips_regs.c
121new file mode 100644
122index 0000000..44f86cb
123--- /dev/null
124+++ b/backends/mips_regs.c
125@@ -0,0 +1,104 @@
126+/* Register names and numbers for MIPS DWARF.
127+ Copyright (C) 2006 Red Hat, Inc.
128+ This file is part of Red Hat elfutils.
129+
130+ Red Hat elfutils is free software; you can redistribute it and/or modify
131+ it under the terms of the GNU General Public License as published by the
132+ Free Software Foundation; version 2 of the License.
133+
134+ Red Hat elfutils is distributed in the hope that it will be useful, but
135+ WITHOUT ANY WARRANTY; without even the implied warranty of
136+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
137+ General Public License for more details.
138+
139+ You should have received a copy of the GNU General Public License along
140+ with Red Hat elfutils; if not, write to the Free Software Foundation,
141+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
142+
143+ Red Hat elfutils is an included package of the Open Invention Network.
144+ An included package of the Open Invention Network is a package for which
145+ Open Invention Network licensees cross-license their patents. No patent
146+ license is granted, either expressly or impliedly, by designation as an
147+ included package. Should you wish to participate in the Open Invention
148+ Network licensing program, please visit www.openinventionnetwork.com
149+ <http://www.openinventionnetwork.com>. */
150+
151+#ifdef HAVE_CONFIG_H
152+# include <config.h>
153+#endif
154+
155+#include <string.h>
156+#include <dwarf.h>
157+
158+#define BACKEND mips_
159+#include "libebl_CPU.h"
160+
161+ssize_t
162+mips_register_info (Ebl *ebl __attribute__((unused)),
163+ int regno, char *name, size_t namelen,
164+ const char **prefix, const char **setname,
165+ int *bits, int *type)
166+{
167+ if (name == NULL)
168+ return 66;
169+
170+ if (regno < 0 || regno > 65 || namelen < 4)
171+ return -1;
172+
173+ *prefix = "$";
174+
175+ if (regno < 32)
176+ {
177+ *setname = "integer";
178+ *type = DW_ATE_signed;
179+ *bits = 32;
180+ if (regno < 32 + 10)
181+ {
182+ name[0] = regno + '0';
183+ namelen = 1;
184+ }
185+ else
186+ {
187+ name[0] = (regno / 10) + '0';
188+ name[1] = (regno % 10) + '0';
189+ namelen = 2;
190+ }
191+ }
192+ else if (regno < 64)
193+ {
194+ *setname = "FPU";
195+ *type = DW_ATE_float;
196+ *bits = 32;
197+ name[0] = 'f';
198+ if (regno < 32 + 10)
199+ {
200+ name[1] = (regno - 32) + '0';
201+ namelen = 2;
202+ }
203+ else
204+ {
205+ name[1] = (regno - 32) / 10 + '0';
206+ name[2] = (regno - 32) % 10 + '0';
207+ namelen = 3;
208+ }
209+ }
210+ else if (regno == 64)
211+ {
212+ *type = DW_ATE_signed;
213+ *bits = 32;
214+ name[0] = 'h';
215+ name[1] = 'i';
216+ namelen = 2;
217+ }
218+ else
219+ {
220+ *type = DW_ATE_signed;
221+ *bits = 32;
222+ name[0] = 'l';
223+ name[1] = 'o';
224+ namelen = 2;
225+ }
226+
227+ name[namelen++] = '\0';
228+ return namelen;
229+}
230diff --git a/backends/mips_reloc.def b/backends/mips_reloc.def
231new file mode 100644
232index 0000000..4579970
233--- /dev/null
234+++ b/backends/mips_reloc.def
235@@ -0,0 +1,79 @@
236+/* List the relocation types for mips. -*- C -*-
237+ Copyright (C) 2006 Red Hat, Inc.
238+ This file is part of Red Hat elfutils.
239+
240+ Red Hat elfutils is free software; you can redistribute it and/or modify
241+ it under the terms of the GNU General Public License as published by the
242+ Free Software Foundation; version 2 of the License.
243+
244+ Red Hat elfutils is distributed in the hope that it will be useful, but
245+ WITHOUT ANY WARRANTY; without even the implied warranty of
246+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
247+ General Public License for more details.
248+
249+ You should have received a copy of the GNU General Public License along
250+ with Red Hat elfutils; if not, write to the Free Software Foundation,
251+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
252+
253+ Red Hat elfutils is an included package of the Open Invention Network.
254+ An included package of the Open Invention Network is a package for which
255+ Open Invention Network licensees cross-license their patents. No patent
256+ license is granted, either expressly or impliedly, by designation as an
257+ included package. Should you wish to participate in the Open Invention
258+ Network licensing program, please visit www.openinventionnetwork.com
259+ <http://www.openinventionnetwork.com>. */
260+
261+/* NAME, REL|EXEC|DYN */
262+
263+RELOC_TYPE (NONE, 0)
264+RELOC_TYPE (16, 0)
265+RELOC_TYPE (32, 0)
266+RELOC_TYPE (REL32, 0)
267+RELOC_TYPE (26, 0)
268+RELOC_TYPE (HI16, 0)
269+RELOC_TYPE (LO16, 0)
270+RELOC_TYPE (GPREL16, 0)
271+RELOC_TYPE (LITERAL, 0)
272+RELOC_TYPE (GOT16, 0)
273+RELOC_TYPE (PC16, 0)
274+RELOC_TYPE (CALL16, 0)
275+RELOC_TYPE (GPREL32, 0)
276+
277+RELOC_TYPE (SHIFT5, 0)
278+RELOC_TYPE (SHIFT6, 0)
279+RELOC_TYPE (64, 0)
280+RELOC_TYPE (GOT_DISP, 0)
281+RELOC_TYPE (GOT_PAGE, 0)
282+RELOC_TYPE (GOT_OFST, 0)
283+RELOC_TYPE (GOT_HI16, 0)
284+RELOC_TYPE (GOT_LO16, 0)
285+RELOC_TYPE (SUB, 0)
286+RELOC_TYPE (INSERT_A, 0)
287+RELOC_TYPE (INSERT_B, 0)
288+RELOC_TYPE (DELETE, 0)
289+RELOC_TYPE (HIGHER, 0)
290+RELOC_TYPE (HIGHEST, 0)
291+RELOC_TYPE (CALL_HI16, 0)
292+RELOC_TYPE (CALL_LO16, 0)
293+RELOC_TYPE (SCN_DISP, 0)
294+RELOC_TYPE (REL16, 0)
295+RELOC_TYPE (ADD_IMMEDIATE, 0)
296+RELOC_TYPE (PJUMP, 0)
297+RELOC_TYPE (RELGOT, 0)
298+RELOC_TYPE (JALR, 0)
299+RELOC_TYPE (TLS_DTPMOD32, 0)
300+RELOC_TYPE (TLS_DTPREL32, 0)
301+RELOC_TYPE (TLS_DTPMOD64, 0)
302+RELOC_TYPE (TLS_DTPREL64, 0)
303+RELOC_TYPE (TLS_GD, 0)
304+RELOC_TYPE (TLS_LDM, 0)
305+RELOC_TYPE (TLS_DTPREL_HI16, 0)
306+RELOC_TYPE (TLS_DTPREL_LO16, 0)
307+RELOC_TYPE (TLS_GOTTPREL, 0)
308+RELOC_TYPE (TLS_TPREL32, 0)
309+RELOC_TYPE (TLS_TPREL64, 0)
310+RELOC_TYPE (TLS_TPREL_HI16, 0)
311+RELOC_TYPE (TLS_TPREL_LO16, 0)
312+
313+#define NO_COPY_RELOC 1
314+#define NO_RELATIVE_RELOC 1
315diff --git a/backends/mips_retval.c b/backends/mips_retval.c
316new file mode 100644
317index 0000000..656cd1f
318--- /dev/null
319+++ b/backends/mips_retval.c
320@@ -0,0 +1,321 @@
321+/* Function return value location for Linux/mips ABI.
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+#ifdef HAVE_CONFIG_H
347+# include <config.h>
348+#endif
349+
350+#include <string.h>
351+#include <assert.h>
352+#include <dwarf.h>
353+#include <elf.h>
354+
355+#include "../libebl/libeblP.h"
356+#include "../libdw/libdwP.h"
357+
358+#define BACKEND mips_
359+#include "libebl_CPU.h"
360+
361+/* The ABI of the file. Also see EF_MIPS_ABI2 above. */
362+#define EF_MIPS_ABI 0x0000F000
363+
364+/* The original o32 abi. */
365+#define E_MIPS_ABI_O32 0x00001000
366+
367+/* O32 extended to work on 64 bit architectures */
368+#define E_MIPS_ABI_O64 0x00002000
369+
370+/* EABI in 32 bit mode */
371+#define E_MIPS_ABI_EABI32 0x00003000
372+
373+/* EABI in 64 bit mode */
374+#define E_MIPS_ABI_EABI64 0x00004000
375+
376+/* All the possible MIPS ABIs. */
377+enum mips_abi
378+ {
379+ MIPS_ABI_UNKNOWN = 0,
380+ MIPS_ABI_N32,
381+ MIPS_ABI_O32,
382+ MIPS_ABI_N64,
383+ MIPS_ABI_O64,
384+ MIPS_ABI_EABI32,
385+ MIPS_ABI_EABI64,
386+ MIPS_ABI_LAST
387+ };
388+
389+/* Find the mips ABI of the current file */
390+enum mips_abi find_mips_abi(Elf *elf)
391+{
392+ GElf_Ehdr ehdr_mem;
393+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
394+
395+ if (ehdr == NULL)
396+ return MIPS_ABI_LAST;
397+
398+ GElf_Word elf_flags = ehdr->e_flags;
399+
400+ /* Check elf_flags to see if it specifies the ABI being used. */
401+ switch ((elf_flags & EF_MIPS_ABI))
402+ {
403+ case E_MIPS_ABI_O32:
404+ return MIPS_ABI_O32;
405+ case E_MIPS_ABI_O64:
406+ return MIPS_ABI_O64;
407+ case E_MIPS_ABI_EABI32:
408+ return MIPS_ABI_EABI32;
409+ case E_MIPS_ABI_EABI64:
410+ return MIPS_ABI_EABI64;
411+ default:
412+ if ((elf_flags & EF_MIPS_ABI2))
413+ return MIPS_ABI_N32;
414+ }
415+
416+ /* GCC creates a pseudo-section whose name describes the ABI. */
417+ size_t shstrndx;
418+ if (elf_getshdrstrndx (elf, &shstrndx) < 0)
419+ return MIPS_ABI_LAST;
420+
421+ const char *name;
422+ Elf_Scn *scn = NULL;
423+ while ((scn = elf_nextscn (elf, scn)) != NULL)
424+ {
425+ GElf_Shdr shdr_mem;
426+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
427+ if (shdr == NULL)
428+ return MIPS_ABI_LAST;
429+
430+ name = elf_strptr (elf, shstrndx, shdr->sh_name) ?: "";
431+ if (strncmp (name, ".mdebug.", 8) != 0)
432+ continue;
433+
434+ if (strcmp (name, ".mdebug.abi32") == 0)
435+ return MIPS_ABI_O32;
436+ else if (strcmp (name, ".mdebug.abiN32") == 0)
437+ return MIPS_ABI_N32;
438+ else if (strcmp (name, ".mdebug.abi64") == 0)
439+ return MIPS_ABI_N64;
440+ else if (strcmp (name, ".mdebug.abiO64") == 0)
441+ return MIPS_ABI_O64;
442+ else if (strcmp (name, ".mdebug.eabi32") == 0)
443+ return MIPS_ABI_EABI32;
444+ else if (strcmp (name, ".mdebug.eabi64") == 0)
445+ return MIPS_ABI_EABI64;
446+ else
447+ return MIPS_ABI_UNKNOWN;
448+ }
449+
450+ return MIPS_ABI_UNKNOWN;
451+}
452+
453+unsigned int
454+mips_abi_regsize (enum mips_abi abi)
455+{
456+ switch (abi)
457+ {
458+ case MIPS_ABI_EABI32:
459+ case MIPS_ABI_O32:
460+ return 4;
461+ case MIPS_ABI_N32:
462+ case MIPS_ABI_N64:
463+ case MIPS_ABI_O64:
464+ case MIPS_ABI_EABI64:
465+ return 8;
466+ case MIPS_ABI_UNKNOWN:
467+ case MIPS_ABI_LAST:
468+ default:
469+ return 0;
470+ }
471+}
472+
473+
474+/* $v0 or pair $v0, $v1 */
475+static const Dwarf_Op loc_intreg_o32[] =
476+ {
477+ { .atom = DW_OP_reg2 }, { .atom = DW_OP_piece, .number = 4 },
478+ { .atom = DW_OP_reg3 }, { .atom = DW_OP_piece, .number = 4 },
479+ };
480+
481+static const Dwarf_Op loc_intreg[] =
482+ {
483+ { .atom = DW_OP_reg2 }, { .atom = DW_OP_piece, .number = 8 },
484+ { .atom = DW_OP_reg3 }, { .atom = DW_OP_piece, .number = 8 },
485+ };
486+#define nloc_intreg 1
487+#define nloc_intregpair 4
488+
489+/* $f0 (float), or pair $f0, $f1 (double).
490+ * f2/f3 are used for COMPLEX (= 2 doubles) returns in Fortran */
491+static const Dwarf_Op loc_fpreg_o32[] =
492+ {
493+ { .atom = DW_OP_regx, .number = 32 }, { .atom = DW_OP_piece, .number = 4 },
494+ { .atom = DW_OP_regx, .number = 33 }, { .atom = DW_OP_piece, .number = 4 },
495+ { .atom = DW_OP_regx, .number = 34 }, { .atom = DW_OP_piece, .number = 4 },
496+ { .atom = DW_OP_regx, .number = 35 }, { .atom = DW_OP_piece, .number = 4 },
497+ };
498+
499+/* $f0, or pair $f0, $f2. */
500+static const Dwarf_Op loc_fpreg[] =
501+ {
502+ { .atom = DW_OP_regx, .number = 32 }, { .atom = DW_OP_piece, .number = 8 },
503+ { .atom = DW_OP_regx, .number = 34 }, { .atom = DW_OP_piece, .number = 8 },
504+ };
505+#define nloc_fpreg 1
506+#define nloc_fpregpair 4
507+#define nloc_fpregquad 8
508+
509+/* The return value is a structure and is actually stored in stack space
510+ passed in a hidden argument by the caller. But, the compiler
511+ helpfully returns the address of that space in $v0. */
512+static const Dwarf_Op loc_aggregate[] =
513+ {
514+ { .atom = DW_OP_breg2, .number = 0 }
515+ };
516+#define nloc_aggregate 1
517+
518+int
519+mips_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
520+{
521+ /* First find the ABI used by the elf object */
522+ enum mips_abi abi = find_mips_abi(functypedie->cu->dbg->elf);
523+
524+ /* Something went seriously wrong while trying to figure out the ABI */
525+ if (abi == MIPS_ABI_LAST)
526+ return -1;
527+
528+ /* We couldn't identify the ABI, but the file seems valid */
529+ if (abi == MIPS_ABI_UNKNOWN)
530+ return -2;
531+
532+ /* Can't handle EABI variants */
533+ if ((abi == MIPS_ABI_EABI32) || (abi == MIPS_ABI_EABI64))
534+ return -2;
535+
536+ unsigned int regsize = mips_abi_regsize (abi);
537+ if (!regsize)
538+ return -2;
539+
540+ /* Start with the function's type, and get the DW_AT_type attribute,
541+ which is the type of the return value. */
542+
543+ Dwarf_Attribute attr_mem;
544+ Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type, &attr_mem);
545+ if (attr == NULL)
546+ /* The function has no return value, like a `void' function in C. */
547+ return 0;
548+
549+ Dwarf_Die die_mem;
550+ Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
551+ int tag = dwarf_tag (typedie);
552+
553+ /* Follow typedefs and qualifiers to get to the actual type. */
554+ while (tag == DW_TAG_typedef
555+ || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
556+ || tag == DW_TAG_restrict_type)
557+ {
558+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
559+ typedie = dwarf_formref_die (attr, &die_mem);
560+ tag = dwarf_tag (typedie);
561+ }
562+
563+ switch (tag)
564+ {
565+ case -1:
566+ return -1;
567+
568+ case DW_TAG_subrange_type:
569+ if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
570+ {
571+ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
572+ typedie = dwarf_formref_die (attr, &die_mem);
573+ tag = dwarf_tag (typedie);
574+ }
575+ /* Fall through. */
576+
577+ case DW_TAG_base_type:
578+ case DW_TAG_enumeration_type:
579+ case DW_TAG_pointer_type:
580+ case DW_TAG_ptr_to_member_type:
581+ {
582+ Dwarf_Word size;
583+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
584+ &attr_mem), &size) != 0)
585+ {
586+ if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
587+ size = regsize;
588+ else
589+ return -1;
590+ }
591+ if (tag == DW_TAG_base_type)
592+ {
593+ Dwarf_Word encoding;
594+ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding,
595+ &attr_mem), &encoding) != 0)
596+ return -1;
597+
598+#define ABI_LOC(loc, regsize) ((regsize) == 4 ? (loc ## _o32) : (loc))
599+
600+ if (encoding == DW_ATE_float)
601+ {
602+ *locp = ABI_LOC(loc_fpreg, regsize);
603+ if (size <= regsize)
604+ return nloc_fpreg;
605+
606+ if (size <= 2*regsize)
607+ return nloc_fpregpair;
608+
609+ if (size <= 4*regsize && abi == MIPS_ABI_O32)
610+ return nloc_fpregquad;
611+
612+ goto aggregate;
613+ }
614+ }
615+ *locp = ABI_LOC(loc_intreg, regsize);
616+ if (size <= regsize)
617+ return nloc_intreg;
618+ if (size <= 2*regsize)
619+ return nloc_intregpair;
620+
621+ /* Else fall through. Shouldn't happen though (at least with gcc) */
622+ }
623+
624+ case DW_TAG_structure_type:
625+ case DW_TAG_class_type:
626+ case DW_TAG_union_type:
627+ case DW_TAG_array_type:
628+ aggregate:
629+ /* XXX TODO: Can't handle structure return with other ABI's yet :-/ */
630+ if ((abi != MIPS_ABI_O32) && (abi != MIPS_ABI_O64))
631+ return -2;
632+
633+ *locp = loc_aggregate;
634+ return nloc_aggregate;
635+ }
636+
637+ /* XXX We don't have a good way to return specific errors from ebl calls.
638+ This value means we do not understand the type, but it is well-formed
639+ DWARF and might be valid. */
640+ return -2;
641+}
642diff --git a/backends/mips_symbol.c b/backends/mips_symbol.c
643new file mode 100644
644index 0000000..ba465fe
645--- /dev/null
646+++ b/backends/mips_symbol.c
647@@ -0,0 +1,52 @@
648+/* MIPS specific symbolic name handling.
649+ Copyright (C) 2002, 2003, 2005 Red Hat, Inc.
650+ This file is part of Red Hat elfutils.
651+ Written by Jakub Jelinek <jakub@redhat.com>, 2002.
652+
653+ Red Hat elfutils is free software; you can redistribute it and/or modify
654+ it under the terms of the GNU General Public License as published by the
655+ Free Software Foundation; version 2 of the License.
656+
657+ Red Hat elfutils is distributed in the hope that it will be useful, but
658+ WITHOUT ANY WARRANTY; without even the implied warranty of
659+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
660+ General Public License for more details.
661+
662+ You should have received a copy of the GNU General Public License along
663+ with Red Hat elfutils; if not, write to the Free Software Foundation,
664+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
665+
666+ Red Hat elfutils is an included package of the Open Invention Network.
667+ An included package of the Open Invention Network is a package for which
668+ Open Invention Network licensees cross-license their patents. No patent
669+ license is granted, either expressly or impliedly, by designation as an
670+ included package. Should you wish to participate in the Open Invention
671+ Network licensing program, please visit www.openinventionnetwork.com
672+ <http://www.openinventionnetwork.com>. */
673+
674+#ifdef HAVE_CONFIG_H
675+# include <config.h>
676+#endif
677+
678+#include <elf.h>
679+#include <stddef.h>
680+
681+#define BACKEND mips_
682+#include "libebl_CPU.h"
683+
684+/* Check for the simple reloc types. */
685+Elf_Type
686+mips_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
687+{
688+ switch (type)
689+ {
690+ case R_MIPS_16:
691+ return ELF_T_HALF;
692+ case R_MIPS_32:
693+ return ELF_T_WORD;
694+ case R_MIPS_64:
695+ return ELF_T_XWORD;
696+ default:
697+ return ELF_T_NUM;
698+ }
699+}
700diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
701index 1f81477..5371396 100644
702--- a/libebl/eblopenbackend.c
703+++ b/libebl/eblopenbackend.c
704@@ -72,6 +72,8 @@ static const struct
705 { "sparc", "elf_sparc", "sparc", 5, EM_SPARC, 0, 0 },
706 { "sparc", "elf_sparcv8plus", "sparc", 5, EM_SPARC32PLUS, 0, 0 },
707 { "s390", "ebl_s390", "s390", 4, EM_S390, 0, 0 },
708+ { "mips", "elf_mips", "mips", 4, EM_MIPS, 0, 0 },
709+ { "mips", "elf_mipsel", "mipsel", 4, EM_MIPS_RS3_LE, 0, 0 },
710
711 { "m32", "elf_m32", "m32", 3, EM_M32, 0, 0 },
712 { "m68k", "elf_m68k", "m68k", 4, EM_68K, ELFCLASS32, ELFDATA2MSB },
713--
7141.8.3.1
715
diff --git a/meta/recipes-devtools/elfutils/files/debian/mips_readelf_w.patch b/meta/recipes-devtools/elfutils/files/debian/mips_readelf_w.patch
new file mode 100644
index 0000000000..790930cf35
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/debian/mips_readelf_w.patch
@@ -0,0 +1,25 @@
1From: Kurt Roeckx <kurt@roeckx.be>
2Subject: Make readelf -w output debug information on mips
3Bug-Debian: http://bugs.debian.org/662041
4Forwarded: not-needed
5
6Upstreams wants a change where this is handled by a hook that needs
7to be filled in by the backend for the arch.
8
9Upstream-Status: Backport [from debian]
10Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
11
12Index: b/src/readelf.c
13===================================================================
14--- a/src/readelf.c
15+++ b/src/readelf.c
16@@ -8343,7 +8343,8 @@ print_debug (Dwfl_Module *dwflmod, Ebl *
17 GElf_Shdr shdr_mem;
18 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
19
20- if (shdr != NULL && shdr->sh_type == SHT_PROGBITS)
21+ if (shdr != NULL && (
22+ (shdr->sh_type == SHT_PROGBITS) || (shdr->sh_type == SHT_MIPS_DWARF)))
23 {
24 static const struct
25 {