C++ Linkers and the One Definition Rule
summary
Linking is unpacked with concrete examples on Windows and Linux: compile to object, use ar/lib to make static archives, or build DLL/so and resolve via PLT/GOT at load time; object file 1.6KB linking to an 8.3KB binary (~80× source), x86-64 relative calls limited to 32-bit (2GB) offsets, syscalls during startup measured 28 vs 284 (Linux vs Windows), tools used include nm/dumpbin/readelf/objdump/strace and Godbolt, symbol hijack demonstrated via LD_PRELOAD, and exports tightened with GCC visibility attribute.
AI-written summary · about
chapters (11)
- 0:00Linkers and ODR
- 1:13Why linkers in C++
- 10:02Symbol resolution in linkers
- 21:01Address space randomization
- 30:15Linking source files
- 37:44Static libraries benefits
- 39:32Shared libraries trade-offs
- 56:20Windows vs Linux shared libs
- 1:01:20One Definition Rule
- 1:18:13Security risks with shared libs
- 1:21:08Key takeaways
related talks
01h 26mWhat Does the Linker Actually Do for Us?
01h 04mThe Bits Between the Bits: How We Get to main()
01h 03mBack to Basics: Compiling and Linking
43mRust Unlinked: Rustc, Symbols, and Static Libraries
01h 00mFrom Program to Process - What Happens After the Compiler
01mTalk Preview: How Symbols Work and Why We Need Them
14mGuided Linking: Dynamic Linking without the Costs
24m(Ab)using Compiler Tools
