summaryrefslogtreecommitdiff
path: root/experimental/elfutils
diff options
context:
space:
mode:
authorA. Wilcox <awilcox@wilcox-tech.com>2019-08-08 03:33:44 +0000
committerA. Wilcox <awilcox@wilcox-tech.com>2019-08-08 03:33:44 +0000
commitaddc96410e6eae47a28314aeaace3228bd70b9cd (patch)
tree3998870b58279b308d8ea678debce30da103dd5e /experimental/elfutils
parent6e8939f34d9bcc8294a64b64e5fce9ce16668070 (diff)
parent6722ef49445b3fbe7665fc487733a8710a98fb5f (diff)
downloadpackages-addc96410e6eae47a28314aeaace3228bd70b9cd.tar.gz
packages-addc96410e6eae47a28314aeaace3228bd70b9cd.tar.bz2
packages-addc96410e6eae47a28314aeaace3228bd70b9cd.tar.xz
packages-addc96410e6eae47a28314aeaace3228bd70b9cd.zip
Merge branch 'sr.2019.08.07' into 'master'
Misc changes, 2019.08.07 See merge request adelie/packages!315
Diffstat (limited to 'experimental/elfutils')
-rw-r--r--experimental/elfutils/APKBUILD90
-rw-r--r--experimental/elfutils/error.h29
-rw-r--r--experimental/elfutils/extmatch.patch24
-rw-r--r--experimental/elfutils/fix-aarch64_fregs.patch14
-rw-r--r--experimental/elfutils/fix-uninitialized.patch10
-rw-r--r--experimental/elfutils/musl-cdefs.patch23
-rw-r--r--experimental/elfutils/musl-fts-obstack.patch115
-rw-r--r--experimental/elfutils/musl-macros.patch66
-rw-r--r--experimental/elfutils/musl-qsort_r.patch65
-rw-r--r--experimental/elfutils/musl-strerror_r.patch19
-rw-r--r--experimental/elfutils/musl-strndupa.patch18
-rw-r--r--experimental/elfutils/test-disable-backtrace.patch59
-rw-r--r--experimental/elfutils/test-disable-biarch.patch9
13 files changed, 541 insertions, 0 deletions
diff --git a/experimental/elfutils/APKBUILD b/experimental/elfutils/APKBUILD
new file mode 100644
index 000000000..4a129216f
--- /dev/null
+++ b/experimental/elfutils/APKBUILD
@@ -0,0 +1,90 @@
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Max Rees <maxcrees@me.com>
+pkgname=elfutils
+pkgver=0.176
+pkgrel=0
+pkgdesc="A collection of utilities and DSOs to handle ELF files and DWARF data"
+url="https://sourceware.org/elfutils/"
+arch="all"
+license="GPL-3.0+ AND (GPL-2.0+ or LGPL-3.0+) AND LGPL-2.1+"
+depends=""
+makedepends="argp-standalone bsd-compat-headers bzip2-dev flex
+ fts-dev musl-obstack-dev xz-dev zlib-dev"
+subpackages="$pkgname-dev $pkgname-lang $pkgname-tools"
+source="https://sourceware.org/elfutils/ftp/$pkgver/$pkgname-$pkgver.tar.bz2
+ extmatch.patch
+ fix-aarch64_fregs.patch
+ fix-uninitialized.patch
+ musl-cdefs.patch
+ musl-fts-obstack.patch
+ musl-macros.patch
+ musl-qsort_r.patch
+ musl-strerror_r.patch
+ musl-strndupa.patch
+ test-disable-backtrace.patch
+ test-disable-biarch.patch
+ error.h"
+
+# Internal only - should not be exposed to other packages
+somask="libebl_aarch64-$pkgver.so
+ libebl_alpha-$pkgver.so
+ libebl_arm-$pkgver.so
+ libebl_bpf-$pkgver.so
+ libebl_i386-$pkgver.so
+ libebl_ia64-$pkgver.so
+ libebl_m68k-$pkgver.so
+ libebl_ppc-$pkgver.so
+ libebl_ppc64-$pkgver.so
+ libebl_riscv-$pkgver.so
+ libebl_s390-$pkgver.so
+ libebl_sh-$pkgver.so
+ libebl_sparc-$pkgver.so
+ libebl_tilegx-$pkgver.so
+ libebl_x86_64-$pkgver.so"
+
+prepare() {
+ default_prepare
+ autoreconf -vif
+ cp "$srcdir"/error.h lib
+ cp "$srcdir"/error.h src
+}
+
+build() {
+ export CFLAGS="$CFLAGS -Wno-error -g"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --localstatedir=/var
+ make
+}
+
+check() {
+ make check
+}
+
+package() {
+ make DESTDIR="$pkgdir" install
+}
+
+tools() {
+ pkgdesc="$pkgdesc (command-line tools)"
+ mkdir -p "$subpkgdir"/usr/bin
+ mv "$pkgdir"/usr/bin/eu-* "$subpkgdir"/usr/bin
+}
+
+sha512sums="7f032913be363a43229ded85d495dcf7542b3c85974aaaba0d984228dc9ac1721da3dc388d3fa02325a80940161db7e9ad2c9e4521a424ad8a7d050c0902915b elfutils-0.176.tar.bz2
+c3676b0b8b40d6e437f5d88c0d658dc0829ec97d1955e4bbf96f4cff9ee9001b8f2f06174450ae7aa5858b91c7905bdbd49073b561c346416132338a9c94731b fix-aarch64_fregs.patch
+8b421bc411fd240ada1d6f4010e222cb430bceebea613b79dc96d8244835b87272e9964f95c6ac54d054978fdc170f3b852606c207804df7fc261bb544f61c53 fix-uninitialized.patch
+3d8c7aee5d509486b680c1eb8903052060386520e8576068a8144019857933b86bd708c2a0a44c383667c4205888435402733dbd8ea0a88c32223a639b0404f0 extmatch.patch
+8c5c2fab616a01df7b57c9338122eb054503c0d76808d1914ae112106c2e73b9cef517719242b8ee3a78479e73e97187fe42d6e897e0b822e5a0a9e30b2246b9 musl-cdefs.patch
+7a22dc1a3423d1e4dd8f1ddbc5c1e1ee87db679d7b9fba0f7e695c207c9fefef5cacdee3d7c5b64ff2751a1d5b155751f0e77ee9af844048a32a8dd890623ef2 musl-fts-obstack.patch
+37a8cd13262115b64b51d47e9d5667185155d1b1159aa333ac34df7cc6d7d71d9c809a9fd99094e5f4102c6535a32f75159ac80f4986e029a0e2cd49b76884d3 musl-macros.patch
+38e5403d645fe2da4df9425c6a3fb00dc8ca8016ed86a19482de3d6a2e4200f3953e628b0a6bc33d3d3ce25733b7171ad887448e21981c0ae39343c163fdff41 musl-qsort_r.patch
+a0d986100c8ff2ef0595645ec1b2eeb1d517b7442aef5f349ebf27fcb66c76e51fadeda25bed5f04b4bb16a61aa23ac6e86a1f34a0087d2136acf0f64c3fa4d1 musl-strerror_r.patch
+83ad42f672e1d5ca479bc44166c423624ab14d70f74bd6f703ef5fd98694ae201db975026ae8bd507d87b038e3403d878c90da40cfcf6d2364bbd3cad8cedb5b musl-strndupa.patch
+edfeaad36b52997a43612b8bc2d26bcde7d2edb6b1b932e42f88a859c46747eb57a4ae963a98157e60d89f3d4f04efe50a69ea91cc0552cb5b0db17e8cc833c1 test-disable-backtrace.patch
+d3263c42b1638a416e95c2b8e68b15a9723e748490c8eca727da94bf7bb3dd8389222dd01bf69612ba45a20114ee1427d77935c41436d1ca9180fcfd71d3cdfe test-disable-biarch.patch
+b33d7f210b9652b7b919afb32b4674ca125b660bf5f81fafb4e4e8405ea16be74ce85f653e6c0ac83e5fff1b192e82e273c5b5baa3802fdc7602edfa1086936d error.h"
diff --git a/experimental/elfutils/error.h b/experimental/elfutils/error.h
new file mode 100644
index 000000000..8bae4c7db
--- /dev/null
+++ b/experimental/elfutils/error.h
@@ -0,0 +1,29 @@
+#ifndef _ERROR_H_
+#define _ERROR_H_
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+static unsigned int error_message_count = 0;
+
+static inline void error(int status, int errnum, const char* format, ...)
+{
+ va_list ap;
+ fflush(stdout);
+ fprintf(stderr, "%s: ", program_invocation_name);
+ va_start(ap, format);
+ vfprintf(stderr, format, ap);
+ va_end(ap);
+ if (errnum)
+ fprintf(stderr, ": %s", strerror(errnum));
+ fprintf(stderr, "\n");
+ error_message_count++;
+ if (status)
+ exit(status);
+ fflush(stderr);
+}
+
+#endif /* _ERROR_H_ */
diff --git a/experimental/elfutils/extmatch.patch b/experimental/elfutils/extmatch.patch
new file mode 100644
index 000000000..ea9d3653f
--- /dev/null
+++ b/experimental/elfutils/extmatch.patch
@@ -0,0 +1,24 @@
+--- elfutils-0.176/src/elfcompress.c 2019-02-15 15:46:47.000000000 +0000
++++ elfutils-0.176/src/elfcompress.c 2019-07-18 09:13:29.159806022 +0000
+@@ -134,8 +142,10 @@ parse_opt (int key, char *arg __attribut
+ case ARGP_KEY_SUCCESS:
+ if (type == T_UNSET)
+ type = T_COMPRESS_ZLIB;
+- if (patterns == NULL)
+- add_pattern (".?(z)debug*");
++ if (patterns == NULL) {
++ add_pattern (".debug*");
++ add_pattern (".zdebug*");
++ }
+ break;
+
+ case ARGP_KEY_NO_ARGS:
+@@ -1312,7 +1322,7 @@ main (int argc, char **argv)
+ N_("What type of compression to apply. TYPE can be 'none' (decompress), 'zlib' (ELF ZLIB compression, the default, 'zlib-gabi' is an alias) or 'zlib-gnu' (.zdebug GNU style compression, 'gnu' is an alias)"),
+ 0 },
+ { "name", 'n', "SECTION", 0,
+- N_("SECTION name to (de)compress, SECTION is an extended wildcard pattern (defaults to '.?(z)debug*')"),
++ N_("SECTION name to (de)compress, SECTION is an wildcard pattern (defaults to '.debug*' and '.zdebug*')"),
+ 0 },
+ { "verbose", 'v', NULL, 0,
+ N_("Print a message for each section being (de)compressed"),
diff --git a/experimental/elfutils/fix-aarch64_fregs.patch b/experimental/elfutils/fix-aarch64_fregs.patch
new file mode 100644
index 000000000..400741639
--- /dev/null
+++ b/experimental/elfutils/fix-aarch64_fregs.patch
@@ -0,0 +1,14 @@
+It looks like fregs.vregs[] is an array of double?
+Casting to Dwarf_Word instead of & 0xFFFFFFF should do.
+
+--- a/backends/aarch64_initreg.c 2015-11-27 14:36:29.000000000 +0100
++++ b/backends/aarch64_initreg.c 2016-08-09 03:47:25.428560159 +0200
+@@ -82,7 +82,7 @@
+
+ Dwarf_Word dwarf_fregs[32];
+ for (int r = 0; r < 32; r++)
+- dwarf_fregs[r] = fregs.vregs[r] & 0xFFFFFFFF;
++ dwarf_fregs[r] = (Dwarf_Word)fregs.vregs[r];
+
+ if (! setfunc (64, 32, dwarf_fregs, arg))
+ return false;
diff --git a/experimental/elfutils/fix-uninitialized.patch b/experimental/elfutils/fix-uninitialized.patch
new file mode 100644
index 000000000..5bc174c86
--- /dev/null
+++ b/experimental/elfutils/fix-uninitialized.patch
@@ -0,0 +1,10 @@
+--- a/libcpu/i386_disasm.c 2015-08-21 14:22:37.000000000 +0200
++++ b/libcpu/i386_disasm.c 2015-11-20 06:30:59.250629957 +0100
+@@ -710,6 +710,7 @@
+
+ case 'm':
+ /* Mnemonic. */
++ str = mnebuf;
+
+ if (unlikely (instrtab[cnt].mnemonic == MNE_INVALID))
+ {
diff --git a/experimental/elfutils/musl-cdefs.patch b/experimental/elfutils/musl-cdefs.patch
new file mode 100644
index 000000000..b74561f46
--- /dev/null
+++ b/experimental/elfutils/musl-cdefs.patch
@@ -0,0 +1,23 @@
+--- elfutils-0.176/libelf/elf.h 2019-02-15 10:46:47.000000000 -0500
++++ elfutils-0.176/libelf/elf.h 2019-07-18 01:52:14.789891340 -0400
+@@ -21,7 +21,9 @@
+
+ #include <features.h>
+
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+
+ /* Standard ELF types. */
+
+@@ -3915,6 +3917,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/experimental/elfutils/musl-fts-obstack.patch b/experimental/elfutils/musl-fts-obstack.patch
new file mode 100644
index 000000000..a9e5fec71
--- /dev/null
+++ b/experimental/elfutils/musl-fts-obstack.patch
@@ -0,0 +1,115 @@
+--- a/configure.ac 2015-10-15 15:16:57.000000000 +0200
++++ b/configure.ac 2015-11-20 05:32:57.723901582 +0100
+@@ -305,6 +305,62 @@
+ fi
+ AC_SUBST([argp_LDADD])
+
++dnl Check if we have fts available from our libc
++AC_LINK_IFELSE(
++ [AC_LANG_PROGRAM(
++ [#if !defined(__x86_64__)
++ #undef _FILE_OFFSET_BITS
++ #define _FILE_OFFSET_BITS 32
++ #endif
++ #include <fts.h>],
++ [FTS* fts = 0; return fts_close(fts); return 0;]
++ )],
++ [libc_has_fts="true"],
++ [libc_has_fts="false"]
++)
++
++dnl If our libc doesn't provide fts, then test for libfts
++if test "$libc_has_fts" = "false" ; then
++ AC_MSG_WARN("libc does not have fts")
++ AC_CHECK_LIB([fts], [fts_close], [have_fts="true"], [have_fts="false"])
++
++ if test "$have_fts" = "false"; then
++ AC_MSG_ERROR("no libfts found")
++ else
++ fts_LDADD="-lfts"
++ fi
++else
++ fts_LDADD=""
++fi
++AC_SUBST([fts_LDADD])
++
++dnl Check if we have obstack available from our libc
++AC_LINK_IFELSE(
++ [AC_LANG_PROGRAM(
++ [#include <obstack.h>],
++ [_obstack_begin(0, 0, 0, NULL, NULL); return 0;]
++ )],
++ [libc_has_obstack="true"],
++ [libc_has_obstack="false"]
++)
++
++dnl If our libc doesn't provide obstack, then test for libobstack
++if test "$libc_has_obstack" = "false" ; then
++ AC_MSG_WARN("libc does not have obstack")
++ AC_CHECK_LIB([obstack], [_obstack_begin], [have_obstack="true"], [have_obstack="false"])
++
++ if test "$have_obstack" = "false"; then
++ AC_MSG_ERROR("no libobstack found")
++ else
++ obstack_LDADD="-lobstack"
++ fi
++else
++ obstack_LDADD=""
++fi
++AC_SUBST([obstack_LDADD])
++
++dnl The directories with content.
++
+ dnl The directories with content.
+
+ dnl Documentation.
+--- a/src/Makefile.am.orig 2016-08-29 21:38:11.179295769 +0200
++++ b/src/Makefile.am 2016-08-03 18:19:47.000000000 +0200
+@@ -67,22 +67,22 @@
+ ar_no_Wstack_usage = yes
+ unstrip_no_Wstack_usage = yes
+
++readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) -ldl
++nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) -ldl \
+-readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
+-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl \
+ $(demanglelib)
++size_LDADD = $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD)
++strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) -ldl
++elflint_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) -ldl
++findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD)
++addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) $(demanglelib)
++elfcmp_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) -ldl
+-size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+-strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl
+-elflint_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
+-findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+-addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
+-elfcmp_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
+ objdump_LDADD = $(libasm) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
++ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD)
++strings_LDADD = $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD)
++ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD)
++unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) -ldl
++stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) -ldl $(demanglelib)
++elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD)
+-ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
+-strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+-ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
+-unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl
+-stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl $(demanglelib)
+-elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+
+ installcheck-binPROGRAMS: $(bin_PROGRAMS)
+ bad=0; pid=$$$$; list="$(bin_PROGRAMS)"; for p in $$list; do \
+--- a/libdw/Makefile.am.orig 2017-08-05 01:41:04.103553705 +0000
++++ b/libdw/Makefile.am 2017-08-05 01:43:55.366543497 +0000
+@@ -105,7 +105,7 @@
+ 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)
++libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) $(zip_LIBS)
+ 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/experimental/elfutils/musl-macros.patch b/experimental/elfutils/musl-macros.patch
new file mode 100644
index 000000000..fb44d4f33
--- /dev/null
+++ b/experimental/elfutils/musl-macros.patch
@@ -0,0 +1,66 @@
+--- a/src/arlib.h 2015-08-21 14:22:37.000000000 +0200
++++ b/src/arlib.h 2015-11-20 08:02:55.153199611 +0100
+@@ -29,6 +29,16 @@
+ #include <stdint.h>
+ #include <sys/types.h>
+
++#if !defined(ACCESSPERMS)
++# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
++#endif
++#if !defined(ALLPERMS)
++# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
++#endif
++#if !defined(DEFFILEMODE)
++# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
++#endif
++
+
+ /* State of -D/-U flags. */
+ extern bool arlib_deterministic_output;
+--- a/src/elfcompress.c.orig 2016-04-02 12:51:26.903848894 +0200
++++ b/src/elfcompress.c 2016-04-02 12:55:15.076996338 +0200
+@@ -35,6 +35,14 @@
+ #include <gelf.h>
+ #include "system.h"
+
++#if !defined(FNM_EXTMATCH)
++# define FNM_EXTMATCH 0
++#endif
++
++#if !defined(ALLPERMS)
++# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
++#endif
++
+ /* Name and version of program. */
+ static void print_version (FILE *stream, struct argp_state *state);
+ ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
+--- a/src/strip.c.orig 2017-08-02 12:06:25.000000000 +0000
++++ b/src/strip.c 2017-08-05 01:58:01.523493062 +0000
+@@ -47,6 +47,14 @@
+ #include <system.h>
+ #include <printversion.h>
+
++#if !defined(FNM_EXTMATCH)
++# define FNM_EXTMATCH 0
++#endif
++
++#if !defined(ACCESSPERMS)
++#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
++#endif
++
+ typedef uint8_t GElf_Byte;
+
+ /* Name and version of program. */
+--- elfutils-0.176/tests/elfstrmerge.c 2019-02-15 15:46:47.000000000 +0000
++++ elfutils-0.176/tests/elfstrmerge.c 2019-07-18 06:29:58.109875347 +0000
+@@ -33,6 +33,10 @@
+ #include ELFUTILS_HEADER(dwelf)
+ #include "elf-knowledge.h"
+
++#if !defined(ALLPERMS)
++# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
++#endif
++
+ /* The original ELF file. */
+ static int fd = -1;
+ static Elf *elf = NULL;
diff --git a/experimental/elfutils/musl-qsort_r.patch b/experimental/elfutils/musl-qsort_r.patch
new file mode 100644
index 000000000..9be21bd25
--- /dev/null
+++ b/experimental/elfutils/musl-qsort_r.patch
@@ -0,0 +1,65 @@
+--- a/src/readelf.c
++++ b/src/readelf.c
+@@ -4773,10 +4773,11 @@ listptr_base (struct listptr *p)
+ return cudie_base (&cu);
+ }
+
++static const char *listptr_name;
++
+ static int
+-compare_listptr (const void *a, const void *b, void *arg)
++compare_listptr (const void *a, const void *b)
+ {
+- const char *name = arg;
+ struct listptr *p1 = (void *) a;
+ struct listptr *p2 = (void *) b;
+
+@@ -4792,21 +4793,21 @@ compare_listptr (const void *a, const void *b, void *arg)
+ p1->warned = p2->warned = true;
+ error (0, 0,
+ gettext ("%s %#" PRIx64 " used with different address sizes"),
+- name, (uint64_t) p1->offset);
++ listptr_name, (uint64_t) p1->offset);
+ }
+ if (p1->dwarf64 != p2->dwarf64)
+ {
+ p1->warned = p2->warned = true;
+ error (0, 0,
+ gettext ("%s %#" PRIx64 " used with different offset sizes"),
+- name, (uint64_t) p1->offset);
++ listptr_name, (uint64_t) p1->offset);
+ }
+ if (listptr_base (p1) != listptr_base (p2))
+ {
+ p1->warned = p2->warned = true;
+ error (0, 0,
+ gettext ("%s %#" PRIx64 " used with different base addresses"),
+- name, (uint64_t) p1->offset);
++ listptr_name, (uint64_t) p1->offset);
+ }
+ if (p1->attr != p2 ->attr)
+ {
+@@ -4814,7 +4815,7 @@ compare_listptr (const void *a, const void *b, void *arg)
+ error (0, 0,
+ gettext ("%s %#" PRIx64
+ " used with different attribute %s and %s"),
+- name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
++ listptr_name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
+ dwarf_attr_name (p2->attr));
+ }
+ }
+@@ -4885,9 +4886,11 @@ notice_listptr (enum section_e section, struct listptr_table *table,
+ static void
+ sort_listptr (struct listptr_table *table, const char *name)
+ {
+- if (table->n > 0)
+- qsort_r (table->table, table->n, sizeof table->table[0],
+- &compare_listptr, (void *) name);
++ if (table->n > 0) {
++ listptr_name = name;
++ qsort (table->table, table->n, sizeof table->table[0],
++ &compare_listptr);
++ }
+ }
+
+ static bool
diff --git a/experimental/elfutils/musl-strerror_r.patch b/experimental/elfutils/musl-strerror_r.patch
new file mode 100644
index 000000000..72977951d
--- /dev/null
+++ b/experimental/elfutils/musl-strerror_r.patch
@@ -0,0 +1,19 @@
+--- a/libdwfl/dwfl_error.c 2015-09-29 17:18:51.000000000 +0200
++++ b/libdwfl/dwfl_error.c 2015-11-20 05:11:29.889002058 +0100
+@@ -154,7 +154,16 @@
+ switch (error &~ 0xffff)
+ {
+ case OTHER_ERROR (ERRNO):
++#if defined(__GLIBC__)
+ return strerror_r (error & 0xffff, "bad", 0);
++#else
++ {
++ static __thread char buf[128] = "";
++ if (0 == strerror_r(error & 0xffff, buf, sizeof(buf)))
++ return buf;
++ }
++ return "strerror_r() failed";
++#endif
+ case OTHER_ERROR (LIBELF):
+ return elf_errmsg (error & 0xffff);
+ case OTHER_ERROR (LIBDW):
diff --git a/experimental/elfutils/musl-strndupa.patch b/experimental/elfutils/musl-strndupa.patch
new file mode 100644
index 000000000..e48fa2018
--- /dev/null
+++ b/experimental/elfutils/musl-strndupa.patch
@@ -0,0 +1,18 @@
+--- a/src/unstrip.c 2017-04-27 14:26:26.000000000 +0000
++++ b/src/unstrip.c 2017-05-05 15:51:33.515154220 +0000
+@@ -56,6 +56,15 @@
+ # define _(str) gettext (str)
+ #endif
+
++#ifndef strndupa
++#define strndupa(s, n) \
++ (__extension__ ({const char *__in = (s); \
++ size_t __len = strnlen (__in, (n)) + 1; \
++ char *__out = (char *) alloca (__len); \
++ __out[__len-1] = '\0'; \
++ (char *) memcpy (__out, __in, __len-1);}))
++#endif
++
+ /* Name and version of program. */
+ ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
+
diff --git a/experimental/elfutils/test-disable-backtrace.patch b/experimental/elfutils/test-disable-backtrace.patch
new file mode 100644
index 000000000..420e39215
--- /dev/null
+++ b/experimental/elfutils/test-disable-backtrace.patch
@@ -0,0 +1,59 @@
+With musl-dbg installed:
+
+FAIL: run-backtrace-native.sh
+=============================
+
+0x5633ee097000 0x5633ee29a000 /home/mcrees/packages/user/elfutils/src/elfutils-0.176/tests/backtrace-child
+0x7f59b75a3000 0x7f59b7850000 /lib/ld-musl-x86_64.so.1
+0x7fffddac8000 0x7fffddaca000 [vdso: 6946]
+TID 6946:
+# 0 0x7f59b75fad77 __restore_sigs
+# 1 0x7f59b75faf38 - 1 raise
+# 2 0x5633ee0979f3 - 1 main
+# 3 0x7f59b75c0e1c - 1 libc_start_main_stage2
+# 4 0x5633ee097b08 - 1 _start_c
+# 5 0x5633ee097adc - 1 _start
+TID 6947:
+# 0 0x7f59b75fad77 __restore_sigs
+/home/mcrees/packages/user/elfutils/src/elfutils-0.176/tests/backtrace: dwfl_thread_getframes: no matching address range
+Assertion failed: symname && strcmp (symname, "raise") == 0 (backtrace.c: callback_verify: 111)
+./test-subr.sh: line 84: 6945 Aborted (core dumped) LD_LIBRARY_PATH="${built_library_path}${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" $VALGRIND_CMD "$@"
+# 2 0x5633ee0979f3 - 1 main
+backtrace-child: neither empty nor just out of DWARF
+rmdir: failed to remove 'test-6939': Directory not empty
+FAIL run-backtrace-native.sh (exit status: 1)
+
+FAIL: run-backtrace-native-core.sh
+==================================
+
+0x7ffea8c6d000 0x7ffea8c6e000 linux-vdso.so.1
+0x7f174e2fb000 0x7f174e5aa2f8 ld-musl-x86_64.so.1
+0x56367bb22000 0x56367bd24078 backtrace-child
+TID 7019:
+# 0 0x7f174e352d77 __restore_sigs
+Assertion failed: symname && strcmp (symname, "raise") == 0 (backtrace.c: callback_verify: 111)
+./test-subr.sh: line 84: 7022 Aborted (core dumped) LD_LIBRARY_PATH="${built_library_path}${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" $VALGRIND_CMD "$@"
+backtrace-child-core.7018: no main
+rmdir: failed to remove 'test-7010': Directory not empty
+FAIL run-backtrace-native-core.sh (exit status: 1)
+
+--- elfutils-0.176/tests/run-backtrace-native-core.sh 2019-02-15 15:46:47.000000000 +0000
++++ elfutils-0.176/tests/run-backtrace-native-core.sh 2019-07-18 10:03:51.589784665 +0000
+@@ -17,4 +17,7 @@
+
+ . $srcdir/backtrace-subr.sh
+
++echo "backtrace test broken on musl"
++exit 77
++
+ check_native_core backtrace-child
+--- elfutils-0.176/tests/run-backtrace-native.sh 2019-02-15 15:46:47.000000000 +0000
++++ elfutils-0.176/tests/run-backtrace-native.sh 2019-07-18 10:07:23.109783171 +0000
+@@ -17,4 +17,7 @@
+
+ . $srcdir/backtrace-subr.sh
+
++echo "backtrace test broken on musl"
++exit 77
++
+ check_native backtrace-child
diff --git a/experimental/elfutils/test-disable-biarch.patch b/experimental/elfutils/test-disable-biarch.patch
new file mode 100644
index 000000000..809c3df1e
--- /dev/null
+++ b/experimental/elfutils/test-disable-biarch.patch
@@ -0,0 +1,9 @@
+https://sourceware.org/PR24158
+
+Tets fails when 32-bit elfutils tries to dump 64-bit process.
+--- a/tests/run-backtrace-native-biarch.sh
++++ b/tests/run-backtrace-native-biarch.sh
+@@ -17,2 +17,3 @@
+
++ELFUTILS_DISABLE_BIARCH=yes # https://sourceware.org/PR24158
+ if test -n "$ELFUTILS_DISABLE_BIARCH"; then