]> Cypherpunks repositories - gostls13.git/commit
5l, 6l, 8l: omit symbols for type, string, go.string
authorRuss Cox <rsc@golang.org>
Tue, 8 Mar 2011 19:14:28 +0000 (14:14 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 8 Mar 2011 19:14:28 +0000 (14:14 -0500)
commit7a09a88274f054fd522443f97e2f11b568be3b85
treef7122827d0e23036792d88b771e632945b1451da
parent9267b0ddf1ab53338610840268e3f5d2c88b42ae
5l, 6l, 8l: omit symbols for type, string, go.string

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
src/cmd/5l/asm.c
src/cmd/5l/l.h
src/cmd/6l/asm.c
src/cmd/6l/l.h
src/cmd/8l/asm.c
src/cmd/8l/l.h
src/cmd/ld/data.c
src/cmd/ld/dwarf.c
src/cmd/ld/go.c
src/cmd/ld/lib.h
src/cmd/ld/symtab.c