Can LD_PRELOAD set different symbol definitions for shared objects and executable?

Florian Weimer fweimer@redhat.com
Tue May 25 08:41:43 GMT 2021


* Fengkai Sun via Libc-help:

> For example, if I set LD_PRELOAD="./mymalloc.so", then all references to
> malloc will be interposed. There is no way to specify a custom allocator
> only for shared objects(maybe I can make a difference in the source code of
> custom malloc, but that's off topic).

Yes, LD_* variables are captured at startup, and changing their values
later using setenv etc. does not have an impact on the current process.

> I wonder if there is any way to do this, or if I missed out some
> fundamental ideas.

It is possible to do this using the LD_AUDIT framework.

Thanks,
Florian



More information about the Libc-help mailing list