cmd/link: deduplicate read-only string data
cmd/link: deduplicate read-only string data

Many read-only strings in Go binaries are substrings of other read-only
strings. A common source is the text form of type information, which
will include both "struct { X int }" and "*struct { X int }" or
"*bytes.Reader" and "func(*bytes.Reader)" in the same binary.

Because this character data is referred to by separate string headers,
we can skip writing the smaller string and modify the pointer
relocation to point to the larger string. This CL does this
deduplication in the linker after the reachable set of strings has
been determined.

This removes 765KB from juju (1.4% without DWARF).

Link time goes at tip goes form 4.6s to 6.3s, but note that this CL
is part of a series that recently reduced link time from 9.6s.

For #6853.

Change-Id: Ib2087cf627c9f1e9a1181f9b4c8f81d1a3f42191
Reviewed-on: https://go-review.googlesource.com/19987
Reviewed-by: Ian Lance Taylor <87e9c6d529889242b7e184afb632328636553ab4@golang.org>
Run-TryBot: David Crawshaw <a2f0bf29257797dd66800b4fbb9945c3e216c004@golang.org>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>

akutz/go,theif519/go,golang/go,cloudflare/go,nawawi/go,linux-on-ibm-z/go,miolini/go,Samurais/go,ImJasonH/go,miolini/go,derekmarcotte/go,golang/go,codestation/go,ImJasonH/go,cloudflare/go,vanloswang/go,momchil-velikov/go,vsekhar/elastic-go,vanloswang/go,derekmarcotte/go,polyverse-security/go,ganboing/go-esx,vsekhar/elastic-go,akutz/go,4ad/go,4ad/go,goodlang/good,nawawi/go,derekmarcotte/go,vsekhar/elastic-go,momchil-velikov/go,momchil-velikov/go,Cofyc/go,golang/go,4ad/go,codestation/go,goodlang/good,vsekhar/elastic-go,akutz/go,josharian/go,Cofyc/go,miolini/go,linux-on-ibm-z/go,derekmarcotte/go,ImJasonH/go,nawawi/go,akutz/go,josharian/go,codestation/go,vanloswang/go,suncycheng/go,cloudflare/go,CAFxX/go,ganboing/go-esx,4ad/go,Cofyc/go,polyverse-security/go,vanloswang/go,linux-on-ibm-z/go,golang/go,golang/go,derekmarcotte/go,linux-on-ibm-z/go,momchil-velikov/go,derekmarcotte/go,4ad/go,Samurais/go,4ad/go,CAFxX/go,josharian/go,CAFxX/go,Cofyc/go,cloudflare/go,ganboing/go-esx,josharian/go,momchil-velikov/go,josharian/go,miolini/go,miolini/go,suncycheng/go,nawawi/go,josharian/go,codestation/go,nawawi/go,Cofyc/go,christopher-henderson/Go,linux-on-ibm-z/go,vanloswang/go,vsekhar/elastic-go,vsekhar/elastic-go,derekmarcotte/go,ImJasonH/go,akutz/go,miolini/go,theif519/go,cloudflare/go,Samurais/go,goodlang/good,ganboing/go-esx,golang/go,polyverse-security/go,polyverse-security/go,theif519/go,suncycheng/go,Samurais/go,Cofyc/go,polyverse-security/go,vanloswang/go,CAFxX/go,polyverse-security/go,ganboing/go-esx,miolini/go,CAFxX/go,polyverse-security/go,codestation/go,akutz/go,ganboing/go-esx,nawawi/go,ImJasonH/go,cloudflare/go,theif519/go,CAFxX/go,Samurais/go,Samurais/go,golang/go,codestation/go,ImJasonH/go,momchil-velikov/go,akutz/go,theif519/go,goodlang/good,vsekhar/elastic-go,goodlang/good,polyverse-security/go,4ad/go,suncycheng/go,ganboing/go-esx,Cofyc/go,miolini/go,derekmarcotte/go,nawawi/go,theif519/go,Samurais/go,vanloswang/go,ImJasonH/go,golang/go,theif519/go,suncycheng/go,theif519/go,josharian/go,CAFxX/go,momchil-velikov/go,josharian/go,4ad/go,Cofyc/go,ganboing/go-esx,linux-on-ibm-z/go,Samurais/go,ImJasonH/go,goodlang/good,nawawi/go,suncycheng/go,cloudflare/go,akutz/go,suncycheng/go,vanloswang/go,linux-on-ibm-z/go,momchil-velikov/go,goodlang/good,vsekhar/elastic-go,goodlang/good,codestation/go,codestation/go,cloudflare/go,CAFxX/go,suncycheng/go,linux-on-ibm-z/go