Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 1 | From 94028b16e56c8eef1aa02dcc4da268a0e471b4ea 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/4] musl-utils |
| 5 | |
| 6 | Provide missing defines which otherwise are available on glibc system headers |
| 7 | |
| 8 | Alter the error API to match posix version |
| 9 | use qsort instead of qsort_r which is glibc specific API |
| 10 | |
| 11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 12 | Upstream-Status: Inappropriate [workaround for musl] |
| 13 | |
| 14 | Rebase to 0.177 |
| 15 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> |
| 16 | |
| 17 | --- |
| 18 | src/arlib.h | 6 ++++++ |
| 19 | src/elfcompress.c | 7 +++++++ |
| 20 | src/readelf.c | 20 ++++++++++++-------- |
| 21 | src/strip.c | 7 +++++++ |
| 22 | src/unstrip.c | 9 +++++++++ |
| 23 | 5 files changed, 41 insertions(+), 8 deletions(-) |
| 24 | |
| 25 | diff --git a/src/arlib.h b/src/arlib.h |
| 26 | index e117166..8326f6c 100644 |
| 27 | --- a/src/arlib.h |
| 28 | +++ b/src/arlib.h |
| 29 | @@ -29,6 +29,12 @@ |
| 30 | #include <stdint.h> |
| 31 | #include <sys/types.h> |
| 32 | |
| 33 | +#if !defined(ALLPERMS) |
| 34 | +# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */ |
| 35 | +#endif |
| 36 | +#if !defined(DEFFILEMODE) |
| 37 | +# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/ |
| 38 | +#endif |
| 39 | |
| 40 | /* State of -D/-U flags. */ |
| 41 | extern bool arlib_deterministic_output; |
| 42 | diff --git a/src/elfcompress.c b/src/elfcompress.c |
| 43 | index 6ba6af4..0c7674b 100644 |
| 44 | --- a/src/elfcompress.c |
| 45 | +++ b/src/elfcompress.c |
| 46 | @@ -37,6 +37,13 @@ |
| 47 | #include "libeu.h" |
| 48 | #include "printversion.h" |
| 49 | |
| 50 | +#if !defined(ALLPERMS) |
| 51 | +# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */ |
| 52 | +#endif |
| 53 | +#if !defined(FNM_EXTMATCH) |
| 54 | +# define FNM_EXTMATCH (0) |
| 55 | +#endif |
| 56 | + |
| 57 | /* Name and version of program. */ |
| 58 | ARGP_PROGRAM_VERSION_HOOK_DEF = print_version; |
| 59 | |
| 60 | diff --git a/src/readelf.c b/src/readelf.c |
| 61 | index 5994615..f3cc071 100644 |
| 62 | --- a/src/readelf.c |
| 63 | +++ b/src/readelf.c |
| 64 | @@ -4829,10 +4829,11 @@ listptr_base (struct listptr *p) |
| 65 | return cudie_base (&cu); |
| 66 | } |
| 67 | |
| 68 | +static const char *listptr_name; |
| 69 | + |
| 70 | static int |
| 71 | -compare_listptr (const void *a, const void *b, void *arg) |
| 72 | +compare_listptr (const void *a, const void *b) |
| 73 | { |
| 74 | - const char *name = arg; |
| 75 | struct listptr *p1 = (void *) a; |
| 76 | struct listptr *p2 = (void *) b; |
| 77 | |
| 78 | @@ -4848,21 +4849,21 @@ compare_listptr (const void *a, const void *b, void *arg) |
| 79 | p1->warned = p2->warned = true; |
| 80 | error (0, 0, |
| 81 | gettext ("%s %#" PRIx64 " used with different address sizes"), |
| 82 | - name, (uint64_t) p1->offset); |
| 83 | + listptr_name, (uint64_t) p1->offset); |
| 84 | } |
| 85 | if (p1->dwarf64 != p2->dwarf64) |
| 86 | { |
| 87 | p1->warned = p2->warned = true; |
| 88 | error (0, 0, |
| 89 | gettext ("%s %#" PRIx64 " used with different offset sizes"), |
| 90 | - name, (uint64_t) p1->offset); |
| 91 | + listptr_name, (uint64_t) p1->offset); |
| 92 | } |
| 93 | if (listptr_base (p1) != listptr_base (p2)) |
| 94 | { |
| 95 | p1->warned = p2->warned = true; |
| 96 | error (0, 0, |
| 97 | gettext ("%s %#" PRIx64 " used with different base addresses"), |
| 98 | - name, (uint64_t) p1->offset); |
| 99 | + listptr_name, (uint64_t) p1->offset); |
| 100 | } |
| 101 | if (p1->attr != p2 ->attr) |
| 102 | { |
| 103 | @@ -4870,7 +4871,7 @@ compare_listptr (const void *a, const void *b, void *arg) |
| 104 | error (0, 0, |
| 105 | gettext ("%s %#" PRIx64 |
| 106 | " used with different attribute %s and %s"), |
| 107 | - name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr), |
| 108 | + listptr_name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr), |
| 109 | dwarf_attr_name (p2->attr)); |
| 110 | } |
| 111 | } |
| 112 | @@ -4942,8 +4943,11 @@ static void |
| 113 | sort_listptr (struct listptr_table *table, const char *name) |
| 114 | { |
| 115 | if (table->n > 0) |
| 116 | - qsort_r (table->table, table->n, sizeof table->table[0], |
| 117 | - &compare_listptr, (void *) name); |
| 118 | + { |
| 119 | + listptr_name = name; |
| 120 | + qsort (table->table, table->n, sizeof table->table[0], |
| 121 | + &compare_listptr); |
| 122 | + } |
| 123 | } |
| 124 | |
| 125 | static bool |
| 126 | diff --git a/src/strip.c b/src/strip.c |
| 127 | index 4054c2a..d2d2176 100644 |
| 128 | --- a/src/strip.c |
| 129 | +++ b/src/strip.c |
| 130 | @@ -46,6 +46,13 @@ |
| 131 | #include <system.h> |
| 132 | #include <printversion.h> |
| 133 | |
| 134 | +#if !defined(ACCESSPERMS) |
| 135 | +# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */ |
| 136 | +#endif |
| 137 | +#if !defined(FNM_EXTMATCH) |
| 138 | +# define FNM_EXTMATCH (0) |
| 139 | +#endif |
| 140 | + |
| 141 | typedef uint8_t GElf_Byte; |
| 142 | |
| 143 | /* Name and version of program. */ |
| 144 | diff --git a/src/unstrip.c b/src/unstrip.c |
| 145 | index 9b8c09a..1fb5063 100644 |
| 146 | --- a/src/unstrip.c |
| 147 | +++ b/src/unstrip.c |
| 148 | @@ -56,6 +56,15 @@ |
| 149 | # define _(str) gettext (str) |
| 150 | #endif |
| 151 | |
| 152 | +#ifndef strndupa |
| 153 | +#define strndupa(s, n) \ |
| 154 | + ({const char *__in = (s); \ |
| 155 | + size_t __len = strnlen (__in, (n)) + 1; \ |
| 156 | + char *__out = (char *) alloca (__len); \ |
| 157 | + __out[__len-1] = '\0'; \ |
| 158 | + (char *) memcpy (__out, __in, __len-1);}) |
| 159 | +#endif |
| 160 | + |
| 161 | /* Name and version of program. */ |
| 162 | ARGP_PROGRAM_VERSION_HOOK_DEF = print_version; |
| 163 | |
| 164 | -- |
| 165 | 2.17.1 |
| 166 | |