Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Tue, 21 Dec 2021 10:56:33 -0800
From: Farid Zakaria <>
Cc: "Scogland, Tom" <>, Carlos Maltzahn <>
Subject: Dynamic linking of NEEDED with absolute path differs than that of glibc


I am working, along with Tom <> on a contribution to
patchelf[1] that takes all the NEEDED from downstream shared object
dependencies and lifts them to the top executable. I then change the
NEEDED in the top executable to be absolute paths. This seems to work
as expected in glibc.

Please use this example for demonstrations:

Here I have two shared objects libbar and libfoo, where foo depends on bar.
> patchelf --print-needed
> patchelf --print-soname

> patchelf --print-needed

I then add libbar and libfoo to another executable but reference them
in NEEDED with explicit paths.
> patchelf --print-needed tests/scratch/replace-add-needed/simple

glibc seems to happily link this and the executable runs.
ldd ./tests/scratch/replace-add-needed/simple (0x00007ffc98d98000)
/some-fixed-path/ (0x00007f269b6d3000)
/some-fixed-path/ (0x00007f269b6ce000)
/lib/x86_64-linux-gnu/ (0x00007f269b509000)
/lib64/ (0x00007f269c6e3000)

If I do the same however with musl it doesn't seem to link and
complains about not finding
ldd ./tests/scratch/replace-add-needed/simple
/lib/ (0x7f04dd7cd000)
/some-fixed-path/ (0x7f04dc7bf000)
/some-fixed-path/ (0x7f04dc7ba000) => /lib/ (0x7f04dd7cd000)
Error loading shared library No such file or directory
(needed by /some-fixed-path/

Tom helped track this down due to the shortname assignment behavior[2]

This is clearly safer than what it was doing before that, but would
musl be open to either:
 1 - Using the contents of DT_SONAME if set, which matches the
behavior of glibc at least from observation, or
 2- Using a shortname based on the basename of the path even for
path-based loading?

It also seems that there are issues similar to this on the mailing
list recently as well [3] and a bit of a discussion from Rich
on the Julia Github repository that sounds similar [4].

Thank you!
Farid Zakaria


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.