From 3382411d932fb401b88a3b0ce33b74f9a26c8f4d Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Fri, 13 Mar 2020 16:56:00 -0400 Subject: [PATCH] [dev.link] cmd/link: don't set unreachable string variables in addstrdata 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 TryBot-Result: Gobot Gobot Reviewed-by: Jeremy Faller Reviewed-by: Than McIntosh --- src/cmd/link/internal/ld/data.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go index 39ec054ab3..010bfcafc5 100644 --- a/src/cmd/link/internal/ld/data.go +++ b/src/cmd/link/internal/ld/data.go @@ -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) -- 2.50.0