f8e9a29235edb266eb8d0a0f783bd07117c14869
[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 @@ -30,7 +30,16 @@
6 #define LIB_SYSTEM_H 1
7
8 #include <errno.h>
9 -#include <error.h>
10 +#ifdef HAVE_ERROR_H
11 +#include "error.h"
12 +#else
13 +#include "err.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 #include <stddef.h>
21 #include <stdint.h>
22 #include <sys/param.h>
23 @@ -38,6 +47,10 @@
24 #include <byteswap.h>
25 #include <unistd.h>
26
27 +#ifndef __GLIBC__
28 +#define canonicalize_file_name(name) realpath(name,NULL)
29 +#endif
30 +
31 #if __BYTE_ORDER == __LITTLE_ENDIAN
32 # define LE32(n) (n)
33 # define LE64(n) (n)
34 --- a/libdw/libdw_alloc.c
35 +++ b/libdw/libdw_alloc.c
36 @@ -73,5 +73,5 @@ __attribute ((noreturn)) attribute_hidde
37 __libdw_oom (void)
38 {
39 while (1)
40 - error (EXIT_FAILURE, ENOMEM, "libdw");
41 + error (EXIT_FAILURE, errno, gettext ("cannot allocate memory"));
42 }
43 --- a/libdwfl/dwfl_error.c
44 +++ b/libdwfl/dwfl_error.c
45 @@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error)
46 const char *
47 dwfl_errmsg (int error)
48 {
49 + static __thread char s[64] = "";
50 if (error == 0 || error == -1)
51 {
52 int last_error = global_error;
53 @@ -154,7 +155,8 @@ dwfl_errmsg (int error)
54 switch (error &~ 0xffff)
55 {
56 case OTHER_ERROR (ERRNO):
57 - return strerror_r (error & 0xffff, "bad", 0);
58 + strerror_r (error & 0xffff, s, sizeof(s));
59 + return s;
60 case OTHER_ERROR (LIBELF):
61 return elf_errmsg (error & 0xffff);
62 case OTHER_ERROR (LIBDW):