github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/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 FuncIDNormal FuncID = iota 40 FuncID_abort 41 FuncID_asmcgocall 42 FuncID_asyncPreempt 43 FuncID_cgocallback 44 FuncID_corostart 45 FuncID_debugCallV2 46 FuncID_gcBgMarkWorker 47 FuncID_goexit 48 FuncID_gogo 49 FuncID_gopanic 50 FuncID_handleAsyncEvent 51 FuncID_mcall 52 FuncID_morestack 53 FuncID_mstart 54 FuncID_panicwrap 55 FuncID_rt0_go 56 FuncID_runfinq 57 FuncID_runtime_main 58 FuncID_sigpanic 59 FuncID_systemstack 60 FuncID_systemstack_switch 61 FuncIDWrapper 62 ) 63 64 // ArgsSizeUnknown is set in Func.argsize to mark all functions 65 // whose argument size is unknown (C vararg functions, and 66 // assembly code without an explicit specification). 67 // This value is generated by the compiler, assembler, or linker. 68 const ArgsSizeUnknown = -0x80000000 69 70 // IDs for PCDATA and FUNCDATA tables in Go binaries. 71 // 72 // These must agree with ../../../runtime/funcdata.h. 73 const ( 74 PCDATA_UnsafePoint = 0 75 PCDATA_StackMapIndex = 1 76 PCDATA_InlTreeIndex = 2 77 PCDATA_ArgLiveIndex = 3 78 79 FUNCDATA_ArgsPointerMaps = 0 80 FUNCDATA_LocalsPointerMaps = 1 81 FUNCDATA_StackObjects = 2 82 FUNCDATA_InlTree = 3 83 FUNCDATA_OpenCodedDeferInfo = 4 84 FUNCDATA_ArgInfo = 5 85 FUNCDATA_ArgLiveInfo = 6 86 FUNCDATA_WrapInfo = 7 87 ) 88 89 // Special values for the PCDATA_UnsafePoint table. 90 const ( 91 UnsafePointSafe = -1 92 UnsafePointUnsafe = -2 93 94 // UnsafePointRestart1(2) apply on a sequence of instructions, within 95 // which if an async preemption happens, we should back off the PC 96 // to the start of the sequence when resuming. 97 // We need two so we can distinguish the start/end of the sequence 98 // in case that two sequences are next to each other. 99 UnsafePointRestart1 = -3 100 UnsafePointRestart2 = -4 101 102 // Like UnsafePointRestart1, but back to function entry if async preempted. 103 UnsafePointRestartAtEntry = -5 104 ) 105 106 const MINFUNC = 16 107 108 const FuncTabBucketSize = 256 * MINFUNC