summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2024-11-21 14:05:26 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2024-11-21 14:08:50 -0600
commit4f9c4cea3a72e03847dba50893302f5b620fd425 (patch)
treec577370c5a37a602c4e2b3d8732537d831c69397
parent0bfe44e25b0f239d854716a031dc2d976e3d45c3 (diff)
downloadpackages-4f9c4cea3a72e03847dba50893302f5b620fd425.tar.gz
packages-4f9c4cea3a72e03847dba50893302f5b620fd425.tar.bz2
packages-4f9c4cea3a72e03847dba50893302f5b620fd425.tar.xz
packages-4f9c4cea3a72e03847dba50893302f5b620fd425.zip
system/elfutils: New package
Needed for kernel on x86 platforms. Includes one patch from experimental/elfutils set.
-rw-r--r--system/elfutils/APKBUILD57
-rw-r--r--system/elfutils/aarch64-regs.patch57
-rw-r--r--system/elfutils/backtrace-cfi-fault.patch16
-rw-r--r--system/elfutils/backtrace-signal.patch20
-rw-r--r--system/elfutils/elfcompress-wildcard.patch27
-rw-r--r--system/elfutils/error.h29
-rw-r--r--system/elfutils/fnm.patch13
7 files changed, 219 insertions, 0 deletions
diff --git a/system/elfutils/APKBUILD b/system/elfutils/APKBUILD
new file mode 100644
index 000000000..3d6baf127
--- /dev/null
+++ b/system/elfutils/APKBUILD
@@ -0,0 +1,57 @@
+# Maintainer: A. Wilcox <awilfox@adelielinux.org>
+pkgname=elfutils
+pkgver=0.192
+pkgrel=0
+pkgdesc="Libraries and utilities to manipulate ELF objects"
+url="https://sourceware.org/elfutils/"
+arch="all"
+license="GPL-2.0+ AND LGPL-3.0+ AND GPL-3.0+"
+depends=""
+checkdepends="shimmy>0.7"
+makedepends="argp-standalone-dev bzip2-dev curl-dev fts-dev libarchive-dev libbsd-dev musl-obstack-dev xz-dev zlib-dev zstd-dev"
+subpackages="$pkgname-dev $pkgname-doc $pkgname-lang $pkgname-libs"
+source="https://sourceware.org/elfutils/ftp/$pkgver/elfutils-$pkgver.tar.bz2
+ aarch64-regs.patch
+ backtrace-signal.patch
+ backtrace-cfi-fault.patch
+ elfcompress-wildcard.patch
+ fnm.patch
+ error.h
+ "
+
+prepare() {
+ default_prepare
+ mkdir "$srcdir"/vendor-error
+ ln -s "$srcdir"/error.h "$srcdir"/vendor-error/error.h
+}
+
+build() {
+ export CFLAGS="$CFLAGS -I$srcdir/vendor-error"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --localstatedir=/var \
+ ac_cv_header_error_h=yes
+ make
+}
+
+check() {
+ env LD_LIBRARY_PATH="${builddir}/libelf:${builddir}/libebl:${builddir}/libdw:${builddir}/libasm" \
+ LC_ALL="C" \
+ make check VERBOSE=1
+}
+
+package() {
+ make DESTDIR="$pkgdir" install
+}
+
+sha512sums="543188f5f2cfe5bc7955a878416c5f252edff9926754e5de0c6c57b132f21d9285c9b29e41281e93baad11d4ae7efbbf93580c114579c182103565fe99bd3909 elfutils-0.192.tar.bz2
+1eb5975bed830dc83e9375f526176276a5254dd9351853dc4c2c4be66246ea74bb65ae5352ea9f3d7fdf70f8af2b9d953e921dbce7cf94a906cd22272db6adab aarch64-regs.patch
+17fc3bc814300e07f6087ce010c43bb67d6b0c8f3bf34ef57815a322a6ef9fbec5929b08641842b0f097d1ff2fdc865c94d6c4e84e357ce0b37e0c9b427024a7 backtrace-signal.patch
+90f8b6b894e79334c66522675e47debb60266fcdb7124bfd9eb0938a276ad4168bee734d3e125b56c76f20b849aa70ac8181382f01313264ecca08225e5fe411 backtrace-cfi-fault.patch
+7fa88ba58fb5eb7c835074dcd1db19591a001bb713c472f08eba3a94d80129011365f9cad70b04ec162897a13e4d2cc2d05ccec9130fd51b163621bb6e7ecc9d elfcompress-wildcard.patch
+95c46254dbd6ad358c29d2f9577ccb9ce884e51b3d7587b7d91c02c1b4e54378ceba707a9d3800b1a7a15b7a4ba8bce6e7601fb6eb3cc93bbe82d484fc16103e fnm.patch
+b33d7f210b9652b7b919afb32b4674ca125b660bf5f81fafb4e4e8405ea16be74ce85f653e6c0ac83e5fff1b192e82e273c5b5baa3802fdc7602edfa1086936d error.h"
diff --git a/system/elfutils/aarch64-regs.patch b/system/elfutils/aarch64-regs.patch
new file mode 100644
index 000000000..222c0527b
--- /dev/null
+++ b/system/elfutils/aarch64-regs.patch
@@ -0,0 +1,57 @@
+https://www.sourceware.org/bugzilla/show_bug.cgi?id=25832
+https://cgit.openembedded.org/openembedded-core/plain/meta/recipes-devtools/elfutils/files/0006-Fix-build-on-aarch64-musl.patch
+https://bugs.gentoo.org/693772
+
+Other variants/links:
+https://git.alpinelinux.org/aports/tree/main/elfutils/fix-aarch64_fregs.patch
+https://github.com/gentoo/musl/blob/6450482b9b4463b57ac249c63b7ed796e9874c40/dev-libs/elfutils/files/0.178/fix-aarch64_fregs.patch
+
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Tue, 15 Aug 2017 17:27:30 +0800
+Subject: [PATCH] Fix build on aarch64/musl
+
+Errors
+
+invalid operands to binary & (have 'long double' and 'unsigned int')
+
+error: redefinition
+ of 'struct iovec'
+ struct iovec { void *iov_base; size_t iov_len; };
+ ^
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+Rebase to 0.170
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+
+--- 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;
+--- 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. */
diff --git a/system/elfutils/backtrace-cfi-fault.patch b/system/elfutils/backtrace-cfi-fault.patch
new file mode 100644
index 000000000..4d66172f5
--- /dev/null
+++ b/system/elfutils/backtrace-cfi-fault.patch
@@ -0,0 +1,16 @@
+musl does not mark __clone as terminating properly with CFI.
+
+This is not strictly a bug in elfutils.
+
+--- elfutils-0.192/tests/backtrace.c.old 2024-11-19 04:38:13.465567711 -0600
++++ elfutils-0.192/tests/backtrace.c 2024-11-19 04:52:51.224654735 -0600
+@@ -254,6 +254,9 @@
+ callback_verify (tid, *framenop, pc, symname, dwfl);
+ (*framenop)++;
+
++ if (symname && strcmp (symname, "__clone") == 0 && *framenop == 15)
++ return -1;
++
+ return DWARF_CB_OK;
+ }
+
diff --git a/system/elfutils/backtrace-signal.patch b/system/elfutils/backtrace-signal.patch
new file mode 100644
index 000000000..3de66da31
--- /dev/null
+++ b/system/elfutils/backtrace-signal.patch
@@ -0,0 +1,20 @@
+Backtraces are thrown off by musl's __restore_sigs internal symbol.
+
+--- elfutils-0.192/tests/backtrace.c.old 2024-10-18 14:03:43.000000000 -0500
++++ elfutils-0.192/tests/backtrace.c 2024-11-19 03:56:50.568150211 -0600
+@@ -90,6 +90,15 @@
+ return;
+ }
+ Dwfl_Module *mod;
++ /* Handle musl's signal handler. */
++ static bool restore_sigs_seen = false;
++ if (symname && strcmp (symname, "__restore_sigs") == 0)
++ {
++ restore_sigs_seen = true;
++ return;
++ }
++ if (restore_sigs_seen)
++ frameno--;
+ /* Skip frames for which there isn't a function name. */
+ static int nulls_seen = 0;
+ if (symname == NULL)
diff --git a/system/elfutils/elfcompress-wildcard.patch b/system/elfutils/elfcompress-wildcard.patch
new file mode 100644
index 000000000..14c422b05
--- /dev/null
+++ b/system/elfutils/elfcompress-wildcard.patch
@@ -0,0 +1,27 @@
+Since musl doesn't support FNM_EXTMATCH, we need to do things.
+
+Ref: https://www.openwall.com/lists/musl/2020/10/26/7
+
+--- elfutils-0.192/src/elfcompress.c.old 2024-10-18 14:03:43.000000000 -0500
++++ elfutils-0.192/src/elfcompress.c 2024-11-19 05:43:45.360225756 -0600
+@@ -154,7 +154,10 @@
+ if (type == UNSET)
+ type = ZLIB;
+ if (patterns == NULL)
+- add_pattern (".?(z)debug*");
++ {
++ add_pattern (".debug*");
++ add_pattern (".zdebug*");
++ }
+ break;
+
+ case ARGP_KEY_NO_ARGS:
+@@ -1412,7 +1415,7 @@
+ "'zlib-gnu' (.zdebug GNU style compression, 'gnu' is an alias) or 'zstd' (ELF ZSTD compression)"),
+ 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 a 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/system/elfutils/error.h b/system/elfutils/error.h
new file mode 100644
index 000000000..8bae4c7db
--- /dev/null
+++ b/system/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/system/elfutils/fnm.patch b/system/elfutils/fnm.patch
new file mode 100644
index 000000000..654620705
--- /dev/null
+++ b/system/elfutils/fnm.patch
@@ -0,0 +1,13 @@
+--- elfutils-0.192/lib/system.h.old 2024-10-18 14:03:43.000000000 -0500
++++ elfutils-0.192/lib/system.h 2024-11-19 03:40:39.859159871 -0600
+@@ -145,6 +145,10 @@
+ #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666 */
+ #endif
+
++#ifndef FNM_EXTMATCH
++#define FNM_EXTMATCH 0
++#endif
++
+ static inline ssize_t __attribute__ ((unused))
+ pwrite_retry (int fd, const void *buf, size_t len, off_t off)
+ {