blob: a8ad93123642b9db00efe723858df6a8be08629e [file] [log] [blame]
Brad Bishopa34c0302019-09-23 22:34:48 -04001From 7f5e2fd86d54e0a4d195ec65afb9b411829dff9f Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Fri, 23 Aug 2019 10:19:48 +0800
4Subject: [PATCH 3/3] musl-utils
5
Brad Bishop96ff1982019-08-19 13:50:42 -04006Provide missing defines which otherwise are available on glibc system headers
7
8Alter the error API to match posix version
9use qsort instead of qsort_r which is glibc specific API
10
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12Upstream-Status: Inappropriate [workaround for musl]
Brad Bishopa34c0302019-09-23 22:34:48 -040013
14Rebase to 0.177
15Signed-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(-)
23
24diff --git a/src/arlib.h b/src/arlib.h
25index e117166..8326f6c 100644
Brad Bishop96ff1982019-08-19 13:50:42 -040026--- a/src/arlib.h
27+++ b/src/arlib.h
28@@ -29,6 +29,12 @@
29 #include <stdint.h>
30 #include <sys/types.h>
31
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
38
39 /* State of -D/-U flags. */
40 extern bool arlib_deterministic_output;
Brad Bishopa34c0302019-09-23 22:34:48 -040041diff --git a/src/elfcompress.c b/src/elfcompress.c
42index 6ba6af4..0c7674b 100644
Brad Bishop96ff1982019-08-19 13:50:42 -040043--- a/src/elfcompress.c
44+++ b/src/elfcompress.c
45@@ -37,6 +37,13 @@
46 #include "libeu.h"
47 #include "printversion.h"
48
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
55+
56 /* Name and version of program. */
57 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
58
Brad Bishopa34c0302019-09-23 22:34:48 -040059diff --git a/src/readelf.c b/src/readelf.c
60index 5c02a9b..817562d 100644
Brad Bishop96ff1982019-08-19 13:50:42 -040061--- a/src/readelf.c
62+++ b/src/readelf.c
Brad Bishopa34c0302019-09-23 22:34:48 -040063@@ -4813,10 +4813,11 @@ listptr_base (struct listptr *p)
Brad Bishop96ff1982019-08-19 13:50:42 -040064 return cudie_base (&cu);
65 }
66
67+static const char *listptr_name;
68+
69 static int
70-compare_listptr (const void *a, const void *b, void *arg)
71+compare_listptr (const void *a, const void *b)
72 {
73- const char *name = arg;
74 struct listptr *p1 = (void *) a;
75 struct listptr *p2 = (void *) b;
76
Brad Bishopa34c0302019-09-23 22:34:48 -040077@@ -4832,21 +4833,21 @@ compare_listptr (const void *a, const void *b, void *arg)
Brad Bishop96ff1982019-08-19 13:50:42 -040078 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);
83 }
84 if (p1->dwarf64 != p2->dwarf64)
85 {
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);
91 }
92 if (listptr_base (p1) != listptr_base (p2))
93 {
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);
99 }
100 if (p1->attr != p2 ->attr)
101 {
Brad Bishopa34c0302019-09-23 22:34:48 -0400102@@ -4854,7 +4855,7 @@ compare_listptr (const void *a, const void *b, void *arg)
Brad Bishop96ff1982019-08-19 13:50:42 -0400103 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));
109 }
110 }
Brad Bishopa34c0302019-09-23 22:34:48 -0400111@@ -4926,8 +4927,11 @@ static void
Brad Bishop96ff1982019-08-19 13:50:42 -0400112 sort_listptr (struct listptr_table *table, const char *name)
113 {
114 if (table->n > 0)
115- qsort_r (table->table, table->n, sizeof table->table[0],
116- &compare_listptr, (void *) name);
117+ {
118+ listptr_name = name;
119+ qsort (table->table, table->n, sizeof table->table[0],
120+ &compare_listptr);
121+ }
122 }
123
124 static bool
Brad Bishopa34c0302019-09-23 22:34:48 -0400125diff --git a/src/strip.c b/src/strip.c
126index 4054c2a..d2d2176 100644
Brad Bishop96ff1982019-08-19 13:50:42 -0400127--- a/src/strip.c
128+++ b/src/strip.c
129@@ -46,6 +46,13 @@
130 #include <system.h>
131 #include <printversion.h>
132
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
139+
140 typedef uint8_t GElf_Byte;
141
142 /* Name and version of program. */
Brad Bishopa34c0302019-09-23 22:34:48 -0400143diff --git a/src/unstrip.c b/src/unstrip.c
144index fc87832..21ea6b3 100644
Brad Bishop96ff1982019-08-19 13:50:42 -0400145--- a/src/unstrip.c
146+++ b/src/unstrip.c
147@@ -56,6 +56,15 @@
148 # define _(str) gettext (str)
149 #endif
150
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
159+
160 /* Name and version of program. */
161 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
162
Brad Bishopa34c0302019-09-23 22:34:48 -0400163--
1642.7.4
165