San7o/ld-preload-sample
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
ld-preload-sample ================= Sample program to replace glibc functions (malloc and free) with custom implementations before execution using LD_PRELOAD. Works with any shared library function. Author: Giovanni Santini Mail: giovanni.santini@proton.me License: MIT Usage ----- Normal execution: make run Execution with LD_PRELOAD: make run-preload Explaination ------------ Before executing a program (but after its compilation), the linux dynamic linker `ld-linux.so` finds and loads the shared libraries needed by a program, prepare the program to run, and then run it. If an environment variable `LD_PRELOAD` is specified, the dynamic linker will load the symbols from the libraries specified in the variable first (even before the libc). We can use this to replace some functions with a custom implementation.