top | item 35693560

(no title)

gabcoh | 2 years ago

Can Linux not trivially do the same thing as windows with LD_PRELOAD? If so why is this more of an issue on Linux than Windows? Is it really less a technical challenge and more just a matter of Linux getting less support from upstream developers?

discuss

order

stabbles|2 years ago

LD_PRELOAD is too global to be useful, it's hard to scope it to one process (and not child processes). macOS is better in the sense that it clears DYLD_* variables when the dynamic linker has done its work and the process starts. (Although that can also be painful when you want to run a shell script and set DYLD_* outside)

nly|2 years ago

You can compile binaries with additional relative library paths in to them that will take priority over /usr/lib64

ungamedplayer|2 years ago

You can set it in the environment for a single process.

bravetraveler|2 years ago

I was thinking/wondering this myself. Not to reinvent the wheel - more toss an idea around, but a 'venv for LD_PRELOAD' sounds like it'd deal with this pretty handily

Not... in a way I'd use as a distribution/release maintainer. Probably as an administrator [of my LAN]

gabcoh|2 years ago

Such things already exist. Eg. Appimage or even docker.

0x457|2 years ago

That's Nix with extra steps.

never_inline|2 years ago

There are tools which overwrite linked libraries, eg: chrpath.

LispSporks22|2 years ago

It can be done by setting rpath to origin, even post compilation using the patchelf tool. Works great with C shared libraries. Perhaps ABI issues with C++ shared libs introduces other problems.

JonChesterfield|2 years ago

With the warning that rpath!=runpath, both are called rpath, and which you get depends on your linker and whether you also pass -Wl,--disable-new-dtags

Runpath is the default, and also the one that is non-transitive and overridden by environment variables.

admax88qqq|2 years ago

Yes linux _can_, the machinery is there, but culturally the common distros do not. And the defaults do not. On windows I can literally drop a DLL next to an executable and it will pick it up. On linux I have to do a wrapper script to set LD_PRELOAD, or mutate the binary's rpath to get it to load.

It's not really a question of capability, but a question of culture and defaults that makes linux hard to support.

Debian for example goes through great pains (or used to at least) to unbundle shared libraries such as openssl from projects like chromium.

aidenn0|2 years ago

This sounds like it's an interaction with the GPU driver though, which could also happen on windows...