From: Josh Bleecher Snyder Date: Fri, 24 Sep 2021 01:03:56 +0000 (-0700) Subject: cmd/link: put type descriptor method arginfo in the correct section X-Git-Tag: go1.18beta1~1159 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=52b23a50f8a2028b6155da12161941803abd6198;p=gostls13.git cmd/link: put type descriptor method arginfo in the correct section We were putting type descriptor funcdata, such as type..eq.[2]interface {}.arginfo1 in type.* or typerel.* instead of go.func.*. Fix that. Change-Id: I779e6be3dd91c8029f2c3dc0e10a7d597c16678f Reviewed-on: https://go-review.googlesource.com/c/go/+/352071 Trust: Josh Bleecher Snyder Reviewed-by: Cherry Mui --- diff --git a/src/cmd/link/internal/ld/symtab.go b/src/cmd/link/internal/ld/symtab.go index 1f5e333cfd..924d6fd6c3 100644 --- a/src/cmd/link/internal/ld/symtab.go +++ b/src/cmd/link/internal/ld/symtab.go @@ -537,22 +537,6 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind { name := ldr.SymName(s) switch { - case strings.HasPrefix(name, "type."): - if !ctxt.DynlinkingGo() { - ldr.SetAttrNotInSymbolTable(s, true) - } - if ctxt.UseRelro() { - symGroupType[s] = sym.STYPERELRO - if symtyperel != 0 { - ldr.SetCarrierSym(s, symtyperel) - } - } else { - symGroupType[s] = sym.STYPE - if symtyperel != 0 { - ldr.SetCarrierSym(s, symtype) - } - } - case strings.HasPrefix(name, "go.importpath.") && ctxt.UseRelro(): // Keep go.importpath symbols in the same section as types and // names, as they can be referred to by a section offset. @@ -599,6 +583,25 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind { align = a } liveness += (ldr.SymSize(s) + int64(align) - 1) &^ (int64(align) - 1) + + // Note: Check for "type." prefix after checking for .arginfo1 suffix. + // That way symbols like "type..eq.[2]interface {}.arginfo1" that belong + // in go.func.* end up there. + case strings.HasPrefix(name, "type."): + if !ctxt.DynlinkingGo() { + ldr.SetAttrNotInSymbolTable(s, true) + } + if ctxt.UseRelro() { + symGroupType[s] = sym.STYPERELRO + if symtyperel != 0 { + ldr.SetCarrierSym(s, symtyperel) + } + } else { + symGroupType[s] = sym.STYPE + if symtyperel != 0 { + ldr.SetCarrierSym(s, symtype) + } + } } }