1
2
3
4
5 package objabi
6
7 import "sync"
8
9
10
11 type PkgSpecial struct {
12
13
14
15
16
17
18
19
20
21
22
23
24
25 Runtime bool
26
27
28
29
30
31 NoInstrument bool
32
33
34
35
36 NoRaceFunc bool
37
38
39
40
41
42 AllowAsmABI bool
43 }
44
45 var runtimePkgs = []string{
46
47
48
49 "runtime",
50
51 "internal/runtime/atomic",
52 "internal/runtime/cgroup",
53 "internal/runtime/exithook",
54 "internal/runtime/gc",
55 "internal/runtime/maps",
56 "internal/runtime/math",
57 "internal/runtime/strconv",
58 "internal/runtime/sys",
59 "internal/runtime/syscall/linux",
60 "internal/runtime/syscall/windows",
61
62 "internal/abi",
63 "internal/bytealg",
64 "internal/byteorder",
65 "internal/chacha8rand",
66 "internal/coverage/rtcov",
67 "internal/cpu",
68 "internal/goarch",
69 "internal/godebugs",
70 "internal/goexperiment",
71 "internal/goos",
72 "internal/profilerecord",
73 "internal/stringslite",
74 }
75
76
77
78 var extraNoInstrumentPkgs = []string{
79 "runtime/race",
80 "runtime/msan",
81 "runtime/asan",
82
83
84
85
86
87 "-internal/bytealg",
88 }
89
90 var noRaceFuncPkgs = []string{"sync", "sync/atomic", "internal/sync", "internal/runtime/atomic"}
91
92 var allowAsmABIPkgs = []string{
93 "runtime",
94 "reflect",
95 "syscall",
96 "internal/bytealg",
97 "internal/chacha8rand",
98 "internal/runtime/syscall/linux",
99 "internal/runtime/syscall/windows",
100 "internal/runtime/startlinetest",
101 }
102
103
104 func LookupPkgSpecial(pkgPath string) PkgSpecial {
105 return pkgSpecialsOnce()[pkgPath]
106 }
107
108 var pkgSpecialsOnce = sync.OnceValue(func() map[string]PkgSpecial {
109
110
111
112 pkgSpecials := make(map[string]PkgSpecial)
113 set := func(elt string, f func(*PkgSpecial)) {
114 s := pkgSpecials[elt]
115 f(&s)
116 pkgSpecials[elt] = s
117 }
118 for _, pkg := range runtimePkgs {
119 set(pkg, func(ps *PkgSpecial) { ps.Runtime = true; ps.NoInstrument = true })
120 }
121 for _, pkg := range extraNoInstrumentPkgs {
122 if pkg[0] == '-' {
123 set(pkg[1:], func(ps *PkgSpecial) { ps.NoInstrument = false })
124 } else {
125 set(pkg, func(ps *PkgSpecial) { ps.NoInstrument = true })
126 }
127 }
128 for _, pkg := range noRaceFuncPkgs {
129 set(pkg, func(ps *PkgSpecial) { ps.NoRaceFunc = true })
130 }
131 for _, pkg := range allowAsmABIPkgs {
132 set(pkg, func(ps *PkgSpecial) { ps.AllowAsmABI = true })
133 }
134 return pkgSpecials
135 })
136
View as plain text