github.com/szmcdull/go-forceexport@v0.0.0-20230908151957-3dac42f564da/go_1_14.go (about) 1 //go:build !go1.16 2 // +build !go1.16 3 4 package forceexport 5 6 import ( 7 "runtime" 8 "unsafe" 9 ) 10 11 type ( 12 functab struct { 13 entry uintptr 14 funcoff uintptr 15 } 16 17 oldModuleWrapper struct { 18 pclntable []byte 19 ftab []functab 20 filetab []uint32 21 findfunctab uintptr 22 minpc, maxpc uintptr 23 24 text, etext uintptr 25 noptrdata, enoptrdata uintptr 26 data, edata uintptr 27 bss, ebss uintptr 28 noptrbss, enoptrbss uintptr 29 end, gcdata, gcbss uintptr 30 31 // Original type was []*_type 32 typelinks []interface{} 33 34 modulename string 35 // Original type was []modulehash 36 modulehashes []interface{} 37 38 gcdatamask, gcbssmask Bitvector 39 40 next *oldModuleWrapper 41 } 42 43 Bitvector struct { 44 n int32 // # of bits 45 bytedata *uint8 46 } 47 ) 48 49 func (me *oldModuleWrapper) GetFtab() []functab { 50 return me.ftab 51 } 52 53 func (me *oldModuleWrapper) GetFunc(ftab functab) *runtime.Func { 54 return (*runtime.Func)(unsafe.Pointer(&me.pclntable[ftab.funcoff])) 55 } 56 57 func (me *oldModuleWrapper) GetNext() moduleWrapper { 58 if me.next != nil { 59 return (*oldModuleWrapper)(unsafe.Pointer(me.next)) 60 } 61 return nil 62 } 63 64 func getModuleWrapper() moduleWrapper { 65 old := &Firstmoduledata 66 // println(&Firstmoduledata) 67 // println(old) 68 return old 69 } 70 71 //go:linkname Firstmoduledata runtime.firstmoduledata 72 var Firstmoduledata oldModuleWrapper