[PATCH v3] elf: Canonicalize $ORIGIN in an explicit ld.so invocation [BZ 25263]

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Thu Mar 20 14:11:47 GMT 2025



On 19/03/25 11:47, Adhemerval Zanella Netto wrote:
> 
> 
> On 19/03/25 11:02, Adhemerval Zanella Netto wrote:
>>
>>
>> On 19/03/25 09:42, Joseph Myers wrote:
>>> This still isn't working for me; the build fails with "cannot find 
>>> -lorigin-mod".  (Before 5291d9f1e274dd869bc0b3d044fd4cbae486893d it was 
>>> also broken with a lint-makefiles failure.)
>>>
>>
>> I forgot that rules dependencies are evaluated in no defined order. I am
>> trying to come up a fix, the main issue is making the build with
>> --enable-hardcoded-path-in-tests.
> 
> I had to reinstate a custom rule to avoid the DT_NEEDED with a full path
> and also link tst-origin with built libc:
> 
> diff --git a/elf/Makefile b/elf/Makefile
> index 3d60000ec9..fd73b68308 100644
> --- a/elf/Makefile
> +++ b/elf/Makefile
> @@ -456,7 +456,6 @@ tests += \
>    tst-noload \
>    tst-non-directory-path \
>    tst-null-argv \
> -  tst-origin \
>    tst-p_align1 \
>    tst-p_align2 \
>    tst-p_align3 \
> @@ -3451,8 +3450,15 @@ $(objpfx)tst-dlopen-constructor-null-mod2.so: \
> 
>  CFLAGS-tst-origin.c += $(no-stack-protector)
>  CFLAGS-liborigin-mod.c += $(no-stack-protector)
> -LDFLAGS-tst-origin += -Wl,-rpath,\$$ORIGIN -L$(subst :, -L,$(rpath-link)) -lorigin-mod
> -$(objpfx)tst-origin.out: tst-origin.sh $(objpfx)liborigin-mod.so $(objpfx)tst-origin
> +# The test requires liborigin-mod.so as dependency without a path, which is
> +# added by default.
> +$(objpfx)tst-origin: $(objpfx)tst-origin.o $(objpfx)liborigin-mod.so
> +       $(LINK.o) $(sysdep-LDFLAGS) $(rtld-LDFLAGS) -B$(csu-objpfx) \
> +               $(link-test-modules-rpath-link) \
> +               $(objpfx)tst-origin.o \
> +               -o $@ \
> +               -Wl,-rpath,\$$ORIGIN -L$(subst :, -L,$(rpath-link)) -lorigin-mod
> +$(objpfx)tst-origin.out: tst-origin.sh $(objpfx)tst-origin
>         $(SHELL) \
>                 $< \
>                 '$(common-objpfx)' \

Is this ok to fix this issue Florian? I have tested with and without
--enable-hardcoded-path-in-tests and it seems to work as expected
by fixing the prerequisite rule and creating a dependency without
the full path.


More information about the Libc-alpha mailing list