From: Cherry Zhang Date: Fri, 16 Oct 2020 21:37:52 +0000 (-0400) Subject: cmd/link: put C static symbols in the symbol table X-Git-Tag: go1.16beta1~680 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6398b4725caa3867e5f02f344c82a0da53cb750a;p=gostls13.git cmd/link: put C static symbols in the symbol table We don't put Go static symbols in the symbol table, as they are always compiler-generated (there is no way to define a static symbol in user code in Go). We retain static symbols in assembly code, as it may be user-defined. Also retain static symbols in C. Change-Id: Ie0425bb4df33f183857b1fd5ba4b2bdfdc497571 Reviewed-on: https://go-review.googlesource.com/c/go/+/263259 Trust: Cherry Zhang Run-TryBot: Cherry Zhang TryBot-Result: Go Bot Reviewed-by: Than McIntosh --- diff --git a/src/cmd/link/internal/ld/symtab.go b/src/cmd/link/internal/ld/symtab.go index dd82963a41..245a320493 100644 --- a/src/cmd/link/internal/ld/symtab.go +++ b/src/cmd/link/internal/ld/symtab.go @@ -518,7 +518,7 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind { nsym := loader.Sym(ldr.NSym()) symGroupType := make([]sym.SymKind, nsym) for s := loader.Sym(1); s < nsym; s++ { - if !ctxt.IsExternal() && ldr.IsFileLocal(s) && !ldr.IsFromAssembly(s) { + if !ctxt.IsExternal() && ldr.IsFileLocal(s) && !ldr.IsFromAssembly(s) && !ldr.IsExternal(s) { ldr.SetAttrNotInSymbolTable(s, true) } if !ldr.AttrReachable(s) || ldr.AttrSpecial(s) || (ldr.SymType(s) != sym.SRODATA && ldr.SymType(s) != sym.SGOFUNC) {