]> Cypherpunks repositories - gostls13.git/commitdiff
cmd, runtime: mark assembly routines in FuncFlags
authorJosh Bleecher Snyder <josharian@gmail.com>
Fri, 1 Oct 2021 23:19:27 +0000 (16:19 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 4 Oct 2021 22:27:40 +0000 (22:27 +0000)
There's no good way to ascertain at runtime whether
a function was implemented in assembly.
The existing workaround doesn't play nicely
with some upcoming linker changes.

This change introduces an explicit marker for routines
implemented in assembly.

This change doesn't use the new bit anywhere,
it only introduces it.

Change-Id: I4051dc0afc15b260724a04b9d18aeeb94911bb29
Reviewed-on: https://go-review.googlesource.com/c/go/+/353671
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/internal/obj/objfile.go
src/cmd/internal/obj/plist.go
src/cmd/internal/objabi/funcid.go
src/runtime/symtab.go

index 3d8d69f069d80e7238d56c1add0cfccc3e8c67ce..4fd2119b965c383a44cf13d56f9cdc8d06ec5dfa 100644 (file)
@@ -772,6 +772,9 @@ func (ctxt *Link) writeSymDebugNamed(s *LSym, name string) {
        if s.Func() != nil && s.Func().FuncFlag&objabi.FuncFlag_TOPFRAME != 0 {
                fmt.Fprintf(ctxt.Bso, "topframe ")
        }
+       if s.Func() != nil && s.Func().FuncFlag&objabi.FuncFlag_ASM != 0 {
+               fmt.Fprintf(ctxt.Bso, "asm ")
+       }
        fmt.Fprintf(ctxt.Bso, "size=%d", s.Size)
        if s.Type == objabi.STEXT {
                fn := s.Func()
index 6beb4dd94cfdc61a9a3716fa6ab7b831fed2ea51..348a16356ebc7f1cd22c71151a10ff27725df5bd 100644 (file)
@@ -156,7 +156,7 @@ func (ctxt *Link) InitTextSym(s *LSym, flag int) {
        }
        name := strings.Replace(s.Name, "\"\"", ctxt.Pkgpath, -1)
        s.Func().FuncID = objabi.GetFuncID(name, flag&WRAPPER != 0 || flag&ABIWRAPPER != 0)
-       s.Func().FuncFlag = toFuncFlag(flag)
+       s.Func().FuncFlag = ctxt.toFuncFlag(flag)
        s.Set(AttrOnList, true)
        s.Set(AttrDuplicateOK, flag&DUPOK != 0)
        s.Set(AttrNoSplit, flag&NOSPLIT != 0)
@@ -172,11 +172,14 @@ func (ctxt *Link) InitTextSym(s *LSym, flag int) {
        ctxt.dwarfSym(s)
 }
 
-func toFuncFlag(flag int) objabi.FuncFlag {
+func (ctxt *Link) toFuncFlag(flag int) objabi.FuncFlag {
        var out objabi.FuncFlag
        if flag&TOPFRAME != 0 {
                out |= objabi.FuncFlag_TOPFRAME
        }
+       if ctxt.IsAsm {
+               out |= objabi.FuncFlag_ASM
+       }
        return out
 }
 
index 68f6a26a76ca4c8deb8d5d4f61e671480c111c8d..084fcdf712159104aca4cc33bed4a940074de696 100644 (file)
@@ -13,6 +13,7 @@ type FuncFlag uint8
 const (
        FuncFlag_TOPFRAME = 1 << iota
        FuncFlag_SPWRITE
+       FuncFlag_ASM
 )
 
 // A FuncID identifies particular functions that need to be treated
index d1fe1a4fcc56103ab42716f06c534d4f6379ea23..14591602a33704eaef011edc5bd92181a5eb5ca4 100644 (file)
@@ -383,6 +383,9 @@ const (
        // to be an incomplete unwinding of the stack. In certain contexts
        // (in particular garbage collector stack scans) that is a fatal error.
        funcFlag_SPWRITE
+
+       // ASM indicates that a function was implemented in assembly.
+       funcFlag_ASM
 )
 
 // pcHeader holds data used by the pclntab lookups.