The .a File Is a Relic: Why Static Archives Were a Bad Idea All Along
10 months ago
- #static linking
- #C programming
- #software development
- The article criticizes static archives (.a files) for being a flawed method for static linking in C-based SDKs.
- Dynamic linking (.so files) allows for easier updates and security fixes without recompilation, while static linking bundles dependencies into the executable.
- Static archives are essentially raw object files (.o) archived together, leading to issues like symbol conflicts and bloated binaries.
- Linker flags like --whole-archive attempt to mitigate issues but introduce new problems, such as unnecessary inclusion of all object files.
- The lack of symbol visibility control in static archives exposes internal functions, posing security and reverse engineering risks.
- The author proposes a new format, 'Static Bundle Object' (.sbo), combining benefits of shared objects with static linking, despite potential binary size increases.
- Transitioning to a new linking format would require widespread toolchain updates and adoption across Linux distributions, a lengthy process.