From: Aaron Merey Date: Tue, 28 Oct 2025 01:49:31 +0000 (-0400) Subject: link_map.c: Declare name_no_sysroot only if openat2 RESOLVE_IN_ROOT is supported X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1bee26c4d7d787eebbebca2a2ad3c5f3d06528a5;p=thirdparty%2Felfutils.git 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 --- 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);