]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: put type descriptor method arginfo in the correct section
authorJosh Bleecher Snyder <josharian@gmail.com>
Fri, 24 Sep 2021 01:03:56 +0000 (18:03 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 27 Sep 2021 22:22:04 +0000 (22:22 +0000)
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 <josharian@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/link/internal/ld/symtab.go

index 1f5e333cfd54cd4848f139abf8113e65b825709f..924d6fd6c32655c5c338c5874a14f25599096e20 100644 (file)
@@ -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)
+                               }
+                       }
                }
        }