• Russ Cox's avatar
    5l, 6l, 8l: omit symbols for type, string, go.string · 7a09a882
    Russ Cox authored
    Much of the bulk of Go binaries is the symbol tables,
    which give a name to every C string, Go string,
    and reflection type symbol.  These names are not worth
    much other than seeing what's where in a binary.
    
    This CL deletes all those names from the symbol table,
    instead aggregating the symbols into contiguous blocks
    and giving them the names "string.*", "go.string.*", and "type.*".
    
    Before:
    $ 6nm $(which godoc.old) | sort | grep ' string\.' | tail -10
      59eda4 D string."aa87ca22be8b05378eb1c71...
      59ee08 D string."b3312fa7e23ee7e4988e056...
      59ee6c D string."func(*token.FileSet, st...
      59eed0 D string."func(io.Writer, []uint8...
      59ef34 D string."func(*tls.Config, *tls....
      59ef98 D string."func(*bool, **template....
      59effc D string."method(p *printer.print...
      59f060 D string."method(S *scanner.Scann...
      59f12c D string."func(*struct { begin in...
      59f194 D string."method(ka *tls.ecdheRSA...
    $
    
    After:
    $ 6nm $(which godoc) | sort | grep ' string\.' | tail -10
      5e6a30 D string.*
    $
    
    Those names in the "Before" are truncated for the CL.
    In the real binary they are the complete string, up to
    a certain length, or else a unique identifier.
    The same applies to the type and go.string symbols.
    
    Removing the names cuts godoc by more than half:
    
    -rwxr-xr-x 1 rsc rsc 9153405 2011-03-07 23:19 godoc.old
    -rwxr-xr-x 1 rsc rsc 4290071 2011-03-07 23:19 godoc
    
    For what it's worth, only 80% of what's left gets loaded
    into memory; the other 20% is dwarf debugging information
    only ever accessed by gdb:
    
    -rwxr-xr-x 1 rsc rsc 3397787 2011-03-07 23:19 godoc.nodwarf
    
    R=r, cw
    CC=golang-dev
    https://golang.org/cl/4245072
    7a09a882
lib.h 6.73 KB