From 7ac64c193d340272e66e0fe979687a2121312a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kl=C3=B6tzke?= Date: Wed, 11 Mar 2026 15:05:38 +0100 Subject: [PATCH] libs::elfutils: fix build with compat-toolchain If the Linux headers of the compiler do not define RESOLVE_IN_ROOT, the build will fail. This is the case with our current host-compat toolchain because the glibc in it is too old. See [1] for the upstream bug report. Work around the problem by cherry-picking the fix. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=33581 Fixes #165. --- recipes/libs/elfutils.yaml | 6 ++- ...lare-name_no_sysroot-only-if-openat2.patch | 51 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 recipes/libs/elfutils/0001-link_map.c-Declare-name_no_sysroot-only-if-openat2.patch diff --git a/recipes/libs/elfutils.yaml b/recipes/libs/elfutils.yaml index 79570e41..10ea0d36 100644 --- a/recipes/libs/elfutils.yaml +++ b/recipes/libs/elfutils.yaml @@ -1,4 +1,4 @@ -inherit: [autotools] +inherit: [autotools, patch] metaEnvironment: PKG_VERSION: "0.194" @@ -16,6 +16,10 @@ checkoutSCM: digestSHA256: 09e2ff033d39baa8b388a2d7fbc5390bfde99ae3b7c67c7daaf7433fbcf0f01e stripComponents: 1 +checkoutDeterministic: True +checkoutScript: | + patchApplySeries $<@elfutils/*.patch@> + buildTools: [m4] buildScript: | mkdir -p all diff --git a/recipes/libs/elfutils/0001-link_map.c-Declare-name_no_sysroot-only-if-openat2.patch b/recipes/libs/elfutils/0001-link_map.c-Declare-name_no_sysroot-only-if-openat2.patch new file mode 100644 index 00000000..817c5039 --- /dev/null +++ b/recipes/libs/elfutils/0001-link_map.c-Declare-name_no_sysroot-only-if-openat2.patch @@ -0,0 +1,51 @@ +From 1bee26c4d7d787eebbebca2a2ad3c5f3d06528a5 Mon Sep 17 00:00:00 2001 +From: Aaron Merey +Date: Mon, 27 Oct 2025 21:49:31 -0400 +Subject: [PATCH] link_map.c: Declare name_no_sysroot only if openat2 + RESOLVE_IN_ROOT is supported + +Rename variable n to name_no_sysroot. Declare name_no_sysroot only if +openat2 RESOLVE_IN_ROOT is supported to avoid an unused variable warning. + +https://sourceware.org/bugzilla/show_bug.cgi?id=33581 + +Signed-off-by: Aaron Merey +--- + libdwfl/link_map.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c +index 013a415d..5f934131 100644 +--- a/libdwfl/link_map.c ++++ b/libdwfl/link_map.c +@@ -431,12 +431,14 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata, + + if (sysroot && !name_in_sysroot) + { +- const char *n = NULL; +- + if (asprintf (&sysroot_name, "%s%s", sysroot, name) < 0) + return release_buffer (&memory_closure, &buffer, &buffer_available, -1); + +- n = name; ++#ifdef HAVE_OPENAT2_RESOLVE_IN_ROOT ++ /* The original name does not contain the sysroot as a prefix. ++ Save this for use with openat2. */ ++ const char *name_no_sysroot = name; ++#endif + name = sysroot_name; + + #ifdef HAVE_OPENAT2_RESOLVE_IN_ROOT +@@ -451,7 +453,8 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata, + if (sysrootfd < 0) + return -1; + +- fd = syscall (SYS_openat2, sysrootfd, n, &how, sizeof(how)); ++ fd = syscall (SYS_openat2, sysrootfd, name_no_sysroot, ++ &how, sizeof(how)); + err = fd < 0 ? -errno : 0; + + close (sysrootfd); +-- +2.43.7 +