Linux Journal: Modifying a Dynamic Library Without Changing the Source Code | Linux Today

Linux Journal: Modifying a Dynamic Library Without Changing the Source Code

Written By
GK
Greg Kroah-Hartman
Nov 4, 2004

“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…'”

Complete
Story

GK

Greg Kroah-Hartman

Linux Today Logo

LinuxToday is a trusted, contributor-driven news resource supporting all types of Linux users. Our thriving international community engages with us through social media and frequent content contributions aimed at solving problems ranging from personal computing to enterprise-level IT operations. LinuxToday serves as a home for a community that struggles to find comparable information elsewhere on the web.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.