summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/elfutils/files/musl-libs.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/elfutils/files/musl-libs.patch')
-rw-r--r--meta/recipes-devtools/elfutils/files/musl-libs.patch111
1 files changed, 111 insertions, 0 deletions
diff --git a/meta/recipes-devtools/elfutils/files/musl-libs.patch b/meta/recipes-devtools/elfutils/files/musl-libs.patch
new file mode 100644
index 0000000000..51ca630ef8
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/musl-libs.patch
@@ -0,0 +1,111 @@
1Collection of fixes needed to compile libelf and other libraries
2provided by elfutils for musl targets
3
4error is glibc specific API, so this patch will mostly not accepted
5upstream given that elfutils has been closely tied to glibc
6
7Signed-off-by: Khem Raj <raj.khem@gmail.com>
8Upstream-Status: Inappropriate [workaround for musl]
9
10--- /dev/null
11+++ b/lib/error.h
12@@ -0,0 +1,27 @@
13+#ifndef _ERROR_H_
14+#define _ERROR_H_
15+
16+#include <stdarg.h>
17+#include <stdio.h>
18+#include <stdlib.h>
19+#include <string.h>
20+#include <errno.h>
21+
22+static unsigned int error_message_count = 0;
23+
24+static inline void error(int status, int errnum, const char* format, ...)
25+{
26+ va_list ap;
27+ fprintf(stderr, "%s: ", program_invocation_name);
28+ va_start(ap, format);
29+ vfprintf(stderr, format, ap);
30+ va_end(ap);
31+ if (errnum)
32+ fprintf(stderr, ": %s", strerror(errnum));
33+ fprintf(stderr, "\n");
34+ error_message_count++;
35+ if (status)
36+ exit(status);
37+}
38+
39+#endif /* _ERROR_H_ */
40--- a/lib/fixedsizehash.h
41+++ b/lib/fixedsizehash.h
42@@ -30,7 +30,6 @@
43 #include <errno.h>
44 #include <stdlib.h>
45 #include <string.h>
46-#include <sys/cdefs.h>
47
48 #include <system.h>
49
50--- a/lib/libeu.h
51+++ b/lib/libeu.h
52@@ -29,6 +29,7 @@
53 #ifndef LIBEU_H
54 #define LIBEU_H
55
56+#include "system.h"
57 #include <stddef.h>
58 #include <stdint.h>
59
60--- a/libdwfl/dwfl_error.c
61+++ b/libdwfl/dwfl_error.c
62@@ -154,7 +154,16 @@ dwfl_errmsg (int error)
63 switch (error &~ 0xffff)
64 {
65 case OTHER_ERROR (ERRNO):
66+#if defined(__GLIBC__)
67 return strerror_r (error & 0xffff, "bad", 0);
68+#else
69+ {
70+ static __thread char buf[128] = "";
71+ if (strerror_r (error & 0xffff, buf, sizeof(buf)) == 0)
72+ return buf;
73+ }
74+ return "strerror_r() failed";
75+#endif
76 case OTHER_ERROR (LIBELF):
77 return elf_errmsg (error & 0xffff);
78 case OTHER_ERROR (LIBDW):
79--- a/libdwfl/linux-kernel-modules.c
80+++ b/libdwfl/linux-kernel-modules.c
81@@ -50,6 +50,7 @@
82 #include <sys/utsname.h>
83 #include <fcntl.h>
84 #include <unistd.h>
85+#include "system.h"
86
87 /* If fts.h is included before config.h, its indirect inclusions may not
88 give us the right LFS aliases of these functions, so map them manually. */
89--- a/libelf/elf.h
90+++ b/libelf/elf.h
91@@ -21,7 +21,9 @@
92
93 #include <features.h>
94
95-__BEGIN_DECLS
96+#ifdef __cplusplus
97+extern "C" {
98+#endif
99
100 /* Standard ELF types. */
101
102@@ -3937,6 +3939,7 @@ enum
103 #define R_METAG_TLS_LE_HI16 60
104 #define R_METAG_TLS_LE_LO16 61
105
106-__END_DECLS
107-
108+#ifdef __cplusplus
109+}
110+#endif
111 #endif /* elf.h */