[PATCH v3] elf: Canonicalize $ORIGIN in an explicit ld.so invocation [BZ 25263]
Florian Weimer
fweimer@redhat.com
Wed Mar 19 17:28:05 GMT 2025
* Adhemerval Zanella Netto:
> 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:
This looks like a job for .EXTRA_PREREQS, I think:
<https://www.gnu.org/software/make/manual/html_node/Special-Variables.html#index-_002eEXTRA_005fPREREQS-_0028prerequisites-not-added-to-automatic-variables_0029>
Unfortunately that was only added in make 4.3, which is quite recent.
I think we could add this:
# sofini.os must be placed last since it terminates .eh_frame section.
build-module-helper-objlist = \
$(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
$(filter-out %.lds $(map-file) $(+preinit) $(+postinit) \
+ $(build-module-nolink) \
$(elf-objpfx)sofini.os \
$(link-libc-deps),$^))
and then use:
LDFLAGS-tst-origin += -Wl,-rpath,\$$ORIGIN -L$(subst :, -L,$(rpath-link)) -lorigin-mod
$(objpfx)tst-origin: $(objpfx)liborigin-mod.so
$(objpfx)tst-origin: build-module-nolink = $(objpfx)liborigin-mod.so
But I haven't tested it.
Thanks,
Florian
More information about the Libc-alpha
mailing list