From 7256f50065f1d53f44c1c9562ad04184ee93279d Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Sat, 12 Oct 2019 01:05:03 -0400 Subject: [PATCH] [dev.link] cmd/link: let cgo import overwrite contentless data symbol A contentless data symbol may be a declaration of a cgo-imported variable, e.g. //go:cgo_import_dynamic xxx var xxx uintptr In this case, we want to mark the symbol imported, instead of defined with zero value. We used to load cgo directives before loading the object file, so we'll mark the symbol SDYNIMPORT first. But in newobj mode, currently we load cgo directives later. Letting SDYNIMPORT overwrite contentless data symbol makes it work in both ordering. Change-Id: I878f52086d6cdb5a347669bf8f848a49bce87b52 Reviewed-on: https://go-review.googlesource.com/c/go/+/201020 Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot Reviewed-by: Jeremy Faller --- src/cmd/link/internal/ld/go.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/link/internal/ld/go.go b/src/cmd/link/internal/ld/go.go index 15d4f9e50f..6c61869ed8 100644 --- a/src/cmd/link/internal/ld/go.go +++ b/src/cmd/link/internal/ld/go.go @@ -197,7 +197,7 @@ func setCgoAttr(ctxt *Link, file string, pkg string, directives [][]string) { remote, q = remote[:i], remote[i+1:] } s := ctxt.Syms.Lookup(local, 0) - if s.Type == 0 || s.Type == sym.SXREF || s.Type == sym.SHOSTOBJ { + if s.Type == 0 || s.Type == sym.SXREF || s.Type == sym.SBSS || s.Type == sym.SNOPTRBSS || s.Type == sym.SHOSTOBJ { s.SetDynimplib(lib) s.SetExtname(remote) s.SetDynimpvers(q) -- 2.48.1