[PATCH v4 5/5] elf: Allow RPATH/RUNPATH for static-pie
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Fri Jan 30 11:54:54 GMT 2026
On 29/01/26 07:51, Florian Weimer wrote:
> * Adhemerval Zanella:
>
>> The initial static-pie support (commit 9d7a3741c9e59eba87fb) reused
>> ld.so ELF parsing logic, even though RPATH/RUNPATH should not appear
>> in the static-pie bootstrap. With static PIE, RPATH/RUNPATH on the
>> loader typically indicates a toolchain misconfiguration. However,
>> for static PIE, the presence of RPATH/RUNPATH has no impact because
>> these binaries do not use dynamic linking at runtime.
>>
>> Static binaries do not support rpath because they lack dynamic
>> sections, and adding static-pie support affects only the dlopen
>> function. If static dlopen support is removed, this change has no effect.
>>
>> This change also simplifies elf_get_dynamic_info and removes a
>> difference between dynamic and static binaries.
>>
>> Tested on aarch64-linux-gnu and x86_64-linux-gnu.
>
> It's not aligned with our desire to remove static dlopen, but it mostly
> deletes code, so I think the misalignment should not stup us.
>
>> +LDFLAGS-tst-pie-rpath-static += -Wl,-rpath,\$$ORIGIN/tst-pie-rpath-static-subdir
>> +CFLAGS-tst-pie-rpath-static.c += -DPFX=\"$(objpfx)\"
>> +ifeq (no,$(build-hardcoded-path-in-tests))
>> +# Avoid dlopen to search for system files.
>> +LDFLAGS-tst-pie-rpath-mod.so += -Wl,-rpath,$(rpath-link)
>> +endif
>
> The comment seems misleading. Isn't testing RPATH/RUNPATH just the
> purpose of the test?
Right, I will remove it.
More information about the Libc-alpha
mailing list