Large statically-linked binaries at companies like Google can exceed 25GiB and hit the "2GiB Relocation Barrier" on x86_64. This occurs because the CALL instruction uses a 32-bit signed relative offset, limiting jumps to ±2GiB. When functions are farther apart, the linker fails with relocation overflow errors. The solution is using -mcmodel=large, which replaces 5-byte relative CALLs with 12-byte absolute jumps, causing instruction bloat and increased register pressure. The article demonstrates this problem through practical examples with objdump, readelf, and linker scripts.

7m read timeFrom fzakaria.com
Post cover image

Sort: