github.com/bir3/gocompiler@v0.9.2202/src/cmd/internal/objabi/funcid.go (about)

     1  // Copyright 2018 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package objabi
     6  
     7  import (
     8  	"github.com/bir3/gocompiler/src/internal/abi"
     9  	"strings"
    10  )
    11  
    12  var funcIDs = map[string]abi.FuncID{
    13  	"abort":		abi.FuncID_abort,
    14  	"asmcgocall":		abi.FuncID_asmcgocall,
    15  	"asyncPreempt":		abi.FuncID_asyncPreempt,
    16  	"cgocallback":		abi.FuncID_cgocallback,
    17  	"corostart":		abi.FuncID_corostart,
    18  	"debugCallV2":		abi.FuncID_debugCallV2,
    19  	"gcBgMarkWorker":	abi.FuncID_gcBgMarkWorker,
    20  	"rt0_go":		abi.FuncID_rt0_go,
    21  	"goexit":		abi.FuncID_goexit,
    22  	"gogo":			abi.FuncID_gogo,
    23  	"gopanic":		abi.FuncID_gopanic,
    24  	"handleAsyncEvent":	abi.FuncID_handleAsyncEvent,
    25  	"main":			abi.FuncID_runtime_main,
    26  	"mcall":		abi.FuncID_mcall,
    27  	"morestack":		abi.FuncID_morestack,
    28  	"mstart":		abi.FuncID_mstart,
    29  	"panicwrap":		abi.FuncID_panicwrap,
    30  	"runfinq":		abi.FuncID_runfinq,
    31  	"sigpanic":		abi.FuncID_sigpanic,
    32  	"systemstack_switch":	abi.FuncID_systemstack_switch,
    33  	"systemstack":		abi.FuncID_systemstack,
    34  
    35  	// Don't show in call stack but otherwise not special.
    36  	"deferreturn":	abi.FuncIDWrapper,
    37  }
    38  
    39  // Get the function ID for the named function in the named file.
    40  // The function should be package-qualified.
    41  func GetFuncID(name string, isWrapper bool) abi.FuncID {
    42  	if isWrapper {
    43  		return abi.FuncIDWrapper
    44  	}
    45  	if strings.HasPrefix(name, "runtime.") {
    46  		if id, ok := funcIDs[name[len("runtime."):]]; ok {
    47  			return id
    48  		}
    49  	}
    50  	return abi.FuncIDNormal
    51  }