...
1
2
3
4
5 package ir
6
7 import (
8 "cmd/compile/internal/base"
9 "cmd/internal/obj"
10 )
11
12
13
14
15
16
17
18
19
20 func InitLSym(f *Func, hasBody bool) {
21 if f.LSym != nil {
22 base.FatalfAt(f.Pos(), "InitLSym called twice on %v", f)
23 }
24
25 if nam := f.Nname; !IsBlank(nam) {
26 f.LSym = nam.LinksymABI(f.ABI)
27 if f.Pragma&Systemstack != 0 {
28 f.LSym.Set(obj.AttrCFunc, true)
29 }
30 }
31 if hasBody {
32 setupTextLSym(f, 0)
33 }
34 }
35
36
37 func setupTextLSym(f *Func, flag int) {
38 if f.Dupok() {
39 flag |= obj.DUPOK
40 }
41 if f.Wrapper() {
42 flag |= obj.WRAPPER
43 }
44 if f.ABIWrapper() {
45 flag |= obj.ABIWRAPPER
46 }
47 if f.Needctxt() {
48 flag |= obj.NEEDCTXT
49 }
50 if f.Pragma&Nosplit != 0 {
51 flag |= obj.NOSPLIT
52 }
53 if f.IsPackageInit() {
54 flag |= obj.PKGINIT
55 }
56
57
58
59
60
61
62
63
64
65
66
67 fnname := f.Sym().Name
68 if base.Ctxt.Pkgpath == "runtime" && fnname == "reflectcall" {
69 flag |= obj.WRAPPER
70 } else if base.Ctxt.Pkgpath == "reflect" {
71 switch fnname {
72 case "callReflect", "callMethod":
73 flag |= obj.WRAPPER
74 }
75 }
76
77 base.Ctxt.InitTextSym(f.LSym, flag, f.Pos())
78 }
79
View as plain text