comparison core/elfutils/musl.patch @ 113:2d954d043296

core/elfutils: initial import, closes #1142
author David Demelier <markand@malikania.fr>
date Sat, 09 Mar 2019 17:03:57 +0100
parents
children 5f0dfff1e37a
comparison
equal deleted inserted replaced
112:08181daf32da 113:2d954d043296
1 It looks like fregs.vregs[] is an array of double?
2 Casting to Dwarf_Word instead of & 0xFFFFFFF should do.
3
4 --- backends/aarch64_initreg.c 2015-11-27 14:36:29.000000000 +0100
5 +++ backends/aarch64_initreg.c 2016-08-09 03:47:25.428560159 +0200
6 @@ -82,7 +83,7 @@
7
8 Dwarf_Word dwarf_fregs[32];
9 for (int r = 0; r < 32; r++)
10 - dwarf_fregs[r] = fregs.vregs[r] & 0xFFFFFFFF;
11 + dwarf_fregs[r] = (Dwarf_Word)fregs.vregs[r];
12
13 if (! setfunc (64, 32, dwarf_fregs, arg))
14 return false;
15
16 --- libcpu/i386_disasm.c 2015-08-21 14:22:37.000000000 +0200
17 +++ libcpu/i386_disasm.c 2015-11-20 06:30:59.250629957 +0100
18 @@ -1,4 +1,4 @@
19 -/* Disassembler for x86.
20 +/* Disassembler for x86.
21 Copyright (C) 2007, 2008, 2009, 2011 Red Hat, Inc.
22 This file is part of elfutils.
23 Written by Ulrich Drepper <drepper@redhat.com>, 2007.
24 @@ -710,6 +710,7 @@
25
26 case 'm':
27 /* Mnemonic. */
28 + str = mnebuf;
29
30 if (unlikely (instrtab[cnt].mnemonic == MNE_INVALID))
31 {
32 --- libelf/elf.h 2015-08-21 14:22:37.000000000 +0200
33 +++ libelf/elf.h 2015-11-20 04:54:33.948081321 +0100
34 @@ -21,6 +21,17 @@
35
36 #include <features.h>
37
38 +#if !defined(__GLIBC__)
39 +/* C++ needs to know that types and declarations are C, not C++. */
40 +#ifdef __cplusplus
41 +# define __BEGIN_DECLS extern "C" {
42 +# define __END_DECLS }
43 +#else
44 +# define __BEGIN_DECLS
45 +# define __END_DECLS
46 +#endif
47 +#endif
48 +
49 __BEGIN_DECLS
50
51 /* Standard ELF types. */
52 --- lib/fixedsizehash.h.orig
53 +++ lib/fixedsizehash.h
54 @@ -30,7 +30,6 @@
55 #include <errno.h>
56 #include <stdlib.h>
57 #include <string.h>
58 -#include <sys/cdefs.h>
59
60 #include <system.h>
61
62 --- configure.ac 2015-10-15 15:16:57.000000000 +0200
63 +++ configure.ac 2015-11-20 05:32:57.723901582 +0100
64 @@ -305,6 +305,62 @@
65 fi
66 AC_SUBST([argp_LDADD])
67
68 +dnl Check if we have fts available from our libc
69 +AC_LINK_IFELSE(
70 + [AC_LANG_PROGRAM(
71 + [#if !defined(__x86_64__)
72 + #undef _FILE_OFFSET_BITS
73 + #define _FILE_OFFSET_BITS 32
74 + #endif
75 + #include <fts.h>],
76 + [FTS* fts = 0; return fts_close(fts); return 0;]
77 + )],
78 + [libc_has_fts="true"],
79 + [libc_has_fts="false"]
80 +)
81 +
82 +dnl If our libc doesn't provide fts, then test for libfts
83 +if test "$libc_has_fts" = "false" ; then
84 + AC_MSG_WARN("libc does not have fts")
85 + AC_CHECK_LIB([fts], [fts_close], [have_fts="true"], [have_fts="false"])
86 +
87 + if test "$have_fts" = "false"; then
88 + AC_MSG_ERROR("no libfts found")
89 + else
90 + fts_LDADD="-lfts"
91 + fi
92 +else
93 + fts_LDADD=""
94 +fi
95 +AC_SUBST([fts_LDADD])
96 +
97 +dnl Check if we have obstack available from our libc
98 +AC_LINK_IFELSE(
99 + [AC_LANG_PROGRAM(
100 + [#include <obstack.h>],
101 + [_obstack_begin(0, 0, 0, NULL, NULL); return 0;]
102 + )],
103 + [libc_has_obstack="true"],
104 + [libc_has_obstack="false"]
105 +)
106 +
107 +dnl If our libc doesn't provide obstack, then test for libobstack
108 +if test "$libc_has_obstack" = "false" ; then
109 + AC_MSG_WARN("libc does not have obstack")
110 + AC_CHECK_LIB([obstack], [_obstack_begin], [have_obstack="true"], [have_obstack="false"])
111 +
112 + if test "$have_obstack" = "false"; then
113 + AC_MSG_ERROR("no libobstack found")
114 + else
115 + obstack_LDADD="-lobstack"
116 + fi
117 +else
118 + obstack_LDADD=""
119 +fi
120 +AC_SUBST([obstack_LDADD])
121 +
122 +dnl The directories with content.
123 +
124 dnl The directories with content.
125
126 dnl Documentation.
127 --- src/Makefile.am.orig 2016-08-29 21:38:11.179295769 +0200
128 +++ src/Makefile.am 2016-08-03 18:19:47.000000000 +0200
129 @@ -67,22 +67,22 @@
130 ar_no_Wstack_usage = yes
131 unstrip_no_Wstack_usage = yes
132
133 +readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) -ldl
134 +nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) -ldl \
135 -readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
136 -nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl \
137 $(demanglelib)
138 +size_LDADD = $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD)
139 +strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) -ldl
140 +elflint_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) -ldl
141 +findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD)
142 +addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) $(demanglelib)
143 +elfcmp_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) -ldl
144 -size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
145 -strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl
146 -elflint_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
147 -findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
148 -addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
149 -elfcmp_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
150 objdump_LDADD = $(libasm) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
151 +ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD)
152 +strings_LDADD = $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD)
153 +ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD)
154 +unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) -ldl
155 +stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) -ldl $(demanglelib)
156 +elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD)
157 -ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
158 -strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
159 -ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
160 -unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl
161 -stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl $(demanglelib)
162 -elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
163
164 installcheck-binPROGRAMS: $(bin_PROGRAMS)
165 bad=0; pid=$$$$; list="$(bin_PROGRAMS)"; for p in $$list; do \
166 --- libdw/Makefile.am.orig 2017-08-05 01:41:04.103553705 +0000
167 +++ libdw/Makefile.am 2017-08-05 01:43:55.366543497 +0000
168 @@ -105,7 +105,7 @@
169 libdw_so_LIBS = libdw_pic.a ../libdwelf/libdwelf_pic.a \
170 ../libdwfl/libdwfl_pic.a ../libebl/libebl.a
171 libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
172 -libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS)
173 +libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) $(zip_LIBS)
174 libdw_so_SOURCES =
175 libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
176 # The rpath is necessary for libebl because its $ORIGIN use will
177 --- src/arlib.h 2015-08-21 14:22:37.000000000 +0200
178 +++ src/arlib.h 2015-11-20 08:02:55.153199611 +0100
179 @@ -29,6 +29,16 @@
180 #include <stdint.h>
181 #include <sys/types.h>
182
183 +#if !defined(ACCESSPERMS)
184 +# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
185 +#endif
186 +#if !defined(ALLPERMS)
187 +# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
188 +#endif
189 +#if !defined(DEFFILEMODE)
190 +# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
191 +#endif
192 +
193
194 /* State of -D/-U flags. */
195 extern bool arlib_deterministic_output;
196 --- src/elfcompress.c.orig 2016-04-02 12:51:26.903848894 +0200
197 +++ src/elfcompress.c 2016-04-02 12:55:15.076996338 +0200
198 @@ -35,6 +35,14 @@
199 #include <gelf.h>
200 #include "system.h"
201
202 +#if !defined(FNM_EXTMATCH)
203 +# define FNM_EXTMATCH 0
204 +#endif
205 +
206 +#if !defined(ALLPERMS)
207 +# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
208 +#endif
209 +
210 /* Name and version of program. */
211 static void print_version (FILE *stream, struct argp_state *state);
212 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
213 --- src/strip.c.orig 2017-08-02 12:06:25.000000000 +0000
214 +++ src/strip.c 2017-08-05 01:58:01.523493062 +0000
215 @@ -47,6 +47,14 @@
216 #include <system.h>
217 #include <printversion.h>
218
219 +#if !defined(FNM_EXTMATCH)
220 +# define FNM_EXTMATCH 0
221 +#endif
222 +
223 +#if !defined(ACCESSPERMS)
224 +#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
225 +#endif
226 +
227 typedef uint8_t GElf_Byte;
228
229 /* Name and version of program. */
230 --- src/readelf.c
231 +++ src/readelf.c
232 @@ -4773,10 +4773,11 @@ listptr_base (struct listptr *p)
233 return cudie_base (&cu);
234 }
235
236 +static const char *listptr_name;
237 +
238 static int
239 -compare_listptr (const void *a, const void *b, void *arg)
240 +compare_listptr (const void *a, const void *b)
241 {
242 - const char *name = arg;
243 struct listptr *p1 = (void *) a;
244 struct listptr *p2 = (void *) b;
245
246 @@ -4792,21 +4793,21 @@ compare_listptr (const void *a, const void *b, void *arg)
247 p1->warned = p2->warned = true;
248 error (0, 0,
249 gettext ("%s %#" PRIx64 " used with different address sizes"),
250 - name, (uint64_t) p1->offset);
251 + listptr_name, (uint64_t) p1->offset);
252 }
253 if (p1->dwarf64 != p2->dwarf64)
254 {
255 p1->warned = p2->warned = true;
256 error (0, 0,
257 gettext ("%s %#" PRIx64 " used with different offset sizes"),
258 - name, (uint64_t) p1->offset);
259 + listptr_name, (uint64_t) p1->offset);
260 }
261 if (listptr_base (p1) != listptr_base (p2))
262 {
263 p1->warned = p2->warned = true;
264 error (0, 0,
265 gettext ("%s %#" PRIx64 " used with different base addresses"),
266 - name, (uint64_t) p1->offset);
267 + listptr_name, (uint64_t) p1->offset);
268 }
269 if (p1->attr != p2 ->attr)
270 {
271 @@ -4814,7 +4815,7 @@ compare_listptr (const void *a, const void *b, void *arg)
272 error (0, 0,
273 gettext ("%s %#" PRIx64
274 " used with different attribute %s and %s"),
275 - name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
276 + listptr_name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
277 dwarf_attr_name (p2->attr));
278 }
279 }
280 @@ -4885,9 +4886,11 @@ notice_listptr (enum section_e section, struct listptr_table *table,
281 static void
282 sort_listptr (struct listptr_table *table, const char *name)
283 {
284 - if (table->n > 0)
285 - qsort_r (table->table, table->n, sizeof table->table[0],
286 - &compare_listptr, (void *) name);
287 + if (table->n > 0) {
288 + listptr_name = name;
289 + qsort (table->table, table->n, sizeof table->table[0],
290 + &compare_listptr);
291 + }
292 }
293
294 static bool
295 --- libdwfl/dwfl_error.c 2015-09-29 17:18:51.000000000 +0200
296 +++ libdwfl/dwfl_error.c 2015-11-20 05:11:29.889002058 +0100
297 @@ -154,7 +154,16 @@
298 switch (error &~ 0xffff)
299 {
300 case OTHER_ERROR (ERRNO):
301 +#if defined(__GLIBC__)
302 return strerror_r (error & 0xffff, "bad", 0);
303 +#else
304 + {
305 + static __thread char buf[128] = "";
306 + if (0 == strerror_r(error & 0xffff, buf, sizeof(buf)))
307 + return buf;
308 + }
309 + return "strerror_r() failed";
310 +#endif
311 case OTHER_ERROR (LIBELF):
312 return elf_errmsg (error & 0xffff);
313 case OTHER_ERROR (LIBDW):
314 --- src/unstrip.c.orig 2017-04-27 14:26:26.000000000 +0000
315 +++ src/unstrip.c 2017-05-05 15:51:33.515154220 +0000
316 @@ -56,6 +56,15 @@
317 # define _(str) gettext (str)
318 #endif
319
320 +#ifndef strndupa
321 +#define strndupa(s, n) \
322 + (__extension__ ({const char *__in = (s); \
323 + size_t __len = strnlen (__in, (n)) + 1; \
324 + char *__out = (char *) alloca (__len); \
325 + __out[__len-1] = '\0'; \
326 + (char *) memcpy (__out, __in, __len-1);}))
327 +#endif
328 +
329 /* Name and version of program. */
330 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
331
332 --- /dev/null 2019-03-09 09:00:22.527999555 +0100
333 +++ src/error.h 2019-03-09 16:37:44.828481636 +0100
334 @@ -0,0 +1,27 @@
335 +#ifndef _ERROR_H_
336 +#define _ERROR_H_
337 +
338 +#include <stdarg.h>
339 +#include <stdio.h>
340 +#include <stdlib.h>
341 +#include <string.h>
342 +#include <errno.h>
343 +
344 +static unsigned int error_message_count = 0;
345 +
346 +static inline void error(int status, int errnum, const char* format, ...)
347 +{
348 + va_list ap;
349 + fprintf(stderr, "%s: ", program_invocation_name);
350 + va_start(ap, format);
351 + vfprintf(stderr, format, ap);
352 + va_end(ap);
353 + if (errnum)
354 + fprintf(stderr, ": %s", strerror(errnum));
355 + fprintf(stderr, "\n");
356 + error_message_count++;
357 + if (status)
358 + exit(status);
359 +}
360 +
361 +#endif /* _ERROR_H_ */
362 --- /dev/null 2019-03-09 09:00:22.527999555 +0100
363 +++ lib/error.h 2019-03-09 16:37:46.732481531 +0100
364 @@ -0,0 +1,27 @@
365 +#ifndef _ERROR_H_
366 +#define _ERROR_H_
367 +
368 +#include <stdarg.h>
369 +#include <stdio.h>
370 +#include <stdlib.h>
371 +#include <string.h>
372 +#include <errno.h>
373 +
374 +static unsigned int error_message_count = 0;
375 +
376 +static inline void error(int status, int errnum, const char* format, ...)
377 +{
378 + va_list ap;
379 + fprintf(stderr, "%s: ", program_invocation_name);
380 + va_start(ap, format);
381 + vfprintf(stderr, format, ap);
382 + va_end(ap);
383 + if (errnum)
384 + fprintf(stderr, ": %s", strerror(errnum));
385 + fprintf(stderr, "\n");
386 + error_message_count++;
387 + if (status)
388 + exit(status);
389 +}
390 +
391 +#endif /* _ERROR_H_ */