summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/elfutils/files/0008-build-Provide-alternatives-for-glibc-assumptions-hel.patch
blob: 10cdac646c42d153005c835494f4943dd4577033 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
From 990d377a92f4bab04bf6820fc81b3dcb6cf5e31d Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 2 Jul 2018 09:52:23 +0800
Subject: [PATCH] build: Provide alternatives for glibc assumptions helps
 compiling it on musl

Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>

Rebase to 0.175

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>

---
 Makefile.am                      |  2 +-
 lib/fixedsizehash.h              |  1 -
 lib/system.h                     | 12 +++++++++++-
 libdw/Makefile.am                |  3 ++-
 libdwfl/dwfl_build_id_find_elf.c |  1 +
 libdwfl/dwfl_error.c             |  4 +++-
 libdwfl/dwfl_module_getdwarf.c   |  1 +
 libdwfl/libdwfl_crc32_file.c     |  9 +++++++++
 libdwfl/linux-kernel-modules.c   |  1 +
 libelf/elf.h                     |  8 ++++++--
 libelf/libelf.h                  |  1 +
 libelf/libelfP.h                 |  1 +
 12 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 2ff444e..41f77df 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -28,7 +28,7 @@ pkginclude_HEADERS = version.h
 
 # Add doc back when we have some real content.
 SUBDIRS = config m4 lib libelf libebl libdwelf libdwfl libdw libcpu libasm \
-	  backends src po tests
+	  backends po tests
 
 EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \
 	     COPYING COPYING-GPLV2 COPYING-LGPLV3
diff --git a/lib/fixedsizehash.h b/lib/fixedsizehash.h
index dac2a5f..43016fc 100644
--- a/lib/fixedsizehash.h
+++ b/lib/fixedsizehash.h
@@ -30,7 +30,6 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/cdefs.h>
 
 #include <system.h>
 
diff --git a/lib/system.h b/lib/system.h
index 292082b..308a762 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -30,7 +30,7 @@
 #define LIB_SYSTEM_H	1
 
 #include <errno.h>
-#include <error.h>
+#include <err.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <sys/param.h>
@@ -51,6 +51,8 @@
 #else
 # error "Unknown byte order"
 #endif
+
+#define error(status, errno, ...) err(status, __VA_ARGS__)
 
 #ifndef MAX
 #define MAX(m, n) ((m) < (n) ? (n) : (m))
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 7a3d532..7ac1241 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -108,7 +108,8 @@ am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os)
 libdw_so_LIBS = libdw_pic.a ../libdwelf/libdwelf_pic.a \
 	  ../libdwfl/libdwfl_pic.a ../libebl/libebl.a
 libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
-libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS)
+fts_LDADD = -lfts
+libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS) $(fts_LDADD)
 libdw_so_SOURCES =
 libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
 # The rpath is necessary for libebl because its $ORIGIN use will
diff --git a/libdwfl/dwfl_build_id_find_elf.c b/libdwfl/dwfl_build_id_find_elf.c
index cc6c3f6..b06ab59 100644
--- a/libdwfl/dwfl_build_id_find_elf.c
+++ b/libdwfl/dwfl_build_id_find_elf.c
@@ -31,6 +31,7 @@
 #endif
 
 #include "libdwflP.h"
+#include "system.h"
 #include <inttypes.h>
 #include <fcntl.h>
 #include <unistd.h>
diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
index 7bcf61c..c345797 100644
--- a/libdwfl/dwfl_error.c
+++ b/libdwfl/dwfl_error.c
@@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error)
 const char *
 dwfl_errmsg (int error)
 {
+  static __thread char s[64] = "";
   if (error == 0 || error == -1)
     {
       int last_error = global_error;
@@ -154,7 +155,8 @@ dwfl_errmsg (int error)
   switch (error &~ 0xffff)
     {
     case OTHER_ERROR (ERRNO):
-      return strerror_r (error & 0xffff, "bad", 0);
+      strerror_r (error & 0xffff, s, sizeof(s));
+      return s;
     case OTHER_ERROR (LIBELF):
       return elf_errmsg (error & 0xffff);
     case OTHER_ERROR (LIBDW):
diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
index 56e6105..f4a0649 100644
--- a/libdwfl/dwfl_module_getdwarf.c
+++ b/libdwfl/dwfl_module_getdwarf.c
@@ -35,6 +35,7 @@
 #include <fcntl.h>
 #include <string.h>
 #include <unistd.h>
+#include "system.h"
 #include "../libdw/libdwP.h"	/* DWARF_E_* values are here.  */
 #include "../libelf/libelfP.h"
 #include "system.h"
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index 360e4ee..b5aa397 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -41,6 +41,7 @@
 
 #include "libelfP.h"
 #include "libdwflP.h"
+#include "system.h"
 #include <inttypes.h>
 #include <errno.h>
 #include <stdio.h>
diff --git a/libelf/elf.h b/libelf/elf.h
index 5dc632b..14da1b7 100644
--- a/libelf/elf.h
+++ b/libelf/elf.h
@@ -21,7 +21,9 @@
 
 #include <features.h>
 
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* Standard ELF types.  */
 
@@ -3937,6 +3939,8 @@ enum
 #define R_METAG_TLS_LE_HI16	60
 #define R_METAG_TLS_LE_LO16	61
 
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
 
 #endif	/* elf.h */
diff --git a/libelf/libelf.h b/libelf/libelf.h
index 1ff11c9..c21e018 100644
--- a/libelf/libelf.h
+++ b/libelf/libelf.h
@@ -29,6 +29,7 @@
 #ifndef _LIBELF_H
 #define _LIBELF_H 1
 
+#include <fcntl.h>
 #include <stdint.h>
 #include <sys/types.h>
 
diff --git a/libelf/libelfP.h b/libelf/libelfP.h
index 9f3e8e9..10a347a 100644
--- a/libelf/libelfP.h
+++ b/libelf/libelfP.h
@@ -32,6 +32,7 @@
 
 #include <ar.h>
 #include <gelf.h>
+#include <libelf.h>
 
 #include <errno.h>
 #include <stdbool.h>