github.com/pkujhd/goloader@v0.0.0-20240411034752-1a28096bd7bd/func.1.8.go (about) 1 //go:build go1.8 && !go1.12 2 // +build go1.8,!go1.12 3 4 package goloader 5 6 import "github.com/pkujhd/goloader/obj" 7 8 type _func struct { 9 Entry uintptr // start pc 10 Nameoff int32 // function name 11 12 Args int32 // in/out args size 13 _ int32 // previously legacy frame size; kept for layout compatibility 14 15 Pcsp int32 16 Pcfile int32 17 Pcln int32 18 Npcdata int32 19 Nfuncdata int32 20 } 21 22 func initfunc(symbol *obj.ObjSymbol, nameOff, pcspOff, pcfileOff, pclnOff, cuOff int) _func { 23 fdata := _func{ 24 Entry: uintptr(0), 25 Nameoff: int32(nameOff), 26 Args: int32(symbol.Func.Args), 27 Pcsp: int32(pcspOff), 28 Pcfile: int32(pcfileOff), 29 Pcln: int32(pclnOff), 30 Npcdata: int32(len(symbol.Func.PCData)), 31 Nfuncdata: int32(len(symbol.Func.FuncData)), 32 } 33 return fdata 34 } 35 36 func setfuncentry(f *_func, entry uintptr, text uintptr) { 37 f.Entry = entry 38 } 39 40 func getfuncentry(f *_func, text uintptr) uintptr { 41 return f.Entry 42 } 43 44 func getfuncname(f *_func, md *moduledata) string { 45 if f.Nameoff <= 0 || f.Nameoff >= int32(len(md.pclntable)) { 46 return EmptyString 47 } 48 return gostringnocopy(&(md.pclntable[f.Nameoff])) 49 } 50 51 func getfuncID(f *_func) uint8 { 52 return 0 53 } 54 55 func adaptePCFile(linker *Linker, symbol *obj.ObjSymbol) { 56 rewritePCFile(symbol, linker) 57 }