recipes: tde/tqt3: make QTDIR visible for the system
[dragora.git] / patches / libelf / musl-libs.patch
blobb9b9f120dfa4912448c9de04badfa3bac1813c5e
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]
15 Rebase to 0.177
16 Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
17 ---
18 lib/error.h | 27 +++++++++++++++++++++++++++
19 lib/fixedsizehash.h | 1 -
20 lib/libeu.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
28 new file mode 100644
29 index 0000000..ef06827
30 --- /dev/null
31 +++ b/lib/error.h
32 @@ -0,0 +1,27 @@
33 +#ifndef _ERROR_H_
34 +#define _ERROR_H_
36 +#include <stdarg.h>
37 +#include <stdio.h>
38 +#include <stdlib.h>
39 +#include <string.h>
40 +#include <errno.h>
42 +static unsigned int error_message_count = 0;
44 +static inline void error(int status, int errnum, const char* format, ...)
46 + va_list ap;
47 + fprintf(stderr, "%s: ", program_invocation_name);
48 + va_start(ap, format);
49 + vfprintf(stderr, format, ap);
50 + va_end(ap);
51 + if (errnum)
52 + fprintf(stderr, ": %s", strerror(errnum));
53 + fprintf(stderr, "\n");
54 + error_message_count++;
55 + if (status)
56 + exit(status);
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
64 @@ -30,7 +30,6 @@
65 #include <errno.h>
66 #include <stdlib.h>
67 #include <string.h>
68 -#include <sys/cdefs.h>
70 #include <system.h>
72 diff --git a/lib/libeu.h b/lib/libeu.h
73 index ecb4d01..edc85e3 100644
74 --- a/lib/libeu.h
75 +++ b/lib/libeu.h
76 @@ -29,6 +29,7 @@
77 #ifndef LIBEU_H
78 #define LIBEU_H
80 +#include "system.h"
81 #include <stddef.h>
82 #include <stdint.h>
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);
94 +#else
95 + {
96 + static __thread char buf[128] = "";
97 + if (strerror_r (error & 0xffff, buf, sizeof(buf)) == 0)
98 + return buf;
99 + }
100 + return "strerror_r() failed";
101 +#endif
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
109 @@ -50,6 +50,7 @@
110 #include <sys/utsname.h>
111 #include <fcntl.h>
112 #include <unistd.h>
113 +#include "system.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
119 --- a/libelf/elf.h
120 +++ b/libelf/elf.h
121 @@ -21,7 +21,9 @@
123 #include <features.h>
125 -__BEGIN_DECLS
126 +#ifdef __cplusplus
127 +extern "C" {
128 +#endif
130 /* Standard ELF types. */
132 @@ -4029,6 +4031,7 @@ enum
133 #define R_NDS32_TLS_TPOFF 102
134 #define R_NDS32_TLS_DESC 119
136 -__END_DECLS
138 +#ifdef __cplusplus
140 +#endif
141 #endif /* elf.h */
143 2.7.4