How to specify ELF shared objects in `LD_PRELOAD` if their path contains a space character?
1
vote
2
answers
51
views
Paths to ELF shared objects in
LD_PRELOAD
cannot contain spaces, as space is one of the two list separators, and it cannot be escaped:
> LD_PRELOAD
>
> A list of additional, user-specified, ELF shared objects to be loaded before all others. This feature can be used to selectively override functions in other shared objects.
>
> The items of the list can be separated by spaces or colons, and there is no support for escaping either separator.
Source: https://manpages.debian.org/bookworm/manpages/ld.so.8.en.html
So assuming I want to execute program myprogram
and preload an ELF shared object from /path/with space/lib/libsomething.so
, then this doesn't work:
$ LD_PRELOAD="/path/with space/lib/libsomething.so" myprogram
ERROR: ld.so: object '/path/with' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object 'space/lib/libsomething.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
...
Asked by finefoot
(3554 rep)
Jun 2, 2025, 12:28 AM
Last activity: Jun 2, 2025, 06:48 AM
Last activity: Jun 2, 2025, 06:48 AM