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]
15 Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
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
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 */
35 +#if !defined(DEFFILEMODE)
36 +# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
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
47 #include "printversion.h"
49 +#if !defined(ALLPERMS)
50 +# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
52 +#if !defined(FNM_EXTMATCH)
53 +# define FNM_EXTMATCH (0)
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
63 @@ -4813,10 +4813,11 @@ listptr_base (struct listptr *p)
64 return cudie_base (&cu);
67 +static const char *listptr_name;
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;
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;
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;
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)
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)
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],
125 diff --git a/src/strip.c b/src/strip.c
126 index 4054c2a..d2d2176 100644
131 #include <printversion.h>
133 +#if !defined(ACCESSPERMS)
134 +# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
136 +#if !defined(FNM_EXTMATCH)
137 +# define FNM_EXTMATCH (0)
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
148 # define _(str) gettext (str)
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);})
160 /* Name and version of program. */
161 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;