Summary
Linking in CMake might initially appear straightforward, but as we dig deeper, we see there’s much more beneath the surface. After all, linking executables isn’t as simple as piecing puzzle parts together. When we delve deep into the structure of object files and libraries, it’s clear that sections, which store various types of data, instructions, symbol names, and the like, need some reordering. Before a program is runnable, these sections undergo what’s known as relocation.
It’s also crucial to resolve symbols. The linker must sort through references across all translation units, ensuring nothing’s left out. Once this is settled, the linker then creates the program header and places it into the final executable. This header offers instructions to the system loader, detailing how to transform consolidated sections into segments that will make up the runtime memory image of the process. We also discussed the three kinds of libraries...