Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 1 | Provide missing defines which otherwise are available on glibc system headers |
| 2 | |
| 3 | Alter the error API to match posix version |
| 4 | use qsort instead of qsort_r which is glibc specific API |
| 5 | |
| 6 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 7 | Upstream-Status: Inappropriate [workaround for musl] |
| 8 | --- a/src/arlib.h |
| 9 | +++ b/src/arlib.h |
| 10 | @@ -29,6 +29,12 @@ |
| 11 | #include <stdint.h> |
| 12 | #include <sys/types.h> |
| 13 | |
| 14 | +#if !defined(ALLPERMS) |
| 15 | +# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */ |
| 16 | +#endif |
| 17 | +#if !defined(DEFFILEMODE) |
| 18 | +# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/ |
| 19 | +#endif |
| 20 | |
| 21 | /* State of -D/-U flags. */ |
| 22 | extern bool arlib_deterministic_output; |
| 23 | --- a/src/elfcompress.c |
| 24 | +++ b/src/elfcompress.c |
| 25 | @@ -37,6 +37,13 @@ |
| 26 | #include "libeu.h" |
| 27 | #include "printversion.h" |
| 28 | |
| 29 | +#if !defined(ALLPERMS) |
| 30 | +# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */ |
| 31 | +#endif |
| 32 | +#if !defined(FNM_EXTMATCH) |
| 33 | +# define FNM_EXTMATCH (0) |
| 34 | +#endif |
| 35 | + |
| 36 | /* Name and version of program. */ |
| 37 | ARGP_PROGRAM_VERSION_HOOK_DEF = print_version; |
| 38 | |
| 39 | --- a/src/readelf.c |
| 40 | +++ b/src/readelf.c |
| 41 | @@ -4792,10 +4792,11 @@ listptr_base (struct listptr *p) |
| 42 | return cudie_base (&cu); |
| 43 | } |
| 44 | |
| 45 | +static const char *listptr_name; |
| 46 | + |
| 47 | static int |
| 48 | -compare_listptr (const void *a, const void *b, void *arg) |
| 49 | +compare_listptr (const void *a, const void *b) |
| 50 | { |
| 51 | - const char *name = arg; |
| 52 | struct listptr *p1 = (void *) a; |
| 53 | struct listptr *p2 = (void *) b; |
| 54 | |
| 55 | @@ -4811,21 +4812,21 @@ compare_listptr (const void *a, const vo |
| 56 | p1->warned = p2->warned = true; |
| 57 | error (0, 0, |
| 58 | gettext ("%s %#" PRIx64 " used with different address sizes"), |
| 59 | - name, (uint64_t) p1->offset); |
| 60 | + listptr_name, (uint64_t) p1->offset); |
| 61 | } |
| 62 | if (p1->dwarf64 != p2->dwarf64) |
| 63 | { |
| 64 | p1->warned = p2->warned = true; |
| 65 | error (0, 0, |
| 66 | gettext ("%s %#" PRIx64 " used with different offset sizes"), |
| 67 | - name, (uint64_t) p1->offset); |
| 68 | + listptr_name, (uint64_t) p1->offset); |
| 69 | } |
| 70 | if (listptr_base (p1) != listptr_base (p2)) |
| 71 | { |
| 72 | p1->warned = p2->warned = true; |
| 73 | error (0, 0, |
| 74 | gettext ("%s %#" PRIx64 " used with different base addresses"), |
| 75 | - name, (uint64_t) p1->offset); |
| 76 | + listptr_name, (uint64_t) p1->offset); |
| 77 | } |
| 78 | if (p1->attr != p2 ->attr) |
| 79 | { |
| 80 | @@ -4833,7 +4834,7 @@ compare_listptr (const void *a, const vo |
| 81 | error (0, 0, |
| 82 | gettext ("%s %#" PRIx64 |
| 83 | " used with different attribute %s and %s"), |
| 84 | - name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr), |
| 85 | + listptr_name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr), |
| 86 | dwarf_attr_name (p2->attr)); |
| 87 | } |
| 88 | } |
| 89 | @@ -4905,8 +4906,11 @@ static void |
| 90 | sort_listptr (struct listptr_table *table, const char *name) |
| 91 | { |
| 92 | if (table->n > 0) |
| 93 | - qsort_r (table->table, table->n, sizeof table->table[0], |
| 94 | - &compare_listptr, (void *) name); |
| 95 | + { |
| 96 | + listptr_name = name; |
| 97 | + qsort (table->table, table->n, sizeof table->table[0], |
| 98 | + &compare_listptr); |
| 99 | + } |
| 100 | } |
| 101 | |
| 102 | static bool |
| 103 | --- a/src/strip.c |
| 104 | +++ b/src/strip.c |
| 105 | @@ -46,6 +46,13 @@ |
| 106 | #include <system.h> |
| 107 | #include <printversion.h> |
| 108 | |
| 109 | +#if !defined(ACCESSPERMS) |
| 110 | +# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */ |
| 111 | +#endif |
| 112 | +#if !defined(FNM_EXTMATCH) |
| 113 | +# define FNM_EXTMATCH (0) |
| 114 | +#endif |
| 115 | + |
| 116 | typedef uint8_t GElf_Byte; |
| 117 | |
| 118 | /* Name and version of program. */ |
| 119 | --- a/src/unstrip.c |
| 120 | +++ b/src/unstrip.c |
| 121 | @@ -56,6 +56,15 @@ |
| 122 | # define _(str) gettext (str) |
| 123 | #endif |
| 124 | |
| 125 | +#ifndef strndupa |
| 126 | +#define strndupa(s, n) \ |
| 127 | + ({const char *__in = (s); \ |
| 128 | + size_t __len = strnlen (__in, (n)) + 1; \ |
| 129 | + char *__out = (char *) alloca (__len); \ |
| 130 | + __out[__len-1] = '\0'; \ |
| 131 | + (char *) memcpy (__out, __in, __len-1);}) |
| 132 | +#endif |
| 133 | + |
| 134 | /* Name and version of program. */ |
| 135 | ARGP_PROGRAM_VERSION_HOOK_DEF = print_version; |
| 136 | |