recipes: Adjust some recipes to match the new package architecture name
[dragora.git] / patches / libelf / musl-utils.patch
bloba8ad93123642b9db00efe723858df6a8be08629e
1 From 7f5e2fd86d54e0a4d195ec65afb9b411829dff9f Mon Sep 17 00:00:00 2001
2 From: Hongxu Jia <hongxu.jia@windriver.com>
3 Date: Fri, 23 Aug 2019 10:19:48 +0800
4 Subject: [PATCH 3/3] musl-utils
6 Provide missing defines which otherwise are available on glibc system headers
8 Alter the error API to match posix version
9 use qsort instead of qsort_r which is glibc specific API
11 Signed-off-by: Khem Raj <raj.khem@gmail.com>
12 Upstream-Status: Inappropriate [workaround for musl]
14 Rebase to 0.177
15 Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
16 ---
17 src/arlib.h | 6 ++++++
18 src/elfcompress.c | 7 +++++++
19 src/readelf.c | 20 ++++++++++++--------
20 src/strip.c | 7 +++++++
21 src/unstrip.c | 9 +++++++++
22 5 files changed, 41 insertions(+), 8 deletions(-)
24 diff --git a/src/arlib.h b/src/arlib.h
25 index e117166..8326f6c 100644
26 --- a/src/arlib.h
27 +++ b/src/arlib.h
28 @@ -29,6 +29,12 @@
29 #include <stdint.h>
30 #include <sys/types.h>
32 +#if !defined(ALLPERMS)
33 +# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
34 +#endif
35 +#if !defined(DEFFILEMODE)
36 +# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
37 +#endif
39 /* State of -D/-U flags. */
40 extern bool arlib_deterministic_output;
41 diff --git a/src/elfcompress.c b/src/elfcompress.c
42 index 6ba6af4..0c7674b 100644
43 --- a/src/elfcompress.c
44 +++ b/src/elfcompress.c
45 @@ -37,6 +37,13 @@
46 #include "libeu.h"
47 #include "printversion.h"
49 +#if !defined(ALLPERMS)
50 +# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
51 +#endif
52 +#if !defined(FNM_EXTMATCH)
53 +# define FNM_EXTMATCH (0)
54 +#endif
56 /* Name and version of program. */
57 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
59 diff --git a/src/readelf.c b/src/readelf.c
60 index 5c02a9b..817562d 100644
61 --- a/src/readelf.c
62 +++ b/src/readelf.c
63 @@ -4813,10 +4813,11 @@ listptr_base (struct listptr *p)
64 return cudie_base (&cu);
67 +static const char *listptr_name;
69 static int
70 -compare_listptr (const void *a, const void *b, void *arg)
71 +compare_listptr (const void *a, const void *b)
73 - const char *name = arg;
74 struct listptr *p1 = (void *) a;
75 struct listptr *p2 = (void *) b;
77 @@ -4832,21 +4833,21 @@ compare_listptr (const void *a, const void *b, void *arg)
78 p1->warned = p2->warned = true;
79 error (0, 0,
80 gettext ("%s %#" PRIx64 " used with different address sizes"),
81 - name, (uint64_t) p1->offset);
82 + listptr_name, (uint64_t) p1->offset);
84 if (p1->dwarf64 != p2->dwarf64)
86 p1->warned = p2->warned = true;
87 error (0, 0,
88 gettext ("%s %#" PRIx64 " used with different offset sizes"),
89 - name, (uint64_t) p1->offset);
90 + listptr_name, (uint64_t) p1->offset);
92 if (listptr_base (p1) != listptr_base (p2))
94 p1->warned = p2->warned = true;
95 error (0, 0,
96 gettext ("%s %#" PRIx64 " used with different base addresses"),
97 - name, (uint64_t) p1->offset);
98 + listptr_name, (uint64_t) p1->offset);
100 if (p1->attr != p2 ->attr)
102 @@ -4854,7 +4855,7 @@ compare_listptr (const void *a, const void *b, void *arg)
103 error (0, 0,
104 gettext ("%s %#" PRIx64
105 " used with different attribute %s and %s"),
106 - name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
107 + listptr_name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
108 dwarf_attr_name (p2->attr));
111 @@ -4926,8 +4927,11 @@ static void
112 sort_listptr (struct listptr_table *table, const char *name)
114 if (table->n > 0)
115 - qsort_r (table->table, table->n, sizeof table->table[0],
116 - &compare_listptr, (void *) name);
118 + listptr_name = name;
119 + qsort (table->table, table->n, sizeof table->table[0],
120 + &compare_listptr);
124 static bool
125 diff --git a/src/strip.c b/src/strip.c
126 index 4054c2a..d2d2176 100644
127 --- a/src/strip.c
128 +++ b/src/strip.c
129 @@ -46,6 +46,13 @@
130 #include <system.h>
131 #include <printversion.h>
133 +#if !defined(ACCESSPERMS)
134 +# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
135 +#endif
136 +#if !defined(FNM_EXTMATCH)
137 +# define FNM_EXTMATCH (0)
138 +#endif
140 typedef uint8_t GElf_Byte;
142 /* Name and version of program. */
143 diff --git a/src/unstrip.c b/src/unstrip.c
144 index fc87832..21ea6b3 100644
145 --- a/src/unstrip.c
146 +++ b/src/unstrip.c
147 @@ -56,6 +56,15 @@
148 # define _(str) gettext (str)
149 #endif
151 +#ifndef strndupa
152 +#define strndupa(s, n) \
153 + ({const char *__in = (s); \
154 + size_t __len = strnlen (__in, (n)) + 1; \
155 + char *__out = (char *) alloca (__len); \
156 + __out[__len-1] = '\0'; \
157 + (char *) memcpy (__out, __in, __len-1);})
158 +#endif
160 /* Name and version of program. */
161 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
164 2.7.4