dev-libs/elfutils: port to Hurd

Bug: https://sourceware.org/PR33974
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sam James
2026-03-19 02:19:48 +00:00
parent e5c2dda796
commit b751e27dd0
2 changed files with 262 additions and 0 deletions

View File

@@ -0,0 +1,161 @@
# Copyright 2003-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/elfutils.gpg
inherit autotools flag-o-matic multilib-minimal
DESCRIPTION="Libraries/utilities to handle ELF objects (drop in replacement for libelf)"
HOMEPAGE="https://sourceware.org/elfutils/"
if [[ ${PV} == 9999 ]] ; then
EGIT_REPO_URI="https://sourceware.org/git/elfutils.git"
inherit git-r3
BDEPEND="
sys-devel/bison
sys-devel/flex
"
else
inherit verify-sig
SRC_URI="https://sourceware.org/elfutils/ftp/${PV}/${P}.tar.bz2"
SRC_URI+=" verify-sig? ( https://sourceware.org/elfutils/ftp/${PV}/${P}.tar.bz2.sig )"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
BDEPEND="verify-sig? ( >=sec-keys/openpgp-keys-elfutils-20240301 )"
fi
LICENSE="|| ( GPL-2+ LGPL-3+ ) utils? ( GPL-3+ )"
SLOT="0"
IUSE="bzip2 +debuginfod +libarchive +lzma nls static-libs stacktrace test +utils valgrind zstd"
RESTRICT="!test? ( test )"
REQUIRED_USE="debuginfod? ( libarchive )"
RDEPEND="
!dev-libs/libelf
>=virtual/zlib-1.2.8-r1:=[static-libs?,${MULTILIB_USEDEP}]
bzip2? ( >=app-arch/bzip2-1.0.6-r4[static-libs?,${MULTILIB_USEDEP}] )
debuginfod? (
dev-db/sqlite:3=
>=dev-libs/json-c-0.11:=
>=net-libs/libmicrohttpd-0.9.33:=
>=net-misc/curl-7.29.0[static-libs?]
)
libarchive? ( >=app-arch/libarchive-3.1.2:= )
lzma? ( >=app-arch/xz-utils-5.0.5-r1[static-libs?,${MULTILIB_USEDEP}] )
stacktrace? ( dev-util/sysprof )
zstd? ( app-arch/zstd:=[static-libs?,${MULTILIB_USEDEP}] )
elibc_musl? (
dev-libs/libbsd
sys-libs/argp-standalone
sys-libs/fts-standalone
sys-libs/obstack-standalone
)
"
DEPEND="
${RDEPEND}
valgrind? ( dev-debug/valgrind )
"
BDEPEND+="
sys-devel/m4
virtual/pkgconfig
nls? ( sys-devel/gettext )
"
PATCHES=(
"${FILESDIR}"/${PN}-0.189-musl-aarch64-regs.patch
"${FILESDIR}"/${PN}-0.191-musl-macros.patch
"${FILESDIR}"/${P}-tests.patch
"${FILESDIR}"/${PN}-0.194-hurd.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
# TODO: Fails with some CFLAGS
# " __divhc3: /var/tmp/portage/dev-libs/elfutils-0.193/work/elfutils-0.193-abi_x86_32.x86/tests/funcretval:
# dwfl_module_return_value_location: cannot handle DWARF type description"
printf "#!/bin/sh\nexit 77" > tests/run-native-test.sh || die
# TODO: Fails for abi_x86_32 w/ DT_RELR
# "section [14] '.rel.plt': relocation 55: relocation type invalid for the file type"
printf "#!/bin/sh\nexit 77" > tests/run-elflint-self.sh || die
printf "#!/bin/sh\nexit 77" > tests/run-reverse-sections-self.sh || die
# TODO: Fails with SFrames
printf "#!/bin/sh\nexit 77" > tests/run-strip-strmerge.sh || die
# https://sourceware.org/PR23914
sed -i 's:-Werror::' */Makefile.in || die
}
src_configure() {
# bug #407135
use test && append-flags -g
# bug 660738
filter-flags -fno-asynchronous-unwind-tables
use debuginfod && MULTILIB_WRAPPED_HEADERS+=( /usr/include/elfutils/debuginfod.h )
multilib-minimal_src_configure
}
multilib_src_configure() {
unset LEX YACC
local myeconfargs=(
$(use_enable nls)
$(multilib_native_use_enable debuginfod)
# Could do dummy if needed? We could also split libdebuginfod
# (client support) into its own USE if required.
$(multilib_native_use_enable debuginfod libdebuginfod)
$(multilib_native_use_enable stacktrace)
$(use_enable valgrind valgrind-annotations)
# Explicitly disable thread safety, it's not recommended by upstream
# (marked experimental in configure) and doesn't build either on musl.
--disable-thread-safety
# Valgrind option is just for running tests under it; dodgy under sandbox
# and indeed even w/ glibc with newer instructions.
--disable-valgrind
--program-prefix="eu-"
--with-zlib
$(use_with bzip2 bzlib)
$(multilib_native_use_with libarchive)
$(use_with lzma)
$(use_with zstd)
)
[[ ${PV} == 9999 ]] && myeconfargs+=( --enable-maintainer-mode )
# Needed because sets alignment macro
is-flagq -fsanitize=address && myeconfargs+=( --enable-sanitize-address )
is-flagq -fsanitize=undefined && myeconfargs+=( --enable-sanitize-undefined )
ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
}
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 we don't
# disable building them when the USE flag is disabled.
if ! use utils; then
rm -rf "${ED}"/usr/bin || die
fi
}

