github.com/wfusion/gofusion@v1.1.14/common/utils/inspect/moduledata_go118.go (about)

     1  //go:build go1.18 && !go1.21
     2  // +build go1.18,!go1.21
     3  
     4  package inspect
     5  
     6  import (
     7  	_ "unsafe"
     8  )
     9  
    10  // A FuncFlag holds bits about a function.
    11  // This list must match the list in cmd/internal/objabi/funcid.go.
    12  type funcFlag uint8
    13  
    14  type _func struct {
    15  	entryOff    uint32 // start pc
    16  	nameoff     int32  // function name
    17  	args        int32  // in/out args size
    18  	deferreturn uint32 // offset of start of a deferreturn call instruction from entry, if any.
    19  	pcsp        uint32
    20  	pcfile      uint32
    21  	pcln        uint32
    22  	npcdata     uint32
    23  	cuOffset    uint32 // runtime.cutab offset of this function's CU
    24  	funcID      uint8  // set for certain special runtime functions
    25  	flag        funcFlag
    26  	_           [1]byte // pad
    27  	nfuncdata   uint8   // must be last
    28  	argptrs     uint32
    29  	localptrs   uint32
    30  }
    31  
    32  type _funcTab struct {
    33  	entry   uint32
    34  	funcoff uint32
    35  }
    36  
    37  type _pcHeader struct {
    38  	magic          uint32  // 1.18&1.19=0xFFFFFFF0 1.20=0xFFFFFFF1
    39  	pad1, pad2     uint8   // 0,0
    40  	minLC          uint8   // min instruction size
    41  	ptrSize        uint8   // size of a ptr in bytes
    42  	nfunc          int     // number of functions in the module
    43  	nfiles         uint    // number of entries in the file tab
    44  	textStart      uintptr // base for function entry PC offsets in this module, equal to moduledata.text
    45  	funcnameOffset uintptr // offset to the funcnametab variable from pcHeader
    46  	cuOffset       uintptr // offset to the cutab variable from pcHeader
    47  	filetabOffset  uintptr // offset to the filetab variable from pcHeader
    48  	pctabOffset    uintptr // offset to the pctab variable from pcHeader
    49  	pclnOffset     uintptr // offset to the pclntab variable from pcHeader
    50  }
    51  
    52  type _bitVector struct {
    53  	n        int32 // # of bits
    54  	bytedata *uint8
    55  }
    56  
    57  type _ptabEntry struct {
    58  	name nameOff
    59  	typ  typeOff
    60  }
    61  
    62  type _textSection struct {
    63  	vaddr    uintptr // prelinked section vaddr
    64  	end      uintptr // vaddr + section length
    65  	baseaddr uintptr // relocated section address
    66  }
    67  
    68  // moduledata records information about the layout of the executable
    69  // image. It is written by the linker. Any changes here must be
    70  // matched changes to the code in cmd/link/internal/ld/symtab.go:symtab.
    71  // moduledata is stored in statically allocated non-pointer memory;
    72  // none of the pointers here are visible to the garbage collector.
    73  type _moduleData struct {
    74  	pcHeader     *_pcHeader
    75  	funcnametab  []byte
    76  	cutab        []uint32
    77  	filetab      []byte
    78  	pctab        []byte
    79  	pclntable    []byte
    80  	ftab         []_funcTab
    81  	findfunctab  uintptr
    82  	minpc, maxpc uintptr
    83  
    84  	text, etext           uintptr
    85  	noptrdata, enoptrdata uintptr
    86  	data, edata           uintptr
    87  	bss, ebss             uintptr
    88  	noptrbss, enoptrbss   uintptr
    89  	end, gcdata, gcbss    uintptr
    90  	types, etypes         uintptr
    91  	rodata                uintptr
    92  	gofunc                uintptr // go.func.*
    93  
    94  	textsectmap []_textSection
    95  	typelinks   []int32 // offsets from types
    96  	itablinks   []*itab
    97  
    98  	ptab []_ptabEntry
    99  
   100  	pluginpath string
   101  	pkghashes  []_modulehash
   102  
   103  	modulename   string
   104  	modulehashes []_modulehash
   105  
   106  	hasmain uint8 // 1 if module contains the main function, 0 otherwise
   107  
   108  	gcdatamask, gcbssmask _bitVector
   109  
   110  	typemap map[typeOff]*rtype // offset to *_rtype in previous module
   111  
   112  	bad bool // module failed to load and should be ignored
   113  
   114  	next *_moduleData
   115  }
   116  
   117  type _modulehash struct {
   118  	modulename   string
   119  	linktimehash string
   120  	runtimehash  *string
   121  }
   122  
   123  //go:linkname textAddr runtime.(*moduledata).textAddr
   124  func textAddr(md *_moduleData, off32 uint32) uintptr