rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | From 8a6cefcd35fb0ba6e12afc6611cfeb600865ca17 Mon Sep 17 00:00:00 2001 |
| 2 | From: Andre McCurdy <armccurdy@gmail.com> |
| 3 | Date: Wed, 27 Sep 2017 21:32:27 -0700 |
| 4 | Subject: [PATCH] musl build fixes |
| 5 | |
| 6 | Upstream-Status: Inappropriate [legacy version] |
| 7 | |
| 8 | Signed-off-by: Andre McCurdy <armccurdy@gmail.com> |
| 9 | --- |
| 10 | lib/fixedsizehash.h | 4 ++-- |
| 11 | lib/system.h | 11 +++++++++++ |
| 12 | libelf/elf.h | 8 ++++++-- |
| 13 | libelf/elf_begin.c | 4 ++-- |
| 14 | libelf/elf_getarsym.c | 2 +- |
| 15 | libelf/libelf.h | 1 + |
| 16 | 6 files changed, 23 insertions(+), 7 deletions(-) |
| 17 | |
| 18 | diff --git a/lib/fixedsizehash.h b/lib/fixedsizehash.h |
| 19 | index a686051..3118954 100644 |
| 20 | --- a/lib/fixedsizehash.h |
| 21 | +++ b/lib/fixedsizehash.h |
| 22 | @@ -51,12 +51,12 @@ |
| 23 | #include <errno.h> |
| 24 | #include <stdlib.h> |
| 25 | #include <string.h> |
| 26 | -#include <sys/cdefs.h> |
| 27 | #include <sys/param.h> |
| 28 | |
| 29 | #include <system.h> |
| 30 | |
| 31 | -#define CONCAT(t1,t2) __CONCAT (t1,t2) |
| 32 | +#define CONCAT1(x,y) x##y |
| 33 | +#define CONCAT(x,y) CONCAT1(x,y) |
| 34 | |
| 35 | /* Before including this file the following macros must be defined: |
| 36 | |
| 37 | diff --git a/lib/system.h b/lib/system.h |
| 38 | index 10b4734..a9cb35e 100644 |
| 39 | --- a/lib/system.h |
| 40 | +++ b/lib/system.h |
| 41 | @@ -52,6 +52,17 @@ |
| 42 | #include <stddef.h> |
| 43 | #include <stdint.h> |
| 44 | |
| 45 | +#ifndef TEMP_FAILURE_RETRY |
| 46 | +#define TEMP_FAILURE_RETRY(expression) \ |
| 47 | + (__extension__ \ |
| 48 | + ({ long int __result; \ |
| 49 | + do __result = (long int) (expression); \ |
| 50 | + while (__result == -1L && errno == EINTR); \ |
| 51 | + __result; })) |
| 52 | +#endif |
| 53 | + |
| 54 | +#define error(status, errno, ...) err(status, __VA_ARGS__) |
| 55 | + |
| 56 | extern void *xmalloc (size_t) __attribute__ ((__malloc__)); |
| 57 | extern void *xcalloc (size_t, size_t) __attribute__ ((__malloc__)); |
| 58 | extern void *xrealloc (void *, size_t) __attribute__ ((__malloc__)); |
| 59 | diff --git a/libelf/elf.h b/libelf/elf.h |
| 60 | index 4158764..6d9af96 100644 |
| 61 | --- a/libelf/elf.h |
| 62 | +++ b/libelf/elf.h |
| 63 | @@ -23,7 +23,9 @@ |
| 64 | |
| 65 | #include <features.h> |
| 66 | |
| 67 | -__BEGIN_DECLS |
| 68 | +#ifdef __cplusplus |
| 69 | +extern "C" { |
| 70 | +#endif |
| 71 | |
| 72 | /* Standard ELF types. */ |
| 73 | |
| 74 | @@ -2909,6 +2911,8 @@ typedef Elf32_Addr Elf32_Conflict; |
| 75 | #define R_M32R_NUM 256 /* Keep this the last entry. */ |
| 76 | |
| 77 | |
| 78 | -__END_DECLS |
| 79 | +#ifdef __cplusplus |
| 80 | +} |
| 81 | +#endif |
| 82 | |
| 83 | #endif /* elf.h */ |
| 84 | diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c |
| 85 | index 0b38991..9083736 100644 |
| 86 | --- a/libelf/elf_begin.c |
| 87 | +++ b/libelf/elf_begin.c |
| 88 | @@ -819,7 +819,7 @@ __libelf_next_arhdr_wrlock (elf) |
| 89 | } |
| 90 | |
| 91 | /* Copy the raw name over to a NUL terminated buffer. */ |
| 92 | - *((char *) __mempcpy (elf->state.ar.raw_name, ar_hdr->ar_name, 16)) = '\0'; |
| 93 | + *((char *) mempcpy (elf->state.ar.raw_name, ar_hdr->ar_name, 16)) = '\0'; |
| 94 | |
| 95 | elf_ar_hdr = &elf->state.ar.elf_ar_hdr; |
| 96 | |
| 97 | @@ -911,7 +911,7 @@ __libelf_next_arhdr_wrlock (elf) |
| 98 | const char *string = ar_hdr->FIELD; \ |
| 99 | if (ar_hdr->FIELD[sizeof (ar_hdr->FIELD) - 1] != ' ') \ |
| 100 | { \ |
| 101 | - *((char *) __mempcpy (buf, ar_hdr->FIELD, sizeof (ar_hdr->FIELD))) \ |
| 102 | + *((char *) mempcpy (buf, ar_hdr->FIELD, sizeof (ar_hdr->FIELD))) \ |
| 103 | = '\0'; \ |
| 104 | string = buf; \ |
| 105 | } \ |
| 106 | diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c |
| 107 | index 9ff7f29..74339ce 100644 |
| 108 | --- a/libelf/elf_getarsym.c |
| 109 | +++ b/libelf/elf_getarsym.c |
| 110 | @@ -257,7 +257,7 @@ elf_getarsym (elf, ptr) |
| 111 | else |
| 112 | arsym[cnt].as_off = file_data[cnt]; |
| 113 | arsym[cnt].as_hash = _dl_elf_hash (str_data); |
| 114 | - str_data = rawmemchr (str_data, '\0') + 1; |
| 115 | + str_data = memchr (str_data, '\0', SIZE_MAX) + 1; |
| 116 | } |
| 117 | /* At the end a special entry. */ |
| 118 | arsym[n].as_name = NULL; |
| 119 | diff --git a/libelf/libelf.h b/libelf/libelf.h |
| 120 | index b0b3a8d..ec15c43 100644 |
| 121 | --- a/libelf/libelf.h |
| 122 | +++ b/libelf/libelf.h |
| 123 | @@ -50,6 +50,7 @@ |
| 124 | #ifndef _LIBELF_H |
| 125 | #define _LIBELF_H 1 |
| 126 | |
| 127 | +#include <fcntl.h> |
| 128 | #include <sys/types.h> |
| 129 | |
| 130 | /* Get the ELF types. */ |
| 131 | -- |
| 132 | 1.9.1 |
| 133 | |