Specifying multiple files with LD_PRELOAD

CLinuxDynamicX86

C Problem Overview


I know how to override one library with LD_PRELOAD, for example, as follows.

LD_PRELOAD=./getpid.so ./testpid

Now my question is how to override multiple files. Say I want to override both getpid and getid, how would I specify that?

C Solutions


Solution 1 - C

According to the ld.so manpage, it is a space separated list. So:

LD_PRELOAD="path1 path2"
ought to work.

Solution 2 - C

One option is to have the overridden version of both getpid and getid in a single .so which you give to LD_PRELOAD.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMetallicPriestView Question on Stackoverflow
Solution 1 - CWilliam PursellView Answer on Stackoverflow
Solution 2 - CcodaddictView Answer on Stackoverflow