Relocations: How the Linker Patches Your Code
摘要
When you compile C code into object files, the compiler faces a fundamental problem: it doesn't know the final addresses where functions and variables will reside in the finished executable. The compiler generates machine code that needs to reference these symbols, but their final locations won't be determined until the linking phase. The solution is relocations, which are essentially placeholders that tell the linker exactly how to patch the code once final addresses are known.