aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJory Pratt <anarchy@gentoo.org>2019-12-12 23:01:35 -0600
committerJory Pratt <anarchy@gentoo.org>2019-12-12 23:01:35 -0600
commitfd5a3a9743f6feb7f921433e187621e228f79927 (patch)
treee911a360c0ab7e2fdc71d4d526b9e52055f458c9 /dev-libs
parentsys-libs/compiler-rt-sanitizers: remove stale (diff)
downloadmusl-fd5a3a9743f6feb7f921433e187621e228f79927.tar.gz
musl-fd5a3a9743f6feb7f921433e187621e228f79927.tar.bz2
musl-fd5a3a9743f6feb7f921433e187621e228f79927.zip
dev-libs/elfutils: Version bump 0.178
Package-Manager: Portage-2.3.81, Repoman-2.3.20 Signed-off-by: Jory Pratt <anarchy@gentoo.org>
Diffstat (limited to 'dev-libs')
-rw-r--r--dev-libs/elfutils/Manifest1
-rw-r--r--dev-libs/elfutils/elfutils-0.178.ebuild94
-rw-r--r--dev-libs/elfutils/files/0.178/fix-aarch64_fregs.patch48
-rw-r--r--dev-libs/elfutils/files/0.178/musl-asm_ptrace_h.patch26
-rw-r--r--dev-libs/elfutils/files/0.178/musl-cdefs.patch45
-rw-r--r--dev-libs/elfutils/files/0.178/musl-error_h.patch81
-rw-r--r--dev-libs/elfutils/files/0.178/musl-fts-obstack.patch107
-rw-r--r--dev-libs/elfutils/files/0.178/musl-macros.patch73
-rw-r--r--dev-libs/elfutils/files/0.178/musl-qsort_r.patch79
-rw-r--r--dev-libs/elfutils/files/0.178/musl-strerror_r.patch33
-rw-r--r--dev-libs/elfutils/files/0.178/musl-strndupa.patch32
-rw-r--r--dev-libs/elfutils/metadata.xml4
12 files changed, 623 insertions, 0 deletions
diff --git a/dev-libs/elfutils/Manifest b/dev-libs/elfutils/Manifest
index 1e9d789..0e02e5c 100644
--- a/dev-libs/elfutils/Manifest
+++ b/dev-libs/elfutils/Manifest
@@ -1,2 +1,3 @@
DIST elfutils-0.176.tar.bz2 8646075 BLAKE2B 7f23d59b7f5d74946fea928a7fada7764c1f96a5eefefc4a3a382090eb7cad07c80419218300d853ccbef8f4e2288eb443ff06b3e64bf4511d9fa7aa84f5b794 SHA512 7f032913be363a43229ded85d495dcf7542b3c85974aaaba0d984228dc9ac1721da3dc388d3fa02325a80940161db7e9ad2c9e4521a424ad8a7d050c0902915b
DIST elfutils-0.177.tar.bz2 8852413 BLAKE2B 03f432342651f7646d73b7847325bd14b722ce34d85df01b1ad072b916af9b9da2d0d119cd24e952073bd584ec76b027ba9b6c7d45fb057372b3e700b1f5741a SHA512 2779987463a22ed220759e25a09c9a1eb84c0f36db37675136e59aa55c7f8f90b7a7d34ffc4e6a4291d7fa73692a1bd1a303a74270b11d1623b4f9868d19498f
+DIST elfutils-0.178.tar.bz2 9007557 BLAKE2B 241b611dbfac37f35a670fbe80096c21b870e4b26fcddc8af26fba0373c9cd72eae42aabae2803b7b16c3bf649aeda036b1ea1b40952b43c4021ed23fcb51e80 SHA512 356656ad0db8f6877b461de1a11280de16a9cc5d8dde4381a938a212e828e32755135e5e3171d311c4c9297b728fbd98123048e2e8fbf7fe7de68976a2daabe5
diff --git a/dev-libs/elfutils/elfutils-0.178.ebuild b/dev-libs/elfutils/elfutils-0.178.ebuild
new file mode 100644
index 0000000..e00d6b2
--- /dev/null
+++ b/dev-libs/elfutils/elfutils-0.178.ebuild
@@ -0,0 +1,94 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit autotools flag-o-matic multilib-minimal
+
+DESCRIPTION="Libraries/utilities to handle ELF objects (drop in replacement for libelf)"
+HOMEPAGE="http://elfutils.org/"
+SRC_URI="https://sourceware.org/elfutils/ftp/${PV}/${P}.tar.bz2"
+
+LICENSE="|| ( GPL-2+ LGPL-3+ ) utils? ( GPL-3+ )"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux"
+IUSE="bzip2 lzma nls static-libs test +threads +utils valgrind"
+
+RDEPEND=">=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}]
+ bzip2? ( >=app-arch/bzip2-1.0.6-r4[${MULTILIB_USEDEP}] )
+ lzma? ( >=app-arch/xz-utils-5.0.5-r1[${MULTILIB_USEDEP}] )
+ elibc_musl? (
+ sys-libs/argp-standalone
+ sys-libs/fts-standalone
+ sys-libs/obstack-standalone
+ )
+ !dev-libs/libelf"
+DEPEND="${RDEPEND}
+ valgrind? ( dev-util/valgrind )
+"
+BDEPEND="nls? ( sys-devel/gettext )
+ >=sys-devel/flex-2.5.4a
+ sys-devel/m4
+ elibc_musl? ( dev-libs/libbsd )"
+
+RESTRICT="!test? ( test )"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-0.118-PaX-support.patch
+ "${FILESDIR}"/${PN}-0.175-disable-biarch-test-PR24158.patch
+ "${FILESDIR}"/${PN}-0.177-disable-large.patch
+ "${FILESDIR}"/${PV}/fix-aarch64_fregs.patch
+ "${FILESDIR}"/${PV}/musl-asm_ptrace_h.patch
+ "${FILESDIR}"/${PV}/musl-cdefs.patch
+ "${FILESDIR}"/${PV}/musl-macros.patch
+ "${FILESDIR}"/${PV}/musl-fts-obstack.patch
+ "${FILESDIR}"/${PV}/musl-qsort_r.patch
+ "${FILESDIR}"/${PV}/musl-strerror_r.patch
+ "${FILESDIR}"/${PV}/musl-strndupa.patch
+ "${FILESDIR}"/${PV}/musl-error_h.patch
+)
+
+src_prepare() {
+ default
+
+ eautoreconf
+
+ if ! use static-libs; then
+ sed -i -e '/^lib_LIBRARIES/s:=.*:=:' -e '/^%.os/s:%.o$::' lib{asm,dw,elf}/Makefile.in || die
+ fi
+ # https://sourceware.org/PR23914
+ sed -i 's:-Werror::' */Makefile.in || die
+}
+
+src_configure() {
+ use test && append-flags -g #407135
+ multilib-minimal_src_configure
+}
+
+multilib_src_configure() {
+ ECONF_SOURCE="${S}" econf \
+ $(use_enable nls) \
+ $(use_enable threads thread-safety) \
+ $(use_enable valgrind) \
+ --disable-debuginfod \
+ --program-prefix="eu-" \
+ --with-zlib \
+ $(use_with bzip2 bzlib) \
+ $(use_with lzma)
+}
+
+multilib_src_test() {
+ env LD_LIBRARY_PATH="${BUILD_DIR}/libelf:${BUILD_DIR}/libebl:${BUILD_DIR}/libdw:${BUILD_DIR}/libasm" \
+ LC_ALL="C" \
+ emake check VERBOSE=1
+}
+
+multilib_src_install_all() {
+ einstalldocs
+ dodoc NOTES
+ # These build quick, and are needed for most tests, so don't
+ # disable their building when the USE flag is disabled.
+ if ! use utils; then
+ rm -rf "${ED}"/usr/bin || die
+ fi
+}
diff --git a/dev-libs/elfutils/files/0.178/fix-aarch64_fregs.patch b/dev-libs/elfutils/files/0.178/fix-aarch64_fregs.patch
new file mode 100644
index 0000000..004bafe
--- /dev/null
+++ b/dev-libs/elfutils/files/0.178/fix-aarch64_fregs.patch
@@ -0,0 +1,48 @@
+From dd394676bb8b8e7e4a584a58664ea20472b948e5 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 12 Dec 2019 20:44:47 -0600
+Subject: [PATCH 1/9] Fix aarch64 support for dwarf_fregs
+
+---
+ backends/aarch64_initreg.c | 4 ++--
+ backends/arm_initreg.c | 2 +-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/backends/aarch64_initreg.c b/backends/aarch64_initreg.c
+index daf6f37..6445276 100644
+--- a/backends/aarch64_initreg.c
++++ b/backends/aarch64_initreg.c
+@@ -33,7 +33,7 @@
+ #include "system.h"
+ #include <assert.h>
+ #if defined(__aarch64__) && defined(__linux__)
+-# include <linux/uio.h>
++# include <sys/uio.h>
+ # include <sys/user.h>
+ # include <sys/ptrace.h>
+ /* Deal with old glibc defining user_pt_regs instead of user_regs_struct. */
+@@ -82,7 +82,7 @@ aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
+
+ Dwarf_Word dwarf_fregs[32];
+ for (int r = 0; r < 32; r++)
+- dwarf_fregs[r] = fregs.vregs[r] & 0xFFFFFFFF;
++ dwarf_fregs[r] = (unsigned int)fregs.vregs[r] & 0xFFFFFFFF;
+
+ if (! setfunc (64, 32, dwarf_fregs, arg))
+ return false;
+diff --git a/backends/arm_initreg.c b/backends/arm_initreg.c
+index efcabaf..062bb9e 100644
+--- a/backends/arm_initreg.c
++++ b/backends/arm_initreg.c
+@@ -38,7 +38,7 @@
+ #endif
+
+ #ifdef __aarch64__
+-# include <linux/uio.h>
++# include <sys/uio.h>
+ # include <sys/user.h>
+ # include <sys/ptrace.h>
+ /* Deal with old glibc defining user_pt_regs instead of user_regs_struct. */
+--
+2.24.1
+
diff --git a/dev-libs/elfutils/files/0.178/musl-asm_ptrace_h.patch b/dev-libs/elfutils/files/0.178/musl-asm_ptrace_h.patch
new file mode 100644
index 0000000..7731f63
--- /dev/null
+++ b/dev-libs/elfutils/files/0.178/musl-asm_ptrace_h.patch
@@ -0,0 +1,26 @@
+From fa623f8330c8e7264eba98d0e8199ef4aa219d2a Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 12 Dec 2019 21:34:57 -0600
+Subject: [PATCH 2/9] include asm.h for non glibc systems on ppc
+
+---
+ backends/ppc_initreg.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/backends/ppc_initreg.c b/backends/ppc_initreg.c
+index 0e0d359..3dbcc2d 100644
+--- a/backends/ppc_initreg.c
++++ b/backends/ppc_initreg.c
+@@ -32,6 +32,9 @@
+
+ #include <stdlib.h>
+ #if defined(__powerpc__) && defined(__linux__)
++#if !defined(__GLIBC__)
++# include <asm/ptrace.h>
++#endif
+ # include <sys/ptrace.h>
+ # include <sys/user.h>
+ #endif
+--
+2.24.1
+
diff --git a/dev-libs/elfutils/files/0.178/musl-cdefs.patch b/dev-libs/elfutils/files/0.178/musl-cdefs.patch
new file mode 100644
index 0000000..7a73f42
--- /dev/null
+++ b/dev-libs/elfutils/files/0.178/musl-cdefs.patch
@@ -0,0 +1,45 @@
+From 4e124b57e40c15c9ccb19c6a219816cfc8d2a167 Mon Sep 17 00:00:00 2001
+From: Jory Pratt <anarchy@gentoo.org>
+Date: Thu, 12 Dec 2019 22:38:30 -0600
+Subject: [PATCH 3/3] Fix cdefs.h include for musl
+
+---
+ lib/fixedsizehash.h | 5 ++++-
+ libelf/elf.h | 4 ++++
+ 2 files changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/lib/fixedsizehash.h b/lib/fixedsizehash.h
+index dac2a5f..910f3ac 100644
+--- a/lib/fixedsizehash.h
++++ b/lib/fixedsizehash.h
+@@ -30,8 +30,11 @@
+ #include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if !defined(__GLIBC__)
++#include <bsd/sys/cdefs.h>
++#else
+ #include <sys/cdefs.h>
+-
++#endif
+ #include <system.h>
+
+ #ifdef __CONCAT
+diff --git a/libelf/elf.h b/libelf/elf.h
+index 7adc752..8cfc337 100644
+--- a/libelf/elf.h
++++ b/libelf/elf.h
+@@ -21,6 +21,10 @@
+
+ #include <features.h>
+
++#if !defined(__GLIBC__)
++#include <bsd/sys/cdefs.h>
++#endif
++
+ __BEGIN_DECLS
+
+ /* Standard ELF types. */
+--
+2.24.1
+
diff --git a/dev-libs/elfutils/files/0.178/musl-error_h.patch b/dev-libs/elfutils/files/0.178/musl-error_h.patch
new file mode 100644
index 0000000..949e600
--- /dev/null
+++ b/dev-libs/elfutils/files/0.178/musl-error_h.patch
@@ -0,0 +1,81 @@
+From 9cb8fad40329cc6445233af0b6ac3f2adde19c65 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 12 Dec 2019 22:00:47 -0600
+Subject: [PATCH 9/9] Add hacked up error header for non GLIBC machines
+
+---
+ lib/error.h | 27 +++++++++++++++++++++++++++
+ src/error.h | 27 +++++++++++++++++++++++++++
+ 2 files changed, 54 insertions(+)
+ create mode 100644 lib/error.h
+ create mode 100644 src/error.h
+
+diff --git a/lib/error.h b/lib/error.h
+new file mode 100644
+index 0000000..ef06827
+--- /dev/null
++++ b/lib/error.h
+@@ -0,0 +1,27 @@
++#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;
++ 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);
++}
++
++#endif /* _ERROR_H_ */
+diff --git a/src/error.h b/src/error.h
+new file mode 100644
+index 0000000..ef06827
+--- /dev/null
++++ b/src/error.h
+@@ -0,0 +1,27 @@
++#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;
++ 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);
++}
++
++#endif /* _ERROR_H_ */
+--
+2.24.1
+
diff --git a/dev-libs/elfutils/files/0.178/musl-fts-obstack.patch b/dev-libs/elfutils/files/0.178/musl-fts-obstack.patch
new file mode 100644
index 0000000..2484164
--- /dev/null
+++ b/dev-libs/elfutils/files/0.178/musl-fts-obstack.patch
@@ -0,0 +1,107 @@
+From e9c4f15652e5c89c51d61007c296daf2cebca014 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 12 Dec 2019 21:53:18 -0600
+Subject: [PATCH 4/9] Check libc for fts and obstack or use standalone
+
+---
+ configure.ac | 56 +++++++++++++++++++++++++++++++++++++++++++++++
+ libdw/Makefile.am | 2 +-
+ src/Makefile.am | 2 +-
+ 3 files changed, 58 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 5a2dc37..7a17a9d 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -529,6 +529,62 @@ else
+ 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.
+diff --git a/libdw/Makefile.am b/libdw/Makefile.am
+index 33b5838..af30825 100644
+--- a/libdw/Makefile.am
++++ b/libdw/Makefile.am
+@@ -109,7 +109,7 @@ libdw_so_LIBS = ../libebl/libebl_pic.a ../backends/libebl_backends_pic.a \
+ ../libcpu/libcpu_pic.a libdw_pic.a ../libdwelf/libdwelf_pic.a \
+ ../libdwfl/libdwfl_pic.a
+ libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
+-libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS) -pthread
++libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(fts_LDADD) $(obstack_LDADD) $(zip_LIBS) -pthread
+ libdw_so_SOURCES =
+ libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
+ $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
+diff --git a/src/Makefile.am b/src/Makefile.am
+index e462e7d..d0cab5a 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -46,7 +46,7 @@ libelf = ../libelf/libelf.a -lz
+ else
+ libasm = ../libasm/libasm.so
+ libdw = ../libdw/libdw.so
+-libelf = ../libelf/libelf.so
++libelf = ../libelf/libelf.so $(fts_LDADD) $(obstack_LDADD)
+ endif
+ libebl = ../libebl/libebl.a ../backends/libebl_backends.a ../libcpu/libcpu.a
+ libeu = ../lib/libeu.a
+--
+2.24.1
+
diff --git a/dev-libs/elfutils/files/0.178/musl-macros.patch b/dev-libs/elfutils/files/0.178/musl-macros.patch
new file mode 100644
index 0000000..f549b69
--- /dev/null
+++ b/dev-libs/elfutils/files/0.178/musl-macros.patch
@@ -0,0 +1,73 @@
+From f49c96b011df0bd03eb45f72bdb102d580fab964 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 12 Dec 2019 21:54:37 -0600
+Subject: [PATCH 5/9] Add macros for musl support
+
+---
+ src/arlib.h | 10 ++++++++++
+ src/elfcompress.c | 8 ++++++++
+ src/strip.c | 8 ++++++++
+ 3 files changed, 26 insertions(+)
+
+diff --git a/src/arlib.h b/src/arlib.h
+index e117166..c66a5c9 100644
+--- a/src/arlib.h
++++ b/src/arlib.h
+@@ -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;
+diff --git a/src/elfcompress.c b/src/elfcompress.c
+index 6ba6af4..f7d032b 100644
+--- a/src/elfcompress.c
++++ b/src/elfcompress.c
+@@ -37,6 +37,14 @@
+ #include "libeu.h"
+ #include "printversion.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. */
+ ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
+
+diff --git a/src/strip.c b/src/strip.c
+index 48792a7..d2f0c60 100644
+--- a/src/strip.c
++++ b/src/strip.c
+@@ -46,6 +46,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. */
+--
+2.24.1
+
diff --git a/dev-libs/elfutils/files/0.178/musl-qsort_r.patch b/dev-libs/elfutils/files/0.178/musl-qsort_r.patch
new file mode 100644
index 0000000..3e45828
--- /dev/null
+++ b/dev-libs/elfutils/files/0.178/musl-qsort_r.patch
@@ -0,0 +1,79 @@
+From 2fe70c56695e170ae7b859c154a83532de2dee22 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 12 Dec 2019 21:55:34 -0600
+Subject: [PATCH 6/9] musl qsort_r
+
+---
+ src/readelf.c | 21 ++++++++++++---------
+ 1 file changed, 12 insertions(+), 9 deletions(-)
+
+diff --git a/src/readelf.c b/src/readelf.c
+index cbb519d..dea513b 100644
+--- a/src/readelf.c
++++ b/src/readelf.c
+@@ -4829,10 +4829,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;
+
+@@ -4848,21 +4849,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)
+ {
+@@ -4870,7 +4871,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));
+ }
+ }
+@@ -4941,9 +4942,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
+--
+2.24.1
+
diff --git a/dev-libs/elfutils/files/0.178/musl-strerror_r.patch b/dev-libs/elfutils/files/0.178/musl-strerror_r.patch
new file mode 100644
index 0000000..f6ca800
--- /dev/null
+++ b/dev-libs/elfutils/files/0.178/musl-strerror_r.patch
@@ -0,0 +1,33 @@
+From 00bd0b5e75bbed231aa743502df96e0641da86fd Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 12 Dec 2019 21:58:10 -0600
+Subject: [PATCH 7/9] musl strerror_r
+
+---
+ libdwfl/dwfl_error.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
+index 7bcf61c..ff25ebb 100644
+--- a/libdwfl/dwfl_error.c
++++ b/libdwfl/dwfl_error.c
+@@ -154,7 +154,16 @@ dwfl_errmsg (int error)
+ 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):
+--
+2.24.1
+
diff --git a/dev-libs/elfutils/files/0.178/musl-strndupa.patch b/dev-libs/elfutils/files/0.178/musl-strndupa.patch
new file mode 100644
index 0000000..5acd7e4
--- /dev/null
+++ b/dev-libs/elfutils/files/0.178/musl-strndupa.patch
@@ -0,0 +1,32 @@
+From 411f7a1d30f03cb64e4716977e3504e25af8ce90 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 12 Dec 2019 21:58:31 -0600
+Subject: [PATCH 8/9] musl strndupa
+
+---
+ src/unstrip.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/src/unstrip.c b/src/unstrip.c
+index 9b8c09a..afce497 100644
+--- a/src/unstrip.c
++++ b/src/unstrip.c
+@@ -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;
+
+--
+2.24.1
+
diff --git a/dev-libs/elfutils/metadata.xml b/dev-libs/elfutils/metadata.xml
index 14c09d8..10d87fa 100644
--- a/dev-libs/elfutils/metadata.xml
+++ b/dev-libs/elfutils/metadata.xml
@@ -9,5 +9,9 @@
<flag name="lzma">Support automatic decompression of LZMA-compressed files and kernel images</flag>
<flag name="threads">Build the libraries with thread safe support</flag>
<flag name="utils">Install command-line utilities (all the eu-* programs)</flag>
+ <flag name="valgrind">Add support for memory debugging using <pkg>dev-util/valgrind</pkg></flag>
</use>
+ <upstream>
+ <remote-id type="cpe">cpe:/a:elfutils_project:elfutils</remote-id>
+ </upstream>
</pkgmetadata>