1 From 990d377a92f4bab04bf6820fc81b3dcb6cf5e31d Mon Sep 17 00:00:00 2001
2 From: Khem Raj <raj.khem@gmail.com>
3 Date: Mon, 2 Jul 2018 09:52:23 +0800
4 Subject: [PATCH] build: Provide alternatives for glibc assumptions helps
7 Upstream-Status: Pending
8 Signed-off-by: Khem Raj <raj.khem@gmail.com>
12 Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
16 lib/fixedsizehash.h | 1 -
17 lib/system.h | 12 +++++++++++-
18 libdw/Makefile.am | 3 ++-
19 libdwfl/dwfl_build_id_find_elf.c | 1 +
20 libdwfl/dwfl_error.c | 4 +++-
21 libdwfl/dwfl_module_getdwarf.c | 1 +
22 libdwfl/libdwfl_crc32_file.c | 9 +++++++++
23 libdwfl/linux-kernel-modules.c | 1 +
24 libelf/elf.h | 8 ++++++--
26 libelf/libelfP.h | 1 +
27 12 files changed, 37 insertions(+), 7 deletions(-)
29 diff --git a/Makefile.am b/Makefile.am
30 index 2ff444e..41f77df 100644
33 @@ -28,7 +28,7 @@ pkginclude_HEADERS = version.h
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
40 EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \
41 COPYING COPYING-GPLV2 COPYING-LGPLV3
42 diff --git a/lib/fixedsizehash.h b/lib/fixedsizehash.h
43 index dac2a5f..43016fc 100644
44 --- a/lib/fixedsizehash.h
45 +++ b/lib/fixedsizehash.h
50 -#include <sys/cdefs.h>
54 diff --git a/lib/system.h b/lib/system.h
55 index 292082b..308a762 100644
59 #define LIB_SYSTEM_H 1
66 #include <sys/param.h>
69 # error "Unknown byte order"
71 +#ifndef TEMP_FAILURE_RETRY
72 +#define TEMP_FAILURE_RETRY(expression) \
74 + ({ long int __result; \
75 + do __result = (long int) (expression); \
76 + while (__result == -1L && errno == EINTR); \
80 +#define error(status, errno, ...) err(status, __VA_ARGS__)
83 #define MAX(m, n) ((m) < (n) ? (n) : (m))
84 diff --git a/libdw/Makefile.am b/libdw/Makefile.am
85 index 7a3d532..7ac1241 100644
86 --- a/libdw/Makefile.am
87 +++ b/libdw/Makefile.am
88 @@ -108,7 +108,8 @@ am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os)
89 libdw_so_LIBS = libdw_pic.a ../libdwelf/libdwelf_pic.a \
90 ../libdwfl/libdwfl_pic.a ../libebl/libebl.a
91 libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
92 -libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS)
94 +libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS) $(fts_LDADD)
96 libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
97 # The rpath is necessary for libebl because its $ORIGIN use will
98 diff --git a/libdwfl/dwfl_build_id_find_elf.c b/libdwfl/dwfl_build_id_find_elf.c
99 index cc6c3f6..b06ab59 100644
100 --- a/libdwfl/dwfl_build_id_find_elf.c
101 +++ b/libdwfl/dwfl_build_id_find_elf.c
105 #include "libdwflP.h"
107 #include <inttypes.h>
110 diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
111 index 7bcf61c..c345797 100644
112 --- a/libdwfl/dwfl_error.c
113 +++ b/libdwfl/dwfl_error.c
114 @@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error)
116 dwfl_errmsg (int error)
118 + static __thread char s[64] = "";
119 if (error == 0 || error == -1)
121 int last_error = global_error;
122 @@ -154,7 +155,8 @@ dwfl_errmsg (int error)
123 switch (error &~ 0xffff)
125 case OTHER_ERROR (ERRNO):
126 - return strerror_r (error & 0xffff, "bad", 0);
127 + strerror_r (error & 0xffff, s, sizeof(s));
129 case OTHER_ERROR (LIBELF):
130 return elf_errmsg (error & 0xffff);
131 case OTHER_ERROR (LIBDW):
132 diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
133 index 56e6105..f4a0649 100644
134 --- a/libdwfl/dwfl_module_getdwarf.c
135 +++ b/libdwfl/dwfl_module_getdwarf.c
141 #include "../libdw/libdwP.h" /* DWARF_E_* values are here. */
142 #include "../libelf/libelfP.h"
144 diff --git a/libdwfl/libdwfl_crc32_file.c b/libdwfl/libdwfl_crc32_file.c
145 index f849128..6f0aca1 100644
146 --- a/libdwfl/libdwfl_crc32_file.c
147 +++ b/libdwfl/libdwfl_crc32_file.c
152 +#ifndef TEMP_FAILURE_RETRY
153 +#define TEMP_FAILURE_RETRY(expression) \
155 + ({ long int __result; \
156 + do __result = (long int) (expression); \
157 + while (__result == -1L && errno == EINTR); \
161 #define crc32_file attribute_hidden __libdwfl_crc32_file
162 #define crc32 __libdwfl_crc32
163 #include <libdwflP.h>
164 diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
165 index 360e4ee..b5aa397 100644
166 --- a/libdwfl/linux-kernel-modules.c
167 +++ b/libdwfl/linux-kernel-modules.c
171 #include "libdwflP.h"
173 #include <inttypes.h>
176 diff --git a/libelf/elf.h b/libelf/elf.h
177 index 5dc632b..14da1b7 100644
182 #include <features.h>
189 /* Standard ELF types. */
191 @@ -3937,6 +3939,8 @@ enum
192 #define R_METAG_TLS_LE_HI16 60
193 #define R_METAG_TLS_LE_LO16 61
201 diff --git a/libelf/libelf.h b/libelf/libelf.h
202 index 1ff11c9..c21e018 100644
203 --- a/libelf/libelf.h
204 +++ b/libelf/libelf.h
211 #include <sys/types.h>
213 diff --git a/libelf/libelfP.h b/libelf/libelfP.h
214 index 9f3e8e9..10a347a 100644
215 --- a/libelf/libelfP.h
216 +++ b/libelf/libelfP.h