What Is Ld_Preload in Linux?

What Is Ld_Preload in Linux?
Contents

The LD_PRELOAD trick is a useful technique to influence the linkage of shared libraries and the resolution of symbols (functions) at runtime. To explain LD_PRELOAD, let’s first discuss a bit about libraries in the Linux system. In brief, a library is a collection of compiled functions.

How does LD_PRELOAD work?

LD_PRELOAD allows you to override symbols in any library by specifying your new function in a shared object. When you run LD_PRELOAD=/path/to/my/free.so /bin/mybinary , /path/to/my/free.so is loaded before any other library, including libc. When mybinary is executed, it uses your custom function for free .

What does Ld So do?

The program ld.so handles a. out binaries, a binary format used long ago. … 2 for glibc2) handles binaries that are in the more modern ELF format. Both programs have the same behavior, and use the same support files and programs (ldd(1), ldconfig(8), and /etc/ld.

Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.