View File

@@ -0,0 +1,101 @@
https://inbox.sourceware.org/elfutils-devel/20260316144817.1722419-1-serhei@serhei.io/
From: Serhei Makarov <serhei@serhei.io>
To: elfutils-devel@sourceware.org
Cc: Serhei Makarov <serhei@serhei.io>
Subject: [PATCH v3] libdwfl/linux-pid-attach.c PR33974: __libdwfl_set_initial_registers_thread on non-Linux
Date: Mon, 16 Mar 2026 10:48:17 -0400
Message-ID: <20260316144817.1722419-1-serhei@serhei.io>
X-Mailer: git-send-email 2.52.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_PASS,SPF_PASS,TXREP,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org
List-Id: <elfutils-devel.sourceware.org>
libdwfl_stacktrace uses __libdwfl_set_initial_registers_thread but it
is wrapped by #ifdef __linux__, causing build errors on non-Linux
platforms.
* linux-pid-attach.c (__libdwfl_set_initial_registers_thread):
Remove from inside the '#ifdef __linux__'.
* dwfl_frame_regs.c (__libdwfl_set_initial_registers_thread):
Move here.
---
libdwfl/dwfl_frame_regs.c | 27 +++++++++++++++++++++++++++
libdwfl/linux-pid-attach.c | 25 -------------------------
2 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/libdwfl/dwfl_frame_regs.c b/libdwfl/dwfl_frame_regs.c
index 572ac676..99de3c22 100644
--- a/libdwfl/dwfl_frame_regs.c
+++ b/libdwfl/dwfl_frame_regs.c
@@ -77,3 +77,30 @@ dwfl_frame_reg (Dwfl_Frame *state, unsigned regno, Dwarf_Word *val)
return res;
}
INTDEF(dwfl_frame_reg)
+
+/* Implement the ebl_set_initial_registers_tid setfunc callback. */
+
+bool
+/* Not internal_function, since that allows calling-convention changes
+ e.g. on i386, and stable ABI is needed to use this as an
+ ebl_tid_registers_t * callback in linux-pid-attach.c and
+ libdwfl_stacktrace. */
+__libdwfl_set_initial_registers_thread (int firstreg, unsigned nregs,
+ const Dwarf_Word *regs, void *arg)
+{
+ Dwfl_Thread *thread = (Dwfl_Thread *) arg;
+ if (firstreg == -1)
+ {
+ assert (nregs == 1);
+ INTUSE(dwfl_thread_state_register_pc) (thread, *regs);
+ return true;
+ }
+ else if (firstreg == -2)
+ {
+ assert (nregs == 1);
+ INTUSE(dwfl_thread_state_registers) (thread, firstreg, nregs, regs);
+ return true;
+ }
+ assert (nregs > 0);
+ return INTUSE(dwfl_thread_state_registers) (thread, firstreg, nregs, regs);
+}
diff --git a/libdwfl/linux-pid-attach.c b/libdwfl/linux-pid-attach.c
index a6e4e41a..9472b041 100644
--- a/libdwfl/linux-pid-attach.c
+++ b/libdwfl/linux-pid-attach.c
@@ -302,31 +302,6 @@ pid_getthread (Dwfl *dwfl __attribute__ ((unused)), pid_t tid,
return true;
}
-/* Implement the ebl_set_initial_registers_tid setfunc callback. */
-
-bool
-/* XXX No internal_function annotation,
- as this function gets passed as ebl_tid_registers_t *. */
-__libdwfl_set_initial_registers_thread (int firstreg, unsigned nregs,
- const Dwarf_Word *regs, void *arg)
-{
- Dwfl_Thread *thread = (Dwfl_Thread *) arg;
- if (firstreg == -1)
- {
- assert (nregs == 1);
- INTUSE(dwfl_thread_state_register_pc) (thread, *regs);
- return true;
- }
- else if (firstreg == -2)
- {
- assert (nregs == 1);
- INTUSE(dwfl_thread_state_registers) (thread, firstreg, nregs, regs);
- return true;
- }
- assert (nregs > 0);
- return INTUSE(dwfl_thread_state_registers) (thread, firstreg, nregs, regs);
-}
-
static bool
pid_set_initial_registers (Dwfl_Thread *thread, void *thread_arg)
{
--
2.52.0