]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
musl: build-path: fix reading DT_RUNPATH or DT_RPATH
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 6 Sep 2025 03:06:06 +0000 (12:06 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 12 Nov 2025 23:02:05 +0000 (08:02 +0900)
musl records DT_STRTAB as offset, rather than address. So, need to add
obtained bias to read runpath or rpath.

src/basic/build-path.c

index 577ff72bce2585f72aade7995062cf2632181965..321208937924d794e9198d56ddb791735b980918 100644 (file)
@@ -34,11 +34,11 @@ static int get_runpath_from_dynamic(const ElfW(Dyn) *d, ElfW(Addr) bias, const c
                         break;
 
                 case DT_STRTAB:
-                        /* On MIPS and RISC-V DT_STRTAB records an offset, not a valid address, so it has to be adjusted
-                         * using the bias calculated earlier. */
+                        /* On MIPS, RISC-V, or with musl, DT_STRTAB records an offset, not a valid address,
+                         * so it has to be adjusted using the bias calculated earlier. */
                         if (d->d_un.d_val != 0)
                                 strtab = (const char *) ((uintptr_t) d->d_un.d_val
-#if defined(__mips__) || defined(__riscv)
+#if defined(__mips__) || defined(__riscv) || !defined(__GLIBC__)
                                          + bias
 #endif
                                 );