Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame^] | 1 | From 0f4667f0bb4b000d74ade07e90bd690b7217a19d Mon Sep 17 00:00:00 2001 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 2 | From: Hongxu Jia <hongxu.jia@windriver.com> |
| 3 | Date: Fri, 23 Aug 2019 10:18:47 +0800 |
Andrew Geissler | 475cb72 | 2020-07-10 16:00:51 -0500 | [diff] [blame] | 4 | Subject: [PATCH] musl-libs |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 5 | |
| 6 | Collection of fixes needed to compile libelf and other libraries |
| 7 | provided by elfutils for musl targets |
| 8 | |
| 9 | error is glibc specific API, so this patch will mostly not accepted |
| 10 | upstream given that elfutils has been closely tied to glibc |
| 11 | |
| 12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 13 | Upstream-Status: Inappropriate [workaround for musl] |
| 14 | |
| 15 | Rebase to 0.177 |
| 16 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> |
| 17 | |
| 18 | --- |
| 19 | lib/error.h | 27 +++++++++++++++++++++++++++ |
| 20 | lib/fixedsizehash.h | 1 - |
| 21 | lib/libeu.h | 1 + |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 22 | libdwfl/linux-kernel-modules.c | 1 + |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 23 | libelf/elf.h | 7 +++++++ |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 24 | 5 files changed, 36 insertions(+), 1 deletion(-) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 25 | create mode 100644 lib/error.h |
| 26 | |
| 27 | diff --git a/lib/error.h b/lib/error.h |
| 28 | new file mode 100644 |
| 29 | index 0000000..ef06827 |
| 30 | --- /dev/null |
| 31 | +++ b/lib/error.h |
| 32 | @@ -0,0 +1,27 @@ |
| 33 | +#ifndef _ERROR_H_ |
| 34 | +#define _ERROR_H_ |
| 35 | + |
| 36 | +#include <stdarg.h> |
| 37 | +#include <stdio.h> |
| 38 | +#include <stdlib.h> |
| 39 | +#include <string.h> |
| 40 | +#include <errno.h> |
| 41 | + |
| 42 | +static unsigned int error_message_count = 0; |
| 43 | + |
| 44 | +static inline void error(int status, int errnum, const char* format, ...) |
| 45 | +{ |
| 46 | + va_list ap; |
| 47 | + fprintf(stderr, "%s: ", program_invocation_name); |
| 48 | + va_start(ap, format); |
| 49 | + vfprintf(stderr, format, ap); |
| 50 | + va_end(ap); |
| 51 | + if (errnum) |
| 52 | + fprintf(stderr, ": %s", strerror(errnum)); |
| 53 | + fprintf(stderr, "\n"); |
| 54 | + error_message_count++; |
| 55 | + if (status) |
| 56 | + exit(status); |
| 57 | +} |
| 58 | + |
| 59 | +#endif /* _ERROR_H_ */ |
| 60 | diff --git a/lib/fixedsizehash.h b/lib/fixedsizehash.h |
| 61 | index dac2a5f..43016fc 100644 |
| 62 | --- a/lib/fixedsizehash.h |
| 63 | +++ b/lib/fixedsizehash.h |
| 64 | @@ -30,7 +30,6 @@ |
| 65 | #include <errno.h> |
| 66 | #include <stdlib.h> |
| 67 | #include <string.h> |
| 68 | -#include <sys/cdefs.h> |
| 69 | |
| 70 | #include <system.h> |
| 71 | |
| 72 | diff --git a/lib/libeu.h b/lib/libeu.h |
| 73 | index ecb4d01..edc85e3 100644 |
| 74 | --- a/lib/libeu.h |
| 75 | +++ b/lib/libeu.h |
| 76 | @@ -29,6 +29,7 @@ |
| 77 | #ifndef LIBEU_H |
| 78 | #define LIBEU_H |
| 79 | |
| 80 | +#include "system.h" |
| 81 | #include <stddef.h> |
| 82 | #include <stdint.h> |
| 83 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 84 | diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame^] | 85 | index c0f8dfa..aa78033 100644 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 86 | --- a/libdwfl/linux-kernel-modules.c |
| 87 | +++ b/libdwfl/linux-kernel-modules.c |
| 88 | @@ -50,6 +50,7 @@ |
| 89 | #include <sys/utsname.h> |
| 90 | #include <fcntl.h> |
| 91 | #include <unistd.h> |
| 92 | +#include "system.h" |
| 93 | |
| 94 | /* If fts.h is included before config.h, its indirect inclusions may not |
| 95 | give us the right LFS aliases of these functions, so map them manually. */ |
| 96 | diff --git a/libelf/elf.h b/libelf/elf.h |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 97 | index 8e3e618..1353890 100644 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 98 | --- a/libelf/elf.h |
| 99 | +++ b/libelf/elf.h |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 100 | @@ -19,6 +19,10 @@ |
| 101 | #ifndef _ELF_H |
| 102 | #define _ELF_H 1 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 103 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 104 | +#ifdef __cplusplus |
| 105 | +extern "C" { |
| 106 | +#endif |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 107 | + |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 108 | /* Standard ELF types. */ |
| 109 | |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 110 | #include <stdint.h> |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 111 | @@ -4102,4 +4106,7 @@ enum |
Andrew Geissler | 475cb72 | 2020-07-10 16:00:51 -0500 | [diff] [blame] | 112 | #define R_ARC_TLS_LE_S9 0x4a |
| 113 | #define R_ARC_TLS_LE_32 0x4b |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 114 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 115 | +#ifdef __cplusplus |
| 116 | +} |
| 117 | +#endif |
| 118 | #endif /* elf.h */ |