proposal: LD_PRELOAD for a specific library

Sebastian Wick sebastian@sebastianwick.net
Tue Jun 11 16:40:00 GMT 2013


Hi,

the problem:
I'm working on a project where I want to change the behaviour of all 
applications which use OpenGL (= which load libGL.so). To change the 
bahaviour, I simply load my library first and overwrite dlopen, dlsym 
and the target functions. If you set the LD_PRELOAD enviroment variable 
on login, it may be changed so that the subprocesses don't load the 
library anymore. If you change the config file for preloading 
(/etc/ld.so.preload) my library gets loaded into every process, not only 
the proccesses with OpenGL (applies the first method, too), which works 
but is bad. The only option is the set LD_PRELOAD manually.

a solution:
A new config file and or an enviroment variable which tells ld.so and 
dlopen to load a library exactly before loading a target library. If the 
target library is not loaded by the executable then no action should be 
performed. The behaviour should be similar to LD_PRELOAD.
Furthermore dlsym must not return the address of the function of the 
target library but the address of the function of the preloaded library, 
if the symbol exists in the preloaded library.

I'd like to work on this but I want to hear your input first.

Regards,
Sebastian



More information about the Binutils mailing list