• Russ Cox's avatar
    liblink: create new library based on linker code · 7d507dc6
    Russ Cox authored
    There is an enormous amount of code moving around in this CL,
    but the code is the same, and it is invoked in the same ways.
    This CL is preparation for the new linker structure, not the new
    structure itself.
    
    The new library's definition is in include/link.h.
    
    The main change is the use of a Link structure to hold all the
    linker-relevant state, replacing the smattering of global variables.
    The Link structure should both make it clearer which state must
    be carried around and make it possible to parallelize more easily
    later.
    
    The main body of the linker has moved into the architecture-independent
    cmd/ld directory. That includes the list of known header types, so the
    distinction between Hplan9x32 and Hplan9x64 is removed (no other
    header type distinguished 32- and 64-bit formats), and code for unused
    formats such as ipaq kernels has been deleted.
    
    The code being deleted from 5l, 6l, and 8l reappears in liblink or in ld.
    Because multiple files are being merged in the liblink directory,
    it is not possible to show the diffs nicely in hg.
    
    The Prog and Addr structures have been unified into an
    architecture-independent form and moved to link.h, where they will
    be shared by all tools: the assemblers, the compilers, and the linkers.
    The unification makes it possible to write architecture-independent
    traversal of Prog lists, among other benefits.
    
    The Sym structures cannot be unified: they are too fundamentally
    different between the linker and the compilers. Instead, liblink defines
    an LSym - a linker Sym - to be used in the Prog and Addr structures,
    and the linker now refers exclusively to LSyms. The compilers will
    keep using their own syms but will fill out the corresponding LSyms in
    the Prog and Addr structures.
    
    Although code from 5l, 6l, and 8l is now in a single library, the
    code has been arranged so that only one architecture needs to
    be linked into a particular program: 5l will not contain the code
    needed for x86 instruction layout, for example.
    
    The object file writing code in liblink/obj.c is from cmd/gc/obj.c.
    
    Preparation for golang.org/s/go13linker work.
    
    This CL does not build by itself. It depends on 35740044
    and will be submitted at the same time.
    
    R=iant
    CC=golang-dev
    https://golang.org/cl/35790044
    7d507dc6
pe.h 4.67 KB