Gold Feature Complete

I think that the new linker, gold, is now feature complete, and with a bit more testing it should be ready for an open release. I wanted to get it to the point where it could build the Linux kernel. I haven’t actually tested that yet, but it now has everything it needs.

The most painful part was that the Linux kernel build uses many features of GNU linker scripts. gold doesn’t use linker scripts internally, so they had to be bolted onto the side. gold lays out executables in memory in the logical way for ELF: it assigns sections to segments, lays out the segments in memory, and then sets the section offsets based on their position in the segment. Linker scripts, unfortunately, work backward. The linker script effectively lays out the sections in memory, and then the linker has to figure out how to fit the sections into segments. This fitting has been a long set of horrors in the GNU linker, and naive linker scripts often lead to the notorious “not enough room for program headers” error message. Fortunately in gold I could take learn from the current state of affairs in the GNU linker, which is much better than it used to be.

My goal has been to release gold in this quarter, so I should make it.


Posted

in

by

Tags:

Comments

4 responses to “Gold Feature Complete”

  1. Simon Richter Avatar

    Do you know if there was a particular decision behind the old design?

    Also, where can I try it? 🙂

  2. tromey Avatar

    Congratulations, Ian!

  3. Ian Lance Taylor Avatar

    GNU ld linker scripts were designed for COFF. Originally the linker script language was a reasonably close copy of the SVR3 linker, although it has been extended quite a bit since then. COFF doesn’t have anything like ELF segments, so in COFF it makes sense to drive the addressing based on sections.

    GNU ld is built around processing the linker script, so there was no easy way to change it for ELF. The segment support had to be added on top of the sections.

  4. alexr Avatar
    alexr

    As soon as you can link the kernel, I think we’d all love to see a link time comparison. 🙂

Leave a Reply