summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2019-07-20 11:00:57 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-07-23 22:26:28 +0100
commitd5b73bdb45c906cfbcfc395d191537a0a7b4ff38 (patch)
tree8a151075dd66ccbf6b48480bd004fb5dc9c53b56
parent002c33a38f87c19bd68d58d936a8d822bcf484f8 (diff)
downloadpoky-d5b73bdb45c906cfbcfc395d191537a0a7b4ff38.tar.gz
elfutils: Fix eu-* utils builds for musl
Re-organize the musl patches in three different areas namely libs, utils and tests, this will help maintain them in future version bumps Add obstack dependency on musl targets which is needed for eu-* PN and PN-binutils is not empty anymore on musl (From OE-Core rev: a747239978e63f22d4107e6e12c75b5f78043cce) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-devtools/elfutils/elfutils_0.176.bb15
-rw-r--r--meta/recipes-devtools/elfutils/files/0001-fix-err-variable-and-function-conflicts.patch91
-rw-r--r--meta/recipes-devtools/elfutils/files/0008-build-Provide-alternatives-for-glibc-assumptions-hel.patch196
-rw-r--r--meta/recipes-devtools/elfutils/files/musl-libs.patch111
-rw-r--r--meta/recipes-devtools/elfutils/files/musl-obstack-fts.patch105
-rw-r--r--meta/recipes-devtools/elfutils/files/musl-tests.patch (renamed from meta/recipes-devtools/elfutils/files/musl.patch)0
-rw-r--r--meta/recipes-devtools/elfutils/files/musl-utils.patch136
7 files changed, 359 insertions, 295 deletions
diff --git a/meta/recipes-devtools/elfutils/elfutils_0.176.bb b/meta/recipes-devtools/elfutils/elfutils_0.176.bb
index 5b8049f531..75acf59d26 100644
--- a/meta/recipes-devtools/elfutils/elfutils_0.176.bb
+++ b/meta/recipes-devtools/elfutils/elfutils_0.176.bb
@@ -4,7 +4,7 @@ SECTION = "base"
4LICENSE = "GPLv2 & LGPLv3+ & GPLv3+" 4LICENSE = "GPLv2 & LGPLv3+ & GPLv3+"
5LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504" 5LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
6DEPENDS = "libtool bzip2 zlib virtual/libintl" 6DEPENDS = "libtool bzip2 zlib virtual/libintl"
7DEPENDS_append_libc-musl = " argp-standalone fts " 7DEPENDS_append_libc-musl = " argp-standalone fts musl-obstack "
8# The Debian patches below are from: 8# The Debian patches below are from:
9# http://ftp.de.debian.org/debian/pool/main/e/elfutils/elfutils_0.175-1.debian.tar.xz 9# http://ftp.de.debian.org/debian/pool/main/e/elfutils/elfutils_0.175-1.debian.tar.xz
10SRC_URI = "https://sourceware.org/elfutils/ftp/${PV}/${BP}.tar.bz2 \ 10SRC_URI = "https://sourceware.org/elfutils/ftp/${PV}/${BP}.tar.bz2 \
@@ -31,12 +31,13 @@ SRC_URI = "https://sourceware.org/elfutils/ftp/${PV}/${BP}.tar.bz2 \
31 file://0001-skip-the-test-when-gcc-not-deployed.patch \ 31 file://0001-skip-the-test-when-gcc-not-deployed.patch \
32 file://run-ptest \ 32 file://run-ptest \
33 file://ptest.patch \ 33 file://ptest.patch \
34 file://musl.patch \
35 " 34 "
36SRC_URI_append_libc-musl = " file://0008-build-Provide-alternatives-for-glibc-assumptions-hel.patch \ 35SRC_URI_append_libc-musl = " \
37 file://0001-fix-err-variable-and-function-conflicts.patch \ 36 file://musl-obstack-fts.patch \
38" 37 file://musl-libs.patch \
39 38 file://musl-utils.patch \
39 file://musl-tests.patch \
40 "
40SRC_URI[md5sum] = "077e4f49320cad82bf17a997068b1db9" 41SRC_URI[md5sum] = "077e4f49320cad82bf17a997068b1db9"
41SRC_URI[sha256sum] = "eb5747c371b0af0f71e86215a5ebb88728533c3a104a43d4231963f308cd1023" 42SRC_URI[sha256sum] = "eb5747c371b0af0f71e86215a5ebb88728533c3a104a43d4231963f308cd1023"
42 43
@@ -85,8 +86,6 @@ do_install_ptest() {
85EXTRA_OEMAKE_class-native = "" 86EXTRA_OEMAKE_class-native = ""
86EXTRA_OEMAKE_class-nativesdk = "" 87EXTRA_OEMAKE_class-nativesdk = ""
87 88
88ALLOW_EMPTY_${PN}_libc-musl = "1"
89
90BBCLASSEXTEND = "native nativesdk" 89BBCLASSEXTEND = "native nativesdk"
91 90
92# Package utilities separately 91# Package utilities separately
diff --git a/meta/recipes-devtools/elfutils/files/0001-fix-err-variable-and-function-conflicts.patch b/meta/recipes-devtools/elfutils/files/0001-fix-err-variable-and-function-conflicts.patch
deleted file mode 100644
index 433db133b2..0000000000
--- a/meta/recipes-devtools/elfutils/files/0001-fix-err-variable-and-function-conflicts.patch
+++ /dev/null
@@ -1,91 +0,0 @@
1From 2c50fe7068bd6911958c6d851aef88179e73bb21 Mon Sep 17 00:00:00 2001
2From: Mingli Yu <Mingli.Yu@windriver.com>
3Date: Tue, 16 Apr 2019 15:30:38 +0800
4Subject: [PATCH] fix err variable and function conflicts
5
6There comes below build failure with musl when
7ptest enabled.
8| In file included from ../../elfutils-0.176/tests/dwfl-proc-attach.c:33:
9| ../../elfutils-0.176/lib/system.h:63:35: error: called object 'err' is not a function or function pointer
10| #define error(status, errno, ...) err(status, __VA_ARGS__)
11| ^~~
12| ../../elfutils-0.176/tests/dwfl-proc-attach.c:92:5: note: in expansion of macro 'error'
13| error (-1, 0, "dwfl_linux_proc_attach pid %d: %s", pid,
14| ^~~~~
15| ../../elfutils-0.176/tests/dwfl-proc-attach.c:79:7: note: declared here
16| int err;
17| ^~~
18
19It is because there is no error.h in musl and
20the patch 0008-build-Provide-alternatives-for-glibc-assumptions-hel.patch
21has updated to use err.h to replace error.h
22and also added macro definiton as below when
23use musl.
24 #define error(status, errno, ...) err(status, __VA_ARGS__)
25
26And in err.h, there is below logic:
27_Noreturn void err(int, const char *, ...);
28
29But when ptest enabled, there comes below error
30as there is both variable and function defined
31to be err in tests/dwfl-proc-attach.c.
32So change the err variable's name to workaround
33the build failure with musl.
34
35Upstream-Status: Inappropriate [workaround in musl]
36
37Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
38---
39 tests/dwfl-proc-attach.c | 6 +++---
40 1 file changed, 3 insertions(+), 3 deletions(-)
41
42Index: elfutils-0.176/tests/dwfl-proc-attach.c
43===================================================================
44--- elfutils-0.176.orig/tests/dwfl-proc-attach.c
45+++ elfutils-0.176/tests/dwfl-proc-attach.c
46@@ -76,10 +76,10 @@ main (int argc __attribute__ ((unused)),
47 char **argv __attribute__ ((unused)))
48 {
49 /* Create two extra threads to iterate through. */
50- int err;
51- if ((err = pthread_create (&thread1, NULL, sleeper, NULL)) != 0)
52+ int err1;
53+ if ((err1 = pthread_create (&thread1, NULL, sleeper, NULL)) != 0)
54 error (-1, err, "Couldn't create thread1");
55- if ((err = pthread_create (&thread2, NULL, sleeper, NULL)) != 0)
56+ if ((err1 = pthread_create (&thread2, NULL, sleeper, NULL)) != 0)
57 error (-1, err, "Couldn't create thread2");
58
59 Dwfl *dwfl = dwfl_begin (&proc_callbacks);
60Index: elfutils-0.176/tests/backtrace.c
61===================================================================
62--- elfutils-0.176.orig/tests/backtrace.c
63+++ elfutils-0.176/tests/backtrace.c
64@@ -219,23 +219,23 @@ dump (Dwfl *dwfl)
65 {
66 ptrdiff_t ptrdiff = dwfl_getmodules (dwfl, dump_modules, NULL, 0);
67 assert (ptrdiff == 0);
68- bool err = false;
69+ bool err1 = false;
70 switch (dwfl_getthreads (dwfl, thread_callback, NULL))
71 {
72 case 0:
73 break;
74 case DWARF_CB_ABORT:
75- err = true;
76+ err1 = true;
77 break;
78 case -1:
79 error (0, 0, "dwfl_getthreads: %s", dwfl_errmsg (-1));
80- err = true;
81+ err1 = true;
82 break;
83 default:
84 abort ();
85 }
86 callback_verify (0, 0, 0, NULL, dwfl);
87- if (err)
88+ if (err1)
89 exit (EXIT_FAILURE);
90 }
91
diff --git a/meta/recipes-devtools/elfutils/files/0008-build-Provide-alternatives-for-glibc-assumptions-hel.patch b/meta/recipes-devtools/elfutils/files/0008-build-Provide-alternatives-for-glibc-assumptions-hel.patch
deleted file mode 100644
index 10cdac646c..0000000000
--- a/meta/recipes-devtools/elfutils/files/0008-build-Provide-alternatives-for-glibc-assumptions-hel.patch
+++ /dev/null
@@ -1,196 +0,0 @@
1From 990d377a92f4bab04bf6820fc81b3dcb6cf5e31d Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 2 Jul 2018 09:52:23 +0800
4Subject: [PATCH] build: Provide alternatives for glibc assumptions helps
5 compiling it on musl
6
7Upstream-Status: Pending
8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9
10Rebase to 0.175
11
12Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
13
14---
15 Makefile.am | 2 +-
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 ++++++--
25 libelf/libelf.h | 1 +
26 libelf/libelfP.h | 1 +
27 12 files changed, 37 insertions(+), 7 deletions(-)
28
29diff --git a/Makefile.am b/Makefile.am
30index 2ff444e..41f77df 100644
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
42diff --git a/lib/fixedsizehash.h b/lib/fixedsizehash.h
43index dac2a5f..43016fc 100644
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
54diff --git a/lib/system.h b/lib/system.h
55index 292082b..308a762 100644
56--- a/lib/system.h
57+++ b/lib/system.h
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>
67@@ -51,6 +51,8 @@
68 #else
69 # error "Unknown byte order"
70 #endif
71+
72+#define error(status, errno, ...) err(status, __VA_ARGS__)
73
74 #ifndef MAX
75 #define MAX(m, n) ((m) < (n) ? (n) : (m))
76diff --git a/libdw/Makefile.am b/libdw/Makefile.am
77index 7a3d532..7ac1241 100644
78--- a/libdw/Makefile.am
79+++ b/libdw/Makefile.am
80@@ -108,7 +108,8 @@ am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os)
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
90diff --git a/libdwfl/dwfl_build_id_find_elf.c b/libdwfl/dwfl_build_id_find_elf.c
91index cc6c3f6..b06ab59 100644
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>
102diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
103index 7bcf61c..c345797 100644
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):
124diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
125index 56e6105..f4a0649 100644
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"
136diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
137index 360e4ee..b5aa397 100644
138--- a/libdwfl/linux-kernel-modules.c
139+++ b/libdwfl/linux-kernel-modules.c
140@@ -41,6 +41,7 @@
141
142 #include "libelfP.h"
143 #include "libdwflP.h"
144+#include "system.h"
145 #include <inttypes.h>
146 #include <errno.h>
147 #include <stdio.h>
148diff --git a/libelf/elf.h b/libelf/elf.h
149index 5dc632b..14da1b7 100644
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
163@@ -3937,6 +3939,8 @@ enum
164 #define R_METAG_TLS_LE_HI16 60
165 #define R_METAG_TLS_LE_LO16 61
166
167-__END_DECLS
168+#ifdef __cplusplus
169+}
170+#endif
171
172 #endif /* elf.h */
173diff --git a/libelf/libelf.h b/libelf/libelf.h
174index 1ff11c9..c21e018 100644
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
185diff --git a/libelf/libelfP.h b/libelf/libelfP.h
186index 9f3e8e9..10a347a 100644
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>
diff --git a/meta/recipes-devtools/elfutils/files/musl-libs.patch b/meta/recipes-devtools/elfutils/files/musl-libs.patch
new file mode 100644
index 0000000000..51ca630ef8
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/musl-libs.patch
@@ -0,0 +1,111 @@
1Collection of fixes needed to compile libelf and other libraries
2provided by elfutils for musl targets
3
4error is glibc specific API, so this patch will mostly not accepted
5upstream given that elfutils has been closely tied to glibc
6
7Signed-off-by: Khem Raj <raj.khem@gmail.com>
8Upstream-Status: Inappropriate [workaround for musl]
9
10--- /dev/null
11+++ b/lib/error.h
12@@ -0,0 +1,27 @@
13+#ifndef _ERROR_H_
14+#define _ERROR_H_
15+
16+#include <stdarg.h>
17+#include <stdio.h>
18+#include <stdlib.h>
19+#include <string.h>
20+#include <errno.h>
21+
22+static unsigned int error_message_count = 0;
23+
24+static inline void error(int status, int errnum, const char* format, ...)
25+{
26+ va_list ap;
27+ fprintf(stderr, "%s: ", program_invocation_name);
28+ va_start(ap, format);
29+ vfprintf(stderr, format, ap);
30+ va_end(ap);
31+ if (errnum)
32+ fprintf(stderr, ": %s", strerror(errnum));
33+ fprintf(stderr, "\n");
34+ error_message_count++;
35+ if (status)
36+ exit(status);
37+}
38+
39+#endif /* _ERROR_H_ */
40--- a/lib/fixedsizehash.h
41+++ b/lib/fixedsizehash.h
42@@ -30,7 +30,6 @@
43 #include <errno.h>
44 #include <stdlib.h>
45 #include <string.h>
46-#include <sys/cdefs.h>
47
48 #include <system.h>
49
50--- a/lib/libeu.h
51+++ b/lib/libeu.h
52@@ -29,6 +29,7 @@
53 #ifndef LIBEU_H
54 #define LIBEU_H
55
56+#include "system.h"
57 #include <stddef.h>
58 #include <stdint.h>
59
60--- a/libdwfl/dwfl_error.c
61+++ b/libdwfl/dwfl_error.c
62@@ -154,7 +154,16 @@ dwfl_errmsg (int error)
63 switch (error &~ 0xffff)
64 {
65 case OTHER_ERROR (ERRNO):
66+#if defined(__GLIBC__)
67 return strerror_r (error & 0xffff, "bad", 0);
68+#else
69+ {
70+ static __thread char buf[128] = "";
71+ if (strerror_r (error & 0xffff, buf, sizeof(buf)) == 0)
72+ return buf;
73+ }
74+ return "strerror_r() failed";
75+#endif
76 case OTHER_ERROR (LIBELF):
77 return elf_errmsg (error & 0xffff);
78 case OTHER_ERROR (LIBDW):
79--- a/libdwfl/linux-kernel-modules.c
80+++ b/libdwfl/linux-kernel-modules.c
81@@ -50,6 +50,7 @@
82 #include <sys/utsname.h>
83 #include <fcntl.h>
84 #include <unistd.h>
85+#include "system.h"
86
87 /* If fts.h is included before config.h, its indirect inclusions may not
88 give us the right LFS aliases of these functions, so map them manually. */
89--- a/libelf/elf.h
90+++ b/libelf/elf.h
91@@ -21,7 +21,9 @@
92
93 #include <features.h>
94
95-__BEGIN_DECLS
96+#ifdef __cplusplus
97+extern "C" {
98+#endif
99
100 /* Standard ELF types. */
101
102@@ -3937,6 +3939,7 @@ enum
103 #define R_METAG_TLS_LE_HI16 60
104 #define R_METAG_TLS_LE_LO16 61
105
106-__END_DECLS
107-
108+#ifdef __cplusplus
109+}
110+#endif
111 #endif /* elf.h */
diff --git a/meta/recipes-devtools/elfutils/files/musl-obstack-fts.patch b/meta/recipes-devtools/elfutils/files/musl-obstack-fts.patch
new file mode 100644
index 0000000000..0fb7eb9236
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/musl-obstack-fts.patch
@@ -0,0 +1,105 @@
1Look for libfts and libobstack during configure, these
2libraries are external to libc when using musl, whereas
3on glibc these libraries are provided in libc itself.
4
5Signed-off-by: Khem Raj <raj.khem@gmail.com>
6Upstream-Status: Inappropriate [workaround for musl]
7--- a/configure.ac
8+++ b/configure.ac
9@@ -494,6 +494,60 @@ else
10 fi
11 AC_SUBST([argp_LDADD])
12
13+dnl Check if we have fts available from our libc
14+AC_LINK_IFELSE(
15+ [AC_LANG_PROGRAM(
16+ [#if !defined(__x86_64__)
17+ #undef _FILE_OFFSET_BITS
18+ #define _FILE_OFFSET_BITS 32
19+ #endif
20+ #include <fts.h>],
21+ [FTS* fts = 0; return fts_close(fts); return 0;]
22+ )],
23+ [libc_has_fts="true"],
24+ [libc_has_fts="false"]
25+)
26+
27+dnl If our libc doesn't provide fts, then test for libfts
28+if test "$libc_has_fts" = "false" ; then
29+ AC_MSG_WARN("libc does not have fts")
30+ AC_CHECK_LIB([fts], [fts_close], [have_fts="true"], [have_fts="false"])
31+
32+ if test "$have_fts" = "false"; then
33+ AC_MSG_ERROR("no libfts found")
34+ else
35+ fts_LDADD="-lfts"
36+ fi
37+else
38+ fts_LDADD=""
39+fi
40+AC_SUBST([fts_LDADD])
41+
42+dnl Check if we have obstack available from our libc
43+AC_LINK_IFELSE(
44+ [AC_LANG_PROGRAM(
45+ [#include <obstack.h>],
46+ [_obstack_begin(0, 0, 0, NULL, NULL); return 0;]
47+ )],
48+ [libc_has_obstack="true"],
49+ [libc_has_obstack="false"]
50+)
51+
52+dnl If our libc doesn't provide obstack, then test for libobstack
53+if test "$libc_has_obstack" = "false" ; then
54+ AC_MSG_WARN("libc does not have obstack")
55+ AC_CHECK_LIB([obstack], [_obstack_begin], [have_obstack="true"], [have_obstack="false"])
56+
57+ if test "$have_obstack" = "false"; then
58+ AC_MSG_ERROR("no libobstack found")
59+ else
60+ obstack_LDADD="-lobstack"
61+ fi
62+else
63+ obstack_LDADD=""
64+fi
65+AC_SUBST([obstack_LDADD])
66+
67 dnl The directories with content.
68
69 dnl Documentation.
70--- a/libdw/Makefile.am
71+++ b/libdw/Makefile.am
72@@ -108,7 +108,7 @@ am_libdw_pic_a_OBJECTS = $(libdw_a_SOURC
73 libdw_so_LIBS = libdw_pic.a ../libdwelf/libdwelf_pic.a \
74 ../libdwfl/libdwfl_pic.a ../libebl/libebl.a
75 libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
76-libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS)
77+libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(fts_LDADD) $(zip_LIBS)
78 libdw_so_SOURCES =
79 libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
80 # The rpath is necessary for libebl because its $ORIGIN use will
81--- a/src/Makefile.am
82+++ b/src/Makefile.am
83@@ -68,8 +68,8 @@ ar_no_Wstack_usage = yes
84 unstrip_no_Wstack_usage = yes
85
86 readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
87-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl \
88- $(demanglelib)
89+nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) \
90+ $(obstack_LDADD) -ldl $(demanglelib)
91 size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
92 strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl
93 elflint_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
94@@ -77,9 +77,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $
95 addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
96 elfcmp_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
97 objdump_LDADD = $(libasm) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
98-ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
99+ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LDADD)
100 strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
101-ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
102+ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LDADD)
103 unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl
104 stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl $(demanglelib)
105 elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
diff --git a/meta/recipes-devtools/elfutils/files/musl.patch b/meta/recipes-devtools/elfutils/files/musl-tests.patch
index be35791b1a..be35791b1a 100644
--- a/meta/recipes-devtools/elfutils/files/musl.patch
+++ b/meta/recipes-devtools/elfutils/files/musl-tests.patch
diff --git a/meta/recipes-devtools/elfutils/files/musl-utils.patch b/meta/recipes-devtools/elfutils/files/musl-utils.patch
new file mode 100644
index 0000000000..8e636bf660
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/musl-utils.patch
@@ -0,0 +1,136 @@
1Provide missing defines which otherwise are available on glibc system headers
2
3Alter the error API to match posix version
4use qsort instead of qsort_r which is glibc specific API
5
6Signed-off-by: Khem Raj <raj.khem@gmail.com>
7Upstream-Status: Inappropriate [workaround for musl]
8--- a/src/arlib.h
9+++ b/src/arlib.h
10@@ -29,6 +29,12 @@
11 #include <stdint.h>
12 #include <sys/types.h>
13
14+#if !defined(ALLPERMS)
15+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
16+#endif
17+#if !defined(DEFFILEMODE)
18+# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
19+#endif
20
21 /* State of -D/-U flags. */
22 extern bool arlib_deterministic_output;
23--- a/src/elfcompress.c
24+++ b/src/elfcompress.c
25@@ -37,6 +37,13 @@
26 #include "libeu.h"
27 #include "printversion.h"
28
29+#if !defined(ALLPERMS)
30+# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
31+#endif
32+#if !defined(FNM_EXTMATCH)
33+# define FNM_EXTMATCH (0)
34+#endif
35+
36 /* Name and version of program. */
37 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
38
39--- a/src/readelf.c
40+++ b/src/readelf.c
41@@ -4792,10 +4792,11 @@ listptr_base (struct listptr *p)
42 return cudie_base (&cu);
43 }
44
45+static const char *listptr_name;
46+
47 static int
48-compare_listptr (const void *a, const void *b, void *arg)
49+compare_listptr (const void *a, const void *b)
50 {
51- const char *name = arg;
52 struct listptr *p1 = (void *) a;
53 struct listptr *p2 = (void *) b;
54
55@@ -4811,21 +4812,21 @@ compare_listptr (const void *a, const vo
56 p1->warned = p2->warned = true;
57 error (0, 0,
58 gettext ("%s %#" PRIx64 " used with different address sizes"),
59- name, (uint64_t) p1->offset);
60+ listptr_name, (uint64_t) p1->offset);
61 }
62 if (p1->dwarf64 != p2->dwarf64)
63 {
64 p1->warned = p2->warned = true;
65 error (0, 0,
66 gettext ("%s %#" PRIx64 " used with different offset sizes"),
67- name, (uint64_t) p1->offset);
68+ listptr_name, (uint64_t) p1->offset);
69 }
70 if (listptr_base (p1) != listptr_base (p2))
71 {
72 p1->warned = p2->warned = true;
73 error (0, 0,
74 gettext ("%s %#" PRIx64 " used with different base addresses"),
75- name, (uint64_t) p1->offset);
76+ listptr_name, (uint64_t) p1->offset);
77 }
78 if (p1->attr != p2 ->attr)
79 {
80@@ -4833,7 +4834,7 @@ compare_listptr (const void *a, const vo
81 error (0, 0,
82 gettext ("%s %#" PRIx64
83 " used with different attribute %s and %s"),
84- name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
85+ listptr_name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
86 dwarf_attr_name (p2->attr));
87 }
88 }
89@@ -4905,8 +4906,11 @@ static void
90 sort_listptr (struct listptr_table *table, const char *name)
91 {
92 if (table->n > 0)
93- qsort_r (table->table, table->n, sizeof table->table[0],
94- &compare_listptr, (void *) name);
95+ {
96+ listptr_name = name;
97+ qsort (table->table, table->n, sizeof table->table[0],
98+ &compare_listptr);
99+ }
100 }
101
102 static bool
103--- a/src/strip.c
104+++ b/src/strip.c
105@@ -46,6 +46,13 @@
106 #include <system.h>
107 #include <printversion.h>
108
109+#if !defined(ACCESSPERMS)
110+# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
111+#endif
112+#if !defined(FNM_EXTMATCH)
113+# define FNM_EXTMATCH (0)
114+#endif
115+
116 typedef uint8_t GElf_Byte;
117
118 /* Name and version of program. */
119--- a/src/unstrip.c
120+++ b/src/unstrip.c
121@@ -56,6 +56,15 @@
122 # define _(str) gettext (str)
123 #endif
124
125+#ifndef strndupa
126+#define strndupa(s, n) \
127+ ({const char *__in = (s); \
128+ size_t __len = strnlen (__in, (n)) + 1; \
129+ char *__out = (char *) alloca (__len); \
130+ __out[__len-1] = '\0'; \
131+ (char *) memcpy (__out, __in, __len-1);})
132+#endif
133+
134 /* Name and version of program. */
135 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
136