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