Library Calling in C and Custom glibc
When main.c calls a function defined in lib.c, the compiler can compile main.c without seeing the function’s body. How does that call eventually reach the right instructions? There are two questions here: where the function’s code comes from, and when its address is resolved. We’ll follow the same out_hello() call through object files, a static archive, and a shared library. Then we’ll use that model to load a library ourselves, replace a function with LD_PRELOAD, and run a program against a private glibc build. ...