LD_PRELOAD lists shared libraries with functions that override the standard set, just as /etc/ld.so.preload does. These are implemented by the loader /lib/ld-linux.so. If you want to override just a few selected functions, you can do this by creating an overriding object file and setting LD_PRELOAD; the functions in this object file will override just those functions leaving others as they were.
With LD_PRELOAD you can give libraries precedence.
For example you can write a library which implement malloc and free. And by loading these with LD_PRELOAD your malloc and free will be executed rather than the standard ones.
LD_PRELOAD
lists shared libraries with functions that override the standard set, just as/etc/ld.so.preload
does. These are implemented by the loader/lib/ld-linux.so
. If you want to override just a few selected functions, you can do this by creating an overriding object file and settingLD_PRELOAD
; the functions in this object file will override just those functions leaving others as they were.For more information on shared libraries visit http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
With
LD_PRELOAD
you can give libraries precedence.For example you can write a library which implement
malloc
andfree
. And by loading these withLD_PRELOAD
yourmalloc
andfree
will be executed rather than the standard ones.