github.com/tencent/goom@v1.0.1/internal/hack/ifunc_21.go (about)

     1  //go:build go1.21
     2  // +build go1.21
     3  
     4  package hack
     5  
     6  import (
     7  	"unsafe"
     8  	_ "unsafe" // 匿名引入
     9  )
    10  
    11  // InterceptCallerSkip 拦截器 callerskip
    12  const InterceptCallerSkip = 5
    13  
    14  // Firstmoduledata keep async with runtime.Firstmoduledata
    15  //
    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  	NotInHeap // Only in static data
    23  
    24  	pcHeader     *uintptr
    25  	funcnametab  []byte
    26  	cutab        []uint32
    27  	filetab      []byte
    28  	pctab        []byte
    29  	Pclntable    []byte
    30  	Ftab         []Functab
    31  	findfunctab  uintptr
    32  	minpc, maxpc uintptr
    33  
    34  	text, etext           uintptr
    35  	noptrdata, enoptrdata uintptr
    36  	data, edata           uintptr
    37  	bss, ebss             uintptr
    38  	noptrbss, enoptrbss   uintptr
    39  	covctrs, ecovctrs     uintptr
    40  	end, gcdata, gcbss    uintptr
    41  	types, etypes         uintptr
    42  	rodata                uintptr
    43  	gofunc                uintptr // go.func.*
    44  
    45  	textsectmap []textsect
    46  	typelinks   []int32 // offsets from types
    47  	itablinks   []*uintptr
    48  
    49  	ptab []interface{}
    50  
    51  	pluginpath string
    52  	pkghashes  []interface{}
    53  
    54  	// This slice records the initializing tasks that need to be
    55  	// done to start up the program. It is built by the linker.
    56  	inittasks []interface{}
    57  
    58  	modulename   string
    59  	modulehashes []interface{}
    60  
    61  	hasmain uint8 // 1 if module contains the main function, 0 otherwise
    62  
    63  	gcdatamask, gcbssmask Bitvector
    64  
    65  	_ map[typeOff]*interface{} // offset to *_rtype in previous module
    66  
    67  	_ bool // module failed to load and should be ignored
    68  
    69  	Next *Moduledata
    70  }
    71  
    72  type NotInHeap struct{ _ nih }
    73  type nih struct{}
    74  
    75  // Functab Functab
    76  type Functab struct {
    77  	Entry   uint32
    78  	Funcoff uint32
    79  }
    80  
    81  // nolint
    82  type textsect struct {
    83  	// nolint
    84  	vaddr    uintptr // prelinked section vaddr
    85  	length   uintptr // section length
    86  	baseaddr uintptr // relocated section address
    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 typeOff int32 // offset to an *rtype
    99  
   100  // Func convenience struct for modifying the underlying code pointer of a function
   101  // value. The actual struct has other values, but always starts with a code
   102  // pointer.
   103  type Func struct {
   104  	CodePtr uintptr
   105  }
   106  
   107  // Value reflect.Value
   108  type Value struct {
   109  	Typ  *uintptr
   110  	Ptr  unsafe.Pointer
   111  	Flag uintptr
   112  }