1 From d5a1651df9884fcf57ed320bc2f866538af2f420 Mon Sep 17 00:00:00 2001
2 From: Hongxu Jia <hongxu.jia@windriver.com>
3 Date: Fri, 23 Aug 2019 10:18:47 +0800
4 Subject: [PATCH 2/3] musl-libs
6 Collection of fixes needed to compile libelf and other libraries
7 provided by elfutils for musl targets
9 error is glibc specific API, so this patch will mostly not accepted
10 upstream given that elfutils has been closely tied to glibc
12 Signed-off-by: Khem Raj <raj.khem@gmail.com>
13 Upstream-Status: Inappropriate [workaround for musl]
16 Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
18 lib/error.h | 27 +++++++++++++++++++++++++++
19 lib/fixedsizehash.h | 1 -
21 libdwfl/dwfl_error.c | 9 +++++++++
22 libdwfl/linux-kernel-modules.c | 1 +
23 libelf/elf.h | 9 ++++++---
24 6 files changed, 44 insertions(+), 4 deletions(-)
25 create mode 100644 lib/error.h
27 diff --git a/lib/error.h b/lib/error.h
29 index 0000000..ef06827
42 +static unsigned int error_message_count = 0;
44 +static inline void error(int status, int errnum, const char* format, ...)
47 + fprintf(stderr, "%s: ", program_invocation_name);
48 + va_start(ap, format);
49 + vfprintf(stderr, format, ap);
52 + fprintf(stderr, ": %s", strerror(errnum));
53 + fprintf(stderr, "\n");
54 + error_message_count++;
59 +#endif /* _ERROR_H_ */
60 diff --git a/lib/fixedsizehash.h b/lib/fixedsizehash.h
61 index dac2a5f..43016fc 100644
62 --- a/lib/fixedsizehash.h
63 +++ b/lib/fixedsizehash.h
68 -#include <sys/cdefs.h>
72 diff --git a/lib/libeu.h b/lib/libeu.h
73 index ecb4d01..edc85e3 100644
84 diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
85 index 7bcf61c..11dcc8b 100644
86 --- a/libdwfl/dwfl_error.c
87 +++ b/libdwfl/dwfl_error.c
88 @@ -154,7 +154,16 @@ dwfl_errmsg (int error)
89 switch (error &~ 0xffff)
91 case OTHER_ERROR (ERRNO):
92 +#if defined(__GLIBC__)
93 return strerror_r (error & 0xffff, "bad", 0);
96 + static __thread char buf[128] = "";
97 + if (strerror_r (error & 0xffff, buf, sizeof(buf)) == 0)
100 + return "strerror_r() failed";
102 case OTHER_ERROR (LIBELF):
103 return elf_errmsg (error & 0xffff);
104 case OTHER_ERROR (LIBDW):
105 diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
106 index d46ab5a..1c3faee 100644
107 --- a/libdwfl/linux-kernel-modules.c
108 +++ b/libdwfl/linux-kernel-modules.c
110 #include <sys/utsname.h>
115 /* If fts.h is included before config.h, its indirect inclusions may not
116 give us the right LFS aliases of these functions, so map them manually. */
117 diff --git a/libelf/elf.h b/libelf/elf.h
118 index bed273d..be228e6 100644
123 #include <features.h>
130 /* Standard ELF types. */
132 @@ -4029,6 +4031,7 @@ enum
133 #define R_NDS32_TLS_TPOFF 102
134 #define R_NDS32_TLS_DESC 119