github.com/twelsh-aw/go/src@v0.0.0-20230516233729-a56fe86a7c81/internal/abi/symtab.go (about)

     1  // Copyright 2023 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 abi
     6  
     7  // A FuncFlag records bits about a function, passed to the runtime.
     8  type FuncFlag uint8
     9  
    10  const (
    11  	// FuncFlagTopFrame indicates a function that appears at the top of its stack.
    12  	// The traceback routine stop at such a function and consider that a
    13  	// successful, complete traversal of the stack.
    14  	// Examples of TopFrame functions include goexit, which appears
    15  	// at the top of a user goroutine stack, and mstart, which appears
    16  	// at the top of a system goroutine stack.
    17  	FuncFlagTopFrame FuncFlag = 1 << iota
    18  
    19  	// FuncFlagSPWrite indicates a function that writes an arbitrary value to SP
    20  	// (any write other than adding or subtracting a constant amount).
    21  	// The traceback routines cannot encode such changes into the
    22  	// pcsp tables, so the function traceback cannot safely unwind past
    23  	// SPWrite functions. Stopping at an SPWrite function is considered
    24  	// to be an incomplete unwinding of the stack. In certain contexts
    25  	// (in particular garbage collector stack scans) that is a fatal error.
    26  	FuncFlagSPWrite
    27  
    28  	// FuncFlagAsm indicates that a function was implemented in assembly.
    29  	FuncFlagAsm
    30  )
    31  
    32  // A FuncID identifies particular functions that need to be treated
    33  // specially by the runtime.
    34  // Note that in some situations involving plugins, there may be multiple
    35  // copies of a particular special runtime function.
    36  type FuncID uint8
    37  
    38  const (
    39  	// If you add a FuncID, you probably also want to add an entry to the map in
    40  	// ../../cmd/internal/objabi/funcid.go
    41  
    42  	FuncIDNormal FuncID = iota // not a special function
    43  	FuncID_abort
    44  	FuncID_asmcgocall
    45  	FuncID_asyncPreempt
    46  	FuncID_cgocallback
    47  	FuncID_debugCallV2
    48  	FuncID_gcBgMarkWorker
    49  	FuncID_goexit
    50  	FuncID_gogo
    51  	FuncID_gopanic
    52  	FuncID_handleAsyncEvent
    53  	FuncID_mcall
    54  	FuncID_morestack
    55  	FuncID_mstart
    56  	FuncID_panicwrap
    57  	FuncID_rt0_go
    58  	FuncID_runfinq
    59  	FuncID_runtime_main
    60  	FuncID_sigpanic
    61  	FuncID_systemstack
    62  	FuncID_systemstack_switch
    63  	FuncIDWrapper // any autogenerated code (hash/eq algorithms, method wrappers, etc.)
    64  )
    65  
    66  // ArgsSizeUnknown is set in Func.argsize to mark all functions
    67  // whose argument size is unknown (C vararg functions, and
    68  // assembly code without an explicit specification).
    69  // This value is generated by the compiler, assembler, or linker.
    70  const ArgsSizeUnknown = -0x80000000
    71  
    72  // IDs for PCDATA and FUNCDATA tables in Go binaries.
    73  //
    74  // These must agree with ../../../runtime/funcdata.h.
    75  const (
    76  	PCDATA_UnsafePoint   = 0
    77  	PCDATA_StackMapIndex = 1
    78  	PCDATA_InlTreeIndex  = 2
    79  	PCDATA_ArgLiveIndex  = 3
    80  
    81  	FUNCDATA_ArgsPointerMaps    = 0
    82  	FUNCDATA_LocalsPointerMaps  = 1
    83  	FUNCDATA_StackObjects       = 2
    84  	FUNCDATA_InlTree            = 3
    85  	FUNCDATA_OpenCodedDeferInfo = 4
    86  	FUNCDATA_ArgInfo            = 5
    87  	FUNCDATA_ArgLiveInfo        = 6
    88  	FUNCDATA_WrapInfo           = 7
    89  )
    90  
    91  // Special values for the PCDATA_UnsafePoint table.
    92  const (
    93  	UnsafePointSafe   = -1 // Safe for async preemption
    94  	UnsafePointUnsafe = -2 // Unsafe for async preemption
    95  
    96  	// UnsafePointRestart1(2) apply on a sequence of instructions, within
    97  	// which if an async preemption happens, we should back off the PC
    98  	// to the start of the sequence when resuming.
    99  	// We need two so we can distinguish the start/end of the sequence
   100  	// in case that two sequences are next to each other.
   101  	UnsafePointRestart1 = -3
   102  	UnsafePointRestart2 = -4
   103  
   104  	// Like UnsafePointRestart1, but back to function entry if async preempted.
   105  	UnsafePointRestartAtEntry = -5
   106  )