]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: don't set unreachable string variables in addstrdata
authorCherry Zhang <cherryyz@google.com>
Fri, 13 Mar 2020 20:56:00 +0000 (16:56 -0400)
committerCherry Zhang <cherryyz@google.com>
Mon, 16 Mar 2020 14:41:53 +0000 (14:41 +0000)
If the variable is not reachable, don't bother setting it.

The old behavior was to set it but not mark it reachable, nor the
string data it points to. This was changed in CL 219226, which
changed the variable and the string data to always reachable.
Typically it shouldn't matter much besides some waste of binary
size. But it does matter on AIX (crash in make.bash). I haven't
looked into why.

Fix AIX build.

Change-Id: I546a0c94ad77b10485ceb66e1288a408e2a2a3e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/223380
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/data.go

index 39ec054ab3d3cd7f4dae619008ed8690e8036e01..010bfcafc52f413579ae9aafeade0e4f409167ec 100644 (file)
@@ -959,6 +959,9 @@ func addstrdata(arch *sys.Arch, l *loader.Loader, name, value string) {
                Errorf(nil, "%s: cannot set with -X: not a var of type string (%s)", name, typeName)
                return
        }
+       if !l.AttrReachable(s) {
+               return // don't bother setting unreachable variable
+       }
        bld := l.MakeSymbolUpdater(s)
        if bld.Type() == sym.SBSS {
                bld.SetType(sym.SDATA)