Handling Long Branches
Summary
The article explains how modern toolchains handle out-of-range branch targets by coordinating between compilers, assemblers, and linkers. It surveys architecture-specific branch ranges (AArch64, AArch32, PowerPC, RISC-V, x86-64, SPARC), discusses compiler branch relaxation, assembler span/transform relaxation, and linker range extension thunks, and compares thunk algorithms across different linkers (lld-ELF, lld-Mach-O, mold). It also covers diagnostics for relocation out-of-range errors and notes RISC-V relaxation as a size-optimization mechanism.