Linux Journal: Modifying a Dynamic Library Without Changing the Source Code
Nov 04, 2004, 07:00 (0 Talkback[s])
(Other stories by Greg Kroah-Hartman)
WEBINAR: On-demand webcast
How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >
"Sometimes, you might want to determine what is happening in a
shared library without modifying the library (have you tried to
build glibc lately?). Other times, you might want to override only
a few functions within a library and get them to do something
else--force a process to a specific CPU, prevent a specific USB
message from being sent and so on. All of these tasks are possible
if you use the LD_PRELOAD environment variable and a small shim
program placed between the application and the library.
"As an example, say you create a shared library object called
shim.so and want it to be loaded before any other shared library.
Say you also want to run the program 'test...'"