The gold
linker was designed as an ELF-specific linker, with the intention of producing a more maintainable and faster linker than BFD ld
(the “traditional” GNU binutils linker). As a side-effect, it is indeed able to link very large programs using less memory than BFD ld
, presumably because there are fewer layers of abstraction to deal with, and because the linker’s data structures map more directly to the ELF format.
I’m not sure there’s much documentation which specifically addresses the design differences between the two linkers, and their effect on memory use. There is a very interesting series of articles on linkers by Ian Lance Taylor, the author of the various GNU linkers, which explains many of the design decisions leading up to gold
. He writes that
The linker I am now working, called gold, on will be my third. It is exclusively an ELF linker. Once again, the goal is speed, in this case being faster than my second linker. That linker has been significantly slowed down over the years by adding support for ELF and for shared libraries. This support was patched in rather than being designed in.
(The second linker is BFD ld
.)
ld
was killed by OoM.ld
can easilu consume many GBs of ram on a large C++ projects, whilegold
and especiallylld
linkers are much more resource-efficient.ld
experienced an out of memory error, but the gold linker was able to link it