summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/elfutils/files/musl-utils.patch
blob: 8e636bf660419160b06a0b94194745af7507d743 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
Provide missing defines which otherwise are available on glibc system headers

Alter the error API to match posix version
use qsort instead of qsort_r which is glibc specific API

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Upstream-Status: Inappropriate [workaround for musl]
--- a/src/arlib.h
+++ b/src/arlib.h
@@ -29,6 +29,12 @@
 #include <stdint.h>
 #include <sys/types.h>
 
+#if !defined(ALLPERMS)
+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
+#endif
+#if !defined(DEFFILEMODE)
+# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
+#endif
 
 /* State of -D/-U flags.  */
 extern bool arlib_deterministic_output;
--- a/src/elfcompress.c
+++ b/src/elfcompress.c
@@ -37,6 +37,13 @@
 #include "libeu.h"
 #include "printversion.h"
 
+#if !defined(ALLPERMS)
+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
+#endif
+#if !defined(FNM_EXTMATCH)
+# define FNM_EXTMATCH (0)
+#endif
+
 /* Name and version of program.  */
 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
 
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -4792,10 +4792,11 @@ listptr_base (struct listptr *p)
   return cudie_base (&cu);
 }
 
+static const char *listptr_name;
+
 static int
-compare_listptr (const void *a, const void *b, void *arg)
+compare_listptr (const void *a, const void *b)
 {
-  const char *name = arg;
   struct listptr *p1 = (void *) a;
   struct listptr *p2 = (void *) b;
 
@@ -4811,21 +4812,21 @@ compare_listptr (const void *a, const vo
 	  p1->warned = p2->warned = true;
 	  error (0, 0,
 		 gettext ("%s %#" PRIx64 " used with different address sizes"),
-		 name, (uint64_t) p1->offset);
+		 listptr_name, (uint64_t) p1->offset);
 	}
       if (p1->dwarf64 != p2->dwarf64)
 	{
 	  p1->warned = p2->warned = true;
 	  error (0, 0,
 		 gettext ("%s %#" PRIx64 " used with different offset sizes"),
-		 name, (uint64_t) p1->offset);
+		 listptr_name, (uint64_t) p1->offset);
 	}
       if (listptr_base (p1) != listptr_base (p2))
 	{
 	  p1->warned = p2->warned = true;
 	  error (0, 0,
 		 gettext ("%s %#" PRIx64 " used with different base addresses"),
-		 name, (uint64_t) p1->offset);
+		 listptr_name, (uint64_t) p1->offset);
 	}
       if (p1->attr != p2 ->attr)
 	{
@@ -4833,7 +4834,7 @@ compare_listptr (const void *a, const vo
 	  error (0, 0,
 		 gettext ("%s %#" PRIx64
 			  " used with different attribute %s and %s"),
-		 name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
+		 listptr_name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
 		 dwarf_attr_name (p2->attr));
 	}
     }
@@ -4905,8 +4906,11 @@ static void
 sort_listptr (struct listptr_table *table, const char *name)
 {
   if (table->n > 0)
-    qsort_r (table->table, table->n, sizeof table->table[0],
-	     &compare_listptr, (void *) name);
+    {
+      listptr_name = name;
+      qsort (table->table, table->n, sizeof table->table[0],
+	    &compare_listptr);
+    }
 }
 
 static bool
--- a/src/strip.c
+++ b/src/strip.c
@@ -46,6 +46,13 @@
 #include <system.h>
 #include <printversion.h>
 
+#if !defined(ACCESSPERMS)
+# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
+#endif
+#if !defined(FNM_EXTMATCH)
+# define FNM_EXTMATCH (0)
+#endif
+
 typedef uint8_t GElf_Byte;
 
 /* Name and version of program.  */
--- a/src/unstrip.c
+++ b/src/unstrip.c
@@ -56,6 +56,15 @@
 # define _(str) gettext (str)
 #endif
 
+#ifndef strndupa
+#define strndupa(s, n) \
+       ({const char *__in = (s); \
+         size_t __len = strnlen (__in, (n)) + 1; \
+         char *__out = (char *) alloca (__len); \
+         __out[__len-1] = '\0'; \
+         (char *) memcpy (__out, __in, __len-1);})
+#endif
+
 /* Name and version of program.  */
 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;