github.com/tencent/goom@v1.0.1/internal/hack/ifunc_16.go (about) 1 //go:build go1.16 && !go1.18 2 // +build go1.16,!go1.18 3 4 // Package hack 对 go 系统包的 hack, 包含一些系统结构体的 copy,需要和不同的 go 版本保持同步 5 package hack 6 7 import ( 8 "unsafe" 9 _ "unsafe" // 匿名引入 10 ) 11 12 // InterceptCallerSkip 拦截器 callerskip 13 const InterceptCallerSkip = 5 14 15 // Firstmoduledata keep async with runtime.Firstmoduledata 16 //go:linkname Firstmoduledata runtime.firstmoduledata 17 var Firstmoduledata Moduledata 18 19 // nolint 20 // Moduledata keep async with runtime.Moduledata 21 type Moduledata struct { 22 pcHeader uintptr 23 funcnametab []byte 24 cutab []uint32 25 filetab []byte 26 pctab []byte 27 Pclntable []byte 28 Ftab []Functab 29 findfunctab uintptr 30 minpc, maxpc uintptr 31 32 text, etext uintptr 33 noptrdata, enoptrdata uintptr 34 data, edata uintptr 35 bss, ebss uintptr 36 noptrbss, enoptrbss uintptr 37 end, gcdata, gcbss uintptr 38 types, etypes uintptr 39 40 textsectmap []textsect 41 typelinks []int32 // offsets from types 42 itablinks []*uintptr 43 44 ptab []interface{} 45 46 pluginpath string 47 pkghashes []interface{} 48 49 modulename string 50 modulehashes []interface{} 51 52 hasmain uint8 // 1 if module contains the main function, 0 otherwise 53 54 gcdatamask, gcbssmask Bitvector 55 56 typemap map[typeOff]*interface{} // offset to *_rtype in previous module 57 58 bad bool // module failed to load and should be ignored 59 60 Next *Moduledata 61 } 62 63 // Functab Functab 64 type Functab struct { 65 Entry uintptr 66 Funcoff uintptr 67 } 68 69 // nolint 70 type textsect struct { 71 // nolint 72 vaddr uintptr // prelinked section vaddr 73 length uintptr // section length 74 baseaddr uintptr // relocated section address 75 } 76 77 // Bitvector Bitvector 78 type Bitvector struct { 79 // nolint 80 n int32 // # of bits 81 // nolint 82 bytedata *uint8 83 } 84 85 // nolint 86 type typeOff int32 // offset to an *rtype 87 88 // Func convenience struct for modifying the underlying code pointer of a function 89 // value. The actual struct has other values, but always starts with a code 90 // pointer. 91 // keep async with runtime.Func 92 type Func struct { 93 CodePtr uintptr 94 } 95 96 // Value reflect.Value 97 // keep async with runtime.Value 98 type Value struct { 99 Typ *uintptr 100 Ptr unsafe.Pointer 101 Flag uintptr 102 }