]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: put C static symbols in the symbol table
authorCherry Zhang <cherryyz@google.com>
Fri, 16 Oct 2020 21:37:52 +0000 (17:37 -0400)
committerCherry Zhang <cherryyz@google.com>
Mon, 19 Oct 2020 13:50:22 +0000 (13:50 +0000)
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 <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/symtab.go

index dd82963a416f61f195ea021ef29de2ed6fa5aa24..245a320493f5537a413c1d9983c6b1f4ab1520d2 100644 (file)
@@ -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) {