Debian Codegraph @

src/internal/abi/symtab.go

raw
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_runtime_main
60 FuncID_runFinalizers
61 FuncID_runCleanups
62 FuncID_sigpanic
63 FuncID_systemstack
64 FuncID_systemstack_switch
65 FuncIDWrapper // any autogenerated code (hash/eq algorithms, method wrappers, etc.)
66 )
67
68 // ArgsSizeUnknown is set in Func.argsize to mark all functions
69 // whose argument size is unknown (C vararg functions, and
70 // assembly code without an explicit specification).
71 // This value is generated by the compiler, assembler, or linker.
72 const ArgsSizeUnknown = -0x80000000
73
74 // IDs for PCDATA and FUNCDATA tables in Go binaries.
75 //
76 // These must agree with ../../../runtime/funcdata.h.
77 const (
78 PCDATA_UnsafePoint = 0
79 PCDATA_StackMapIndex = 1
80 PCDATA_InlTreeIndex = 2
81 PCDATA_ArgLiveIndex = 3
82
83 FUNCDATA_ArgsPointerMaps = 0
84 FUNCDATA_LocalsPointerMaps = 1
85 FUNCDATA_StackObjects = 2
86 FUNCDATA_InlTree = 3
87 FUNCDATA_OpenCodedDeferInfo = 4
88 FUNCDATA_ArgInfo = 5
89 FUNCDATA_ArgLiveInfo = 6
90 FUNCDATA_WrapInfo = 7
91 )
92
93 // Special values for the PCDATA_UnsafePoint table.
94 const (
95 UnsafePointSafe = -1 // Safe for async preemption
96 UnsafePointUnsafe = -2 // Unsafe for async preemption
97
98 // UnsafePointRestart1(2) apply on a sequence of instructions, within
99 // which if an async preemption happens, we should back off the PC
100 // to the start of the sequence when resuming.
101 // We need two so we can distinguish the start/end of the sequence
102 // in case that two sequences are next to each other.
103 UnsafePointRestart1 = -3
104 UnsafePointRestart2 = -4
105
106 // Like UnsafePointRestart1, but back to function entry if async preempted.
107 UnsafePointRestartAtEntry = -5
108 )
109
110 const MINFUNC = 16 // minimum size for a function
111
112 const FuncTabBucketSize = 256 * MINFUNC // size of bucket in the pc->func lookup table