github.com/eh-steve/goloader@v0.0.0-20240111193454-90ff3cfdae39/functab.1.18.go (about)

     1  //go:build go1.18 && !go1.23
     2  // +build go1.18,!go1.23
     3  
     4  package goloader
     5  
     6  import (
     7  	"unsafe"
     8  
     9  	"github.com/eh-steve/goloader/obj"
    10  )
    11  
    12  type functab struct {
    13  	entry   uint32
    14  	funcoff uint32
    15  }
    16  
    17  func initfunctab(entry, funcoff, text uintptr) functab {
    18  	functabdata := functab{
    19  		entry:   uint32(entry - text),
    20  		funcoff: uint32(funcoff),
    21  	}
    22  	return functabdata
    23  }
    24  
    25  func addfuncdata(module *moduledata, Func *obj.Func, _func *_func) {
    26  	funcdata := make([]uint32, 0)
    27  	for _, v := range Func.FuncData {
    28  		if v != 0 {
    29  			funcdata = append(funcdata, (uint32)(v))
    30  		} else {
    31  			funcdata = append(funcdata, ^uint32(0))
    32  		}
    33  	}
    34  	append2Slice(&module.pclntable, uintptr(unsafe.Pointer(&funcdata[0])), Uint32Size*int(_func.nfuncdata))
    35  }