[dev.link] cmd/compile: pass index through when re-exporting
[dev.link] cmd/compile: pass index through when re-exporting

When we re-export an imported symbol that has an index, we should
pass the index through. Currently, if the symbol is not
referenced in the generated machine code, it does not get
assigned a package index, and the exporter will not export its
symbol index. Let the exporter handle this case -- if the symbol
has a symbol index but not a package index, still export its
symbol index. This is safe as referenced-by-name symbols always
have their package indices set to a special value.

This should reduce the number of referenced-by-name symbols, and
also make the export data more stable, less dependent on codegen
details.

Change-Id: Ic515a002ae84226e7fdbe68a53496c051b7badcc
Reviewed-on: https://go-review.googlesource.com/c/go/+/201719
Run-TryBot: Cherry Zhang <d62e63aa42ce272d7b6a5055d97e942b33a34679@google.com>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Than McIntosh <4b2922593166fc595a9b1a408f34f5d3817fe9d2@google.com>

cloudflare/go,akutz/go,nawawi/go,akutz/go,cloudflare/go,nawawi/go,CAFxX/go,golang/go,akutz/go,nawawi/go,akutz/go,golang/go,cloudflare/go,cloudflare/go,nawawi/go,golang/go,CAFxX/go,nawawi/go,CAFxX/go,nawawi/go,CAFxX/go,golang/go,akutz/go,cloudflare/go,akutz/go,golang/go,golang/go,CAFxX/go,CAFxX/go,akutz/go,nawawi/go,CAFxX/go,nawawi/go,akutz/go,golang/go,cloudflare/go,cloudflare/go,cloudflare/go,golang/go,CAFxX/go