]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: put C static symbols in the symbol table, attempt 2
authorCherry Zhang <cherryyz@google.com>
Thu, 29 Oct 2020 02:46:41 +0000 (22:46 -0400)
committerCherry Zhang <cherryyz@google.com>
Thu, 29 Oct 2020 22:44:12 +0000 (22:44 +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.

This is the second attempt of CL 263259, which was reverted
because it broke AIX tests in that it brought TOC.stmp symbols
in the symbol table. This time we use SymPkg(s) == "" to identify
non-Go symbols, instead of IsExternal(s), as the latter also
includes linker-modified Go symbols.

Change-Id: I5c752c54f0fc6ac4cde6a0e8161dac5b72a47d56
Reviewed-on: https://go-review.googlesource.com/c/go/+/266237
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/symtab.go

index 2e2e392c59b781dd24905a1d80374a21164a5472..49713896138a7faa0d7cd463eb29b3e9bb1615a8 100644 (file)
@@ -519,7 +519,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.SymPkg(s) != "" {
                        ldr.SetAttrNotInSymbolTable(s, true)
                }
                if !ldr.AttrReachable(s) || ldr.AttrSpecial(s) || (ldr.SymType(s) != sym.SRODATA && ldr.SymType(s) != sym.SGOFUNC) {