elfutils: bump to 0.173
[openwrt/openwrt.git] / package / libs / elfutils / patches / 100-musl-compat.patch
1 https://sourceware.org/bugzilla/show_bug.cgi?id=21002
2
3 --- a/lib/system.h
4 +++ b/lib/system.h
5 @@ -29,7 +29,18 @@
6 #ifndef LIB_SYSTEM_H
7 #define LIB_SYSTEM_H 1
8
9 +#ifdef HAVE_ERROR_H
10 +#include "error.h"
11 +#else
12 +#include "err.h"
13 #include <errno.h>
14 +#include <stdio.h>
15 +#define error(status, errno, ...) \
16 + fflush(stdout); \
17 + warn(__VA_ARGS__); \
18 + if (status) exit(status)
19 +#endif
20 +
21 #include <stddef.h>
22 #include <stdint.h>
23 #include <sys/param.h>
24 @@ -37,6 +48,10 @@
25 #include <byteswap.h>
26 #include <unistd.h>
27
28 +#ifndef __GLIBC__
29 +#define canonicalize_file_name(name) realpath(name,NULL)
30 +#endif
31 +
32 #if __BYTE_ORDER == __LITTLE_ENDIAN
33 # define LE32(n) (n)
34 # define LE64(n) (n)
35 --- a/lib/color.c
36 +++ b/lib/color.c
37 @@ -32,13 +32,13 @@
38 #endif
39
40 #include <argp.h>
41 -#include <error.h>
42 #include <libintl.h>
43 #include <stdlib.h>
44 #include <string.h>
45 #include <unistd.h>
46 #include "libeu.h"
47 #include "color.h"
48 +#include "system.h"
49
50 /* Prototype for option handler. */
51 static error_t parse_opt (int key, char *arg, struct argp_state *state);
52 --- a/lib/xmalloc.c
53 +++ b/lib/xmalloc.c
54 @@ -30,7 +30,6 @@
55 # include <config.h>
56 #endif
57
58 -#include <error.h>
59 #include <libintl.h>
60 #include <stddef.h>
61 #include <stdlib.h>
62 --- a/src/addr2line.c
63 +++ b/src/addr2line.c
64 @@ -23,7 +23,6 @@
65 #include <argp.h>
66 #include <assert.h>
67 #include <errno.h>
68 -#include <error.h>
69 #include <fcntl.h>
70 #include <inttypes.h>
71 #include <libdwfl.h>
72 --- a/src/ar.c
73 +++ b/src/ar.c
74 @@ -22,7 +22,6 @@
75
76 #include <argp.h>
77 #include <assert.h>
78 -#include <error.h>
79 #include <fcntl.h>
80 #include <gelf.h>
81 #include <libintl.h>
82 --- a/src/arlib2.c
83 +++ b/src/arlib2.c
84 @@ -20,7 +20,6 @@
85 # include <config.h>
86 #endif
87
88 -#include <error.h>
89 #include <libintl.h>
90 #include <limits.h>
91 #include <string.h>
92 --- a/src/arlib.c
93 +++ b/src/arlib.c
94 @@ -21,7 +21,6 @@
95 #endif
96
97 #include <assert.h>
98 -#include <error.h>
99 #include <gelf.h>
100 #include <inttypes.h>
101 #include <libintl.h>
102 --- a/src/elfcmp.c
103 +++ b/src/elfcmp.c
104 @@ -23,7 +23,6 @@
105 #include <argp.h>
106 #include <assert.h>
107 #include <errno.h>
108 -#include <error.h>
109 #include <fcntl.h>
110 #include <locale.h>
111 #include <libintl.h>
112 --- a/src/elflint.c
113 +++ b/src/elflint.c
114 @@ -24,7 +24,6 @@
115 #include <assert.h>
116 #include <byteswap.h>
117 #include <endian.h>
118 -#include <error.h>
119 #include <fcntl.h>
120 #include <gelf.h>
121 #include <inttypes.h>
122 --- a/src/findtextrel.c
123 +++ b/src/findtextrel.c
124 @@ -23,7 +23,6 @@
125 #include <argp.h>
126 #include <assert.h>
127 #include <errno.h>
128 -#include <error.h>
129 #include <fcntl.h>
130 #include <gelf.h>
131 #include <libdw.h>
132 --- a/src/nm.c
133 +++ b/src/nm.c
134 @@ -26,7 +26,6 @@
135 #include <ctype.h>
136 #include <dwarf.h>
137 #include <errno.h>
138 -#include <error.h>
139 #include <fcntl.h>
140 #include <gelf.h>
141 #include <inttypes.h>
142 --- a/src/objdump.c
143 +++ b/src/objdump.c
144 @@ -21,7 +21,6 @@
145 #endif
146
147 #include <argp.h>
148 -#include <error.h>
149 #include <fcntl.h>
150 #include <inttypes.h>
151 #include <libintl.h>
152 --- a/src/ranlib.c
153 +++ b/src/ranlib.c
154 @@ -24,7 +24,6 @@
155 #include <argp.h>
156 #include <assert.h>
157 #include <errno.h>
158 -#include <error.h>
159 #include <fcntl.h>
160 #include <gelf.h>
161 #include <libintl.h>
162 --- a/src/readelf.c
163 +++ b/src/readelf.c
164 @@ -24,7 +24,6 @@
165 #include <ctype.h>
166 #include <dwarf.h>
167 #include <errno.h>
168 -#include <error.h>
169 #include <fcntl.h>
170 #include <gelf.h>
171 #include <inttypes.h>
172 --- a/src/size.c
173 +++ b/src/size.c
174 @@ -21,7 +21,6 @@
175 #endif
176
177 #include <argp.h>
178 -#include <error.h>
179 #include <fcntl.h>
180 #include <gelf.h>
181 #include <inttypes.h>
182 --- a/src/stack.c
183 +++ b/src/stack.c
184 @@ -18,7 +18,6 @@
185 #include <config.h>
186 #include <assert.h>
187 #include <argp.h>
188 -#include <error.h>
189 #include <stdlib.h>
190 #include <inttypes.h>
191 #include <stdio.h>
192 --- a/src/strings.c
193 +++ b/src/strings.c
194 @@ -25,7 +25,6 @@
195 #include <ctype.h>
196 #include <endian.h>
197 #include <errno.h>
198 -#include <error.h>
199 #include <fcntl.h>
200 #include <gelf.h>
201 #include <inttypes.h>
202 --- a/src/strip.c
203 +++ b/src/strip.c
204 @@ -24,7 +24,6 @@
205 #include <assert.h>
206 #include <byteswap.h>
207 #include <endian.h>
208 -#include <error.h>
209 #include <fcntl.h>
210 #include <fnmatch.h>
211 #include <gelf.h>
212 --- a/src/unstrip.c
213 +++ b/src/unstrip.c
214 @@ -31,7 +31,6 @@
215 #include <argp.h>
216 #include <assert.h>
217 #include <errno.h>
218 -#include <error.h>
219 #include <fcntl.h>
220 #include <fnmatch.h>
221 #include <libintl.h>
222 --- a/tests/addrscopes.c
223 +++ b/tests/addrscopes.c
224 @@ -25,7 +25,6 @@
225 #include <stdio_ext.h>
226 #include <locale.h>
227 #include <stdlib.h>
228 -#include <error.h>
229 #include <string.h>
230
231
232 --- a/tests/allregs.c
233 +++ b/tests/allregs.c
234 @@ -21,7 +21,6 @@
235 #include <stdio.h>
236 #include <stdlib.h>
237 #include <string.h>
238 -#include <error.h>
239 #include <locale.h>
240 #include <argp.h>
241 #include <assert.h>
242 --- a/tests/backtrace.c
243 +++ b/tests/backtrace.c
244 @@ -24,7 +24,6 @@
245 #include <dirent.h>
246 #include <stdlib.h>
247 #include <errno.h>
248 -#include <error.h>
249 #include <unistd.h>
250 #include <dwarf.h>
251 #ifdef __linux__
252 --- a/tests/backtrace-data.c
253 +++ b/tests/backtrace-data.c
254 @@ -27,7 +27,6 @@
255 #include <dirent.h>
256 #include <stdlib.h>
257 #include <errno.h>
258 -#include <error.h>
259 #include <unistd.h>
260 #include <dwarf.h>
261 #if defined(__x86_64__) && defined(__linux__)
262 --- a/tests/buildid.c
263 +++ b/tests/buildid.c
264 @@ -23,7 +23,6 @@
265 #include ELFUTILS_HEADER(elf)
266 #include ELFUTILS_HEADER(dwelf)
267 #include <stdio.h>
268 -#include <error.h>
269 #include <string.h>
270 #include <stdlib.h>
271 #include <sys/types.h>
272 --- a/tests/debugaltlink.c
273 +++ b/tests/debugaltlink.c
274 @@ -23,7 +23,6 @@
275 #include ELFUTILS_HEADER(dw)
276 #include ELFUTILS_HEADER(dwelf)
277 #include <stdio.h>
278 -#include <error.h>
279 #include <string.h>
280 #include <stdlib.h>
281 #include <sys/types.h>
282 --- a/tests/debuglink.c
283 +++ b/tests/debuglink.c
284 @@ -21,7 +21,6 @@
285 #include <errno.h>
286 #include ELFUTILS_HEADER(dwelf)
287 #include <stdio.h>
288 -#include <error.h>
289 #include <string.h>
290 #include <stdlib.h>
291 #include <sys/types.h>
292 --- a/tests/dwfl-addr-sect.c
293 +++ b/tests/dwfl-addr-sect.c
294 @@ -23,7 +23,6 @@
295 #include <stdio_ext.h>
296 #include <stdlib.h>
297 #include <string.h>
298 -#include <error.h>
299 #include <locale.h>
300 #include <argp.h>
301 #include ELFUTILS_HEADER(dwfl)
302 --- a/tests/dwfl-bug-addr-overflow.c
303 +++ b/tests/dwfl-bug-addr-overflow.c
304 @@ -20,7 +20,6 @@
305 #include <inttypes.h>
306 #include <stdio.h>
307 #include <stdio_ext.h>
308 -#include <error.h>
309 #include <locale.h>
310 #include ELFUTILS_HEADER(dwfl)
311
312 --- a/tests/dwfl-bug-fd-leak.c
313 +++ b/tests/dwfl-bug-fd-leak.c
314 @@ -24,7 +24,6 @@
315 #include <dirent.h>
316 #include <stdlib.h>
317 #include <errno.h>
318 -#include <error.h>
319 #include <unistd.h>
320 #include <dwarf.h>
321
322 --- a/tests/dwfl-bug-getmodules.c
323 +++ b/tests/dwfl-bug-getmodules.c
324 @@ -18,7 +18,6 @@
325 #include <config.h>
326 #include ELFUTILS_HEADER(dwfl)
327
328 -#include <error.h>
329
330 static const Dwfl_Callbacks callbacks =
331 {
332 --- a/tests/dwfllines.c
333 +++ b/tests/dwfllines.c
334 @@ -27,7 +27,6 @@
335 #include <stdio.h>
336 #include <stdlib.h>
337 #include <string.h>
338 -#include <error.h>
339
340 int
341 main (int argc, char *argv[])
342 --- a/tests/dwflmodtest.c
343 +++ b/tests/dwflmodtest.c
344 @@ -23,7 +23,6 @@
345 #include <stdio_ext.h>
346 #include <stdlib.h>
347 #include <string.h>
348 -#include <error.h>
349 #include <locale.h>
350 #include <argp.h>
351 #include ELFUTILS_HEADER(dwfl)
352 --- a/tests/dwfl-report-elf-align.c
353 +++ b/tests/dwfl-report-elf-align.c
354 @@ -20,7 +20,6 @@
355 #include <inttypes.h>
356 #include <stdio.h>
357 #include <stdio_ext.h>
358 -#include <error.h>
359 #include <locale.h>
360 #include <string.h>
361 #include <stdlib.h>
362 --- a/tests/dwflsyms.c
363 +++ b/tests/dwflsyms.c
364 @@ -25,7 +25,6 @@
365 #include <stdio.h>
366 #include <stdio_ext.h>
367 #include <stdlib.h>
368 -#include <error.h>
369 #include <string.h>
370
371 static const char *
372 --- a/tests/early-offscn.c
373 +++ b/tests/early-offscn.c
374 @@ -19,7 +19,6 @@
375 #endif
376
377 #include <errno.h>
378 -#include <error.h>
379 #include <fcntl.h>
380 #include <gelf.h>
381 #include <stdio.h>
382 --- a/tests/ecp.c
383 +++ b/tests/ecp.c
384 @@ -20,7 +20,6 @@
385 #endif
386
387 #include <errno.h>
388 -#include <error.h>
389 #include <fcntl.h>
390 #include <gelf.h>
391 #include <stdlib.h>
392 --- a/tests/find-prologues.c
393 +++ b/tests/find-prologues.c
394 @@ -25,7 +25,6 @@
395 #include <stdio_ext.h>
396 #include <locale.h>
397 #include <stdlib.h>
398 -#include <error.h>
399 #include <string.h>
400 #include <fnmatch.h>
401
402 --- a/tests/funcretval.c
403 +++ b/tests/funcretval.c
404 @@ -25,7 +25,6 @@
405 #include <stdio_ext.h>
406 #include <locale.h>
407 #include <stdlib.h>
408 -#include <error.h>
409 #include <string.h>
410 #include <fnmatch.h>
411
412 --- a/tests/funcscopes.c
413 +++ b/tests/funcscopes.c
414 @@ -25,7 +25,6 @@
415 #include <stdio_ext.h>
416 #include <locale.h>
417 #include <stdlib.h>
418 -#include <error.h>
419 #include <string.h>
420 #include <fnmatch.h>
421
422 --- a/tests/line2addr.c
423 +++ b/tests/line2addr.c
424 @@ -26,7 +26,6 @@
425 #include <locale.h>
426 #include <stdlib.h>
427 #include <string.h>
428 -#include <error.h>
429
430
431 static void
432 --- a/tests/low_high_pc.c
433 +++ b/tests/low_high_pc.c
434 @@ -25,7 +25,6 @@
435 #include <stdio_ext.h>
436 #include <locale.h>
437 #include <stdlib.h>
438 -#include <error.h>
439 #include <string.h>
440 #include <fnmatch.h>
441
442 --- a/tests/rdwrmmap.c
443 +++ b/tests/rdwrmmap.c
444 @@ -19,7 +19,6 @@
445 #endif
446
447 #include <errno.h>
448 -#include <error.h>
449 #include <stdio.h>
450 #include <fcntl.h>
451 #include <unistd.h>
452 --- a/tests/saridx.c
453 +++ b/tests/saridx.c
454 @@ -17,7 +17,6 @@
455
456 #include <config.h>
457
458 -#include <error.h>
459 #include <fcntl.h>
460 #include <gelf.h>
461 #include <stdio.h>
462 --- a/tests/sectiondump.c
463 +++ b/tests/sectiondump.c
464 @@ -18,7 +18,6 @@
465 #include <config.h>
466
467 #include <errno.h>
468 -#include <error.h>
469 #include <fcntl.h>
470 #include <gelf.h>
471 #include <inttypes.h>
472 --- a/tests/varlocs.c
473 +++ b/tests/varlocs.c
474 @@ -25,7 +25,6 @@
475 #include <dwarf.h>
476 #include <stdio.h>
477 #include <stdlib.h>
478 -#include <error.h>
479 #include <string.h>
480 #include <sys/types.h>
481 #include <sys/stat.h>
482 --- a/libasm/asm_end.c
483 +++ b/libasm/asm_end.c
484 @@ -32,7 +32,6 @@
485 #endif
486
487 #include <assert.h>
488 -#include <error.h>
489 #include <libintl.h>
490 #include <stdio.h>
491 #include <stdlib.h>
492 --- a/libasm/asm_newscn.c
493 +++ b/libasm/asm_newscn.c
494 @@ -32,7 +32,6 @@
495 #endif
496
497 #include <assert.h>
498 -#include <error.h>
499 #include <libintl.h>
500 #include <stdlib.h>
501 #include <string.h>
502 --- a/libcpu/i386_gendis.c
503 +++ b/libcpu/i386_gendis.c
504 @@ -31,7 +31,6 @@
505 # include <config.h>
506 #endif
507
508 -#include <error.h>
509 #include <errno.h>
510 #include <stdio.h>
511 #include <stdlib.h>
512 --- a/libcpu/i386_lex.c
513 +++ b/libcpu/i386_lex.c
514 @@ -808,7 +808,6 @@ char *yytext;
515 #endif
516
517 #include <ctype.h>
518 -#include <error.h>
519 #include <libintl.h>
520
521 #include <libeu.h>
522 --- a/libcpu/i386_lex.l
523 +++ b/libcpu/i386_lex.l
524 @@ -31,7 +31,6 @@
525 #endif
526
527 #include <ctype.h>
528 -#include <error.h>
529 #include <libintl.h>
530
531 #include <libeu.h>
532 --- a/libcpu/i386_parse.c
533 +++ b/libcpu/i386_parse.c
534 @@ -107,7 +107,6 @@
535 #include <assert.h>
536 #include <ctype.h>
537 #include <errno.h>
538 -#include <error.h>
539 #include <inttypes.h>
540 #include <libintl.h>
541 #include <math.h>
542 --- a/libdw/libdw_alloc.c
543 +++ b/libdw/libdw_alloc.c
544 @@ -31,7 +31,6 @@
545 # include <config.h>
546 #endif
547
548 -#include <error.h>
549 #include <errno.h>
550 #include <stdlib.h>
551 #include "libdwP.h"
552 @@ -74,5 +73,5 @@ __attribute ((noreturn)) attribute_hidde
553 __libdw_oom (void)
554 {
555 while (1)
556 - error (EXIT_FAILURE, ENOMEM, "libdw");
557 + error (EXIT_FAILURE, errno, gettext ("cannot allocate memory"));
558 }
559 --- a/libebl/eblopenbackend.c
560 +++ b/libebl/eblopenbackend.c
561 @@ -32,7 +32,6 @@
562
563 #include <assert.h>
564 #include <dlfcn.h>
565 -#include <error.h>
566 #include <libelfP.h>
567 #include <dwarf.h>
568 #include <stdlib.h>
569 --- a/libdwfl/dwfl_error.c
570 +++ b/libdwfl/dwfl_error.c
571 @@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error)
572 const char *
573 dwfl_errmsg (int error)
574 {
575 + static __thread char s[64] = "";
576 if (error == 0 || error == -1)
577 {
578 int last_error = global_error;
579 @@ -154,7 +155,8 @@ dwfl_errmsg (int error)
580 switch (error &~ 0xffff)
581 {
582 case OTHER_ERROR (ERRNO):
583 - return strerror_r (error & 0xffff, "bad", 0);
584 + strerror_r (error & 0xffff, s, sizeof(s));
585 + return s;
586 case OTHER_ERROR (LIBELF):
587 return elf_errmsg (error & 0xffff);
588 case OTHER_ERROR (LIBDW):