From 752cc07c77767d28a61525daa359d087b035f5c1 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Fri, 1 Oct 2021 16:19:27 -0700 Subject: [PATCH] cmd, runtime: mark assembly routines in FuncFlags 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 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Cherry Mui --- src/cmd/internal/obj/objfile.go | 3 +++ src/cmd/internal/obj/plist.go | 7 +++++-- src/cmd/internal/objabi/funcid.go | 1 + src/runtime/symtab.go | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/cmd/internal/obj/objfile.go b/src/cmd/internal/obj/objfile.go index 3d8d69f069..4fd2119b96 100644 --- a/src/cmd/internal/obj/objfile.go +++ b/src/cmd/internal/obj/objfile.go @@ -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() diff --git a/src/cmd/internal/obj/plist.go b/src/cmd/internal/obj/plist.go index 6beb4dd94c..348a16356e 100644 --- a/src/cmd/internal/obj/plist.go +++ b/src/cmd/internal/obj/plist.go @@ -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 } diff --git a/src/cmd/internal/objabi/funcid.go b/src/cmd/internal/objabi/funcid.go index 68f6a26a76..084fcdf712 100644 --- a/src/cmd/internal/objabi/funcid.go +++ b/src/cmd/internal/objabi/funcid.go @@ -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 diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go index d1fe1a4fcc..14591602a3 100644 --- a/src/runtime/symtab.go +++ b/src/runtime/symtab.go @@ -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. -- 2.48.1