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