Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1 | From 990d377a92f4bab04bf6820fc81b3dcb6cf5e31d Mon Sep 17 00:00:00 2001 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2 | From: Khem Raj <raj.khem@gmail.com> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 3 | Date: Mon, 2 Jul 2018 09:52:23 +0800 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 4 | Subject: [PATCH] build: Provide alternatives for glibc assumptions helps |
| 5 | compiling it on musl |
| 6 | |
| 7 | Upstream-Status: Pending |
| 8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 9 | |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 10 | Rebase to 0.175 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 11 | |
| 12 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 13 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 14 | --- |
| 15 | Makefile.am | 2 +- |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 16 | lib/fixedsizehash.h | 1 - |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 17 | lib/system.h | 12 +++++++++++- |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 18 | libdw/Makefile.am | 3 ++- |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 19 | libdwfl/dwfl_build_id_find_elf.c | 1 + |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 20 | libdwfl/dwfl_error.c | 4 +++- |
| 21 | libdwfl/dwfl_module_getdwarf.c | 1 + |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 22 | libdwfl/libdwfl_crc32_file.c | 9 +++++++++ |
| 23 | libdwfl/linux-kernel-modules.c | 1 + |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 24 | libelf/elf.h | 8 ++++++-- |
| 25 | libelf/libelf.h | 1 + |
| 26 | libelf/libelfP.h | 1 + |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 27 | 12 files changed, 37 insertions(+), 7 deletions(-) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 28 | |
| 29 | diff --git a/Makefile.am b/Makefile.am |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 30 | index 2ff444e..41f77df 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 31 | --- a/Makefile.am |
| 32 | +++ b/Makefile.am |
| 33 | @@ -28,7 +28,7 @@ pkginclude_HEADERS = version.h |
| 34 | |
| 35 | # Add doc back when we have some real content. |
| 36 | SUBDIRS = config m4 lib libelf libebl libdwelf libdwfl libdw libcpu libasm \ |
| 37 | - backends src po tests |
| 38 | + backends po tests |
| 39 | |
| 40 | EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \ |
| 41 | COPYING COPYING-GPLV2 COPYING-LGPLV3 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 42 | diff --git a/lib/fixedsizehash.h b/lib/fixedsizehash.h |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 43 | index dac2a5f..43016fc 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 44 | --- a/lib/fixedsizehash.h |
| 45 | +++ b/lib/fixedsizehash.h |
| 46 | @@ -30,7 +30,6 @@ |
| 47 | #include <errno.h> |
| 48 | #include <stdlib.h> |
| 49 | #include <string.h> |
| 50 | -#include <sys/cdefs.h> |
| 51 | |
| 52 | #include <system.h> |
| 53 | |
| 54 | diff --git a/lib/system.h b/lib/system.h |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 55 | index 292082b..308a762 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 56 | --- a/lib/system.h |
| 57 | +++ b/lib/system.h |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 58 | @@ -30,7 +30,7 @@ |
| 59 | #define LIB_SYSTEM_H 1 |
| 60 | |
| 61 | #include <errno.h> |
| 62 | -#include <error.h> |
| 63 | +#include <err.h> |
| 64 | #include <stddef.h> |
| 65 | #include <stdint.h> |
| 66 | #include <sys/param.h> |
Brad Bishop | 393846f | 2019-05-20 12:24:11 -0400 | [diff] [blame] | 67 | @@ -51,6 +51,8 @@ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 68 | #else |
| 69 | # error "Unknown byte order" |
| 70 | #endif |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 71 | + |
| 72 | +#define error(status, errno, ...) err(status, __VA_ARGS__) |
| 73 | |
| 74 | #ifndef MAX |
| 75 | #define MAX(m, n) ((m) < (n) ? (n) : (m)) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 76 | diff --git a/libdw/Makefile.am b/libdw/Makefile.am |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 77 | index 7a3d532..7ac1241 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 78 | --- a/libdw/Makefile.am |
| 79 | +++ b/libdw/Makefile.am |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 80 | @@ -108,7 +108,8 @@ am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 81 | libdw_so_LIBS = libdw_pic.a ../libdwelf/libdwelf_pic.a \ |
| 82 | ../libdwfl/libdwfl_pic.a ../libebl/libebl.a |
| 83 | libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so |
| 84 | -libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS) |
| 85 | +fts_LDADD = -lfts |
| 86 | +libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS) $(fts_LDADD) |
| 87 | libdw_so_SOURCES = |
| 88 | libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS) |
| 89 | # The rpath is necessary for libebl because its $ORIGIN use will |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 90 | diff --git a/libdwfl/dwfl_build_id_find_elf.c b/libdwfl/dwfl_build_id_find_elf.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 91 | index cc6c3f6..b06ab59 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 92 | --- a/libdwfl/dwfl_build_id_find_elf.c |
| 93 | +++ b/libdwfl/dwfl_build_id_find_elf.c |
| 94 | @@ -31,6 +31,7 @@ |
| 95 | #endif |
| 96 | |
| 97 | #include "libdwflP.h" |
| 98 | +#include "system.h" |
| 99 | #include <inttypes.h> |
| 100 | #include <fcntl.h> |
| 101 | #include <unistd.h> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 102 | diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 103 | index 7bcf61c..c345797 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 104 | --- a/libdwfl/dwfl_error.c |
| 105 | +++ b/libdwfl/dwfl_error.c |
| 106 | @@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error) |
| 107 | const char * |
| 108 | dwfl_errmsg (int error) |
| 109 | { |
| 110 | + static __thread char s[64] = ""; |
| 111 | if (error == 0 || error == -1) |
| 112 | { |
| 113 | int last_error = global_error; |
| 114 | @@ -154,7 +155,8 @@ dwfl_errmsg (int error) |
| 115 | switch (error &~ 0xffff) |
| 116 | { |
| 117 | case OTHER_ERROR (ERRNO): |
| 118 | - return strerror_r (error & 0xffff, "bad", 0); |
| 119 | + strerror_r (error & 0xffff, s, sizeof(s)); |
| 120 | + return s; |
| 121 | case OTHER_ERROR (LIBELF): |
| 122 | return elf_errmsg (error & 0xffff); |
| 123 | case OTHER_ERROR (LIBDW): |
| 124 | diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 125 | index 56e6105..f4a0649 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 126 | --- a/libdwfl/dwfl_module_getdwarf.c |
| 127 | +++ b/libdwfl/dwfl_module_getdwarf.c |
| 128 | @@ -35,6 +35,7 @@ |
| 129 | #include <fcntl.h> |
| 130 | #include <string.h> |
| 131 | #include <unistd.h> |
| 132 | +#include "system.h" |
| 133 | #include "../libdw/libdwP.h" /* DWARF_E_* values are here. */ |
| 134 | #include "../libelf/libelfP.h" |
| 135 | #include "system.h" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 136 | diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 137 | index 360e4ee..b5aa397 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 138 | --- a/libdwfl/linux-kernel-modules.c |
| 139 | +++ b/libdwfl/linux-kernel-modules.c |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 140 | @@ -41,6 +41,7 @@ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 141 | |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 142 | #include "libelfP.h" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 143 | #include "libdwflP.h" |
| 144 | +#include "system.h" |
| 145 | #include <inttypes.h> |
| 146 | #include <errno.h> |
| 147 | #include <stdio.h> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 148 | diff --git a/libelf/elf.h b/libelf/elf.h |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 149 | index 5dc632b..14da1b7 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 150 | --- a/libelf/elf.h |
| 151 | +++ b/libelf/elf.h |
| 152 | @@ -21,7 +21,9 @@ |
| 153 | |
| 154 | #include <features.h> |
| 155 | |
| 156 | -__BEGIN_DECLS |
| 157 | +#ifdef __cplusplus |
| 158 | +extern "C" { |
| 159 | +#endif |
| 160 | |
| 161 | /* Standard ELF types. */ |
| 162 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 163 | @@ -3937,6 +3939,8 @@ enum |
| 164 | #define R_METAG_TLS_LE_HI16 60 |
| 165 | #define R_METAG_TLS_LE_LO16 61 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 166 | |
| 167 | -__END_DECLS |
| 168 | +#ifdef __cplusplus |
| 169 | +} |
| 170 | +#endif |
| 171 | |
| 172 | #endif /* elf.h */ |
| 173 | diff --git a/libelf/libelf.h b/libelf/libelf.h |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 174 | index 1ff11c9..c21e018 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 175 | --- a/libelf/libelf.h |
| 176 | +++ b/libelf/libelf.h |
| 177 | @@ -29,6 +29,7 @@ |
| 178 | #ifndef _LIBELF_H |
| 179 | #define _LIBELF_H 1 |
| 180 | |
| 181 | +#include <fcntl.h> |
| 182 | #include <stdint.h> |
| 183 | #include <sys/types.h> |
| 184 | |
| 185 | diff --git a/libelf/libelfP.h b/libelf/libelfP.h |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 186 | index 9f3e8e9..10a347a 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 187 | --- a/libelf/libelfP.h |
| 188 | +++ b/libelf/libelfP.h |
| 189 | @@ -32,6 +32,7 @@ |
| 190 | |
| 191 | #include <ar.h> |
| 192 | #include <gelf.h> |
| 193 | +#include <libelf.h> |
| 194 | |
| 195 | #include <errno.h> |
| 196 | #include <stdbool.h> |