github.com/goshafaq/sonic@v0.0.0-20231026082336-871835fb94c6/loader/funcdata_go120.go (about) 1 //go:build go1.20 && !go1.21 2 // +build go1.20,!go1.21 3 4 /* 5 * Copyright 2021 ByteDance Inc. 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 package loader 21 22 import ( 23 "github.com/goshafaq/sonic/internal/rt" 24 ) 25 26 const ( 27 _Magic uint32 = 0xFFFFFFF1 28 ) 29 30 type moduledata struct { 31 pcHeader *pcHeader 32 funcnametab []byte 33 cutab []uint32 34 filetab []byte 35 pctab []byte 36 pclntable []byte 37 ftab []funcTab 38 findfunctab uintptr 39 minpc, maxpc uintptr // first func address, last func address + last func size 40 41 text, etext uintptr // start/end of text, (etext-text) must be greater than MIN_FUNC 42 noptrdata, enoptrdata uintptr 43 data, edata uintptr 44 bss, ebss uintptr 45 noptrbss, enoptrbss uintptr 46 covctrs, ecovctrs uintptr 47 end, gcdata, gcbss uintptr 48 types, etypes uintptr 49 rodata uintptr 50 gofunc uintptr // go.func.* is actual funcinfo object in image 51 52 textsectmap []textSection // see runtime/symtab.go: textAddr() 53 typelinks []int32 // offsets from types 54 itablinks []*rt.GoItab 55 56 ptab []ptabEntry 57 58 pluginpath string 59 pkghashes []modulehash 60 61 modulename string 62 modulehashes []modulehash 63 64 hasmain uint8 // 1 if module contains the main function, 0 otherwise 65 66 gcdatamask, gcbssmask bitVector 67 68 typemap map[int32]*rt.GoType // offset to *_rtype in previous module 69 70 bad bool // module failed to load and should be ignored 71 72 next *moduledata 73 } 74 75 type _func struct { 76 entryOff uint32 // start pc, as offset from moduledata.text/pcHeader.textStart 77 nameOff int32 // function name, as index into moduledata.funcnametab. 78 79 args int32 // in/out args size 80 deferreturn uint32 // offset of start of a deferreturn call instruction from entry, if any. 81 82 pcsp uint32 83 pcfile uint32 84 pcln uint32 85 npcdata uint32 86 cuOffset uint32 // runtime.cutab offset of this function's CU 87 startLine int32 // line number of start of function (func keyword/TEXT directive) 88 funcID uint8 // set for certain special runtime functions 89 flag uint8 90 _ [1]byte // pad 91 nfuncdata uint8 // 92 93 // The end of the struct is followed immediately by two variable-length 94 // arrays that reference the pcdata and funcdata locations for this 95 // function. 96 97 // pcdata contains the offset into moduledata.pctab for the start of 98 // that index's table. e.g., 99 // &moduledata.pctab[_func.pcdata[_PCDATA_UnsafePoint]] is the start of 100 // the unsafe point table. 101 // 102 // An offset of 0 indicates that there is no table. 103 // 104 // pcdata [npcdata]uint32 105 106 // funcdata contains the offset past moduledata.gofunc which contains a 107 // pointer to that index's funcdata. e.g., 108 // *(moduledata.gofunc + _func.funcdata[_FUNCDATA_ArgsPointerMaps]) is 109 // the argument pointer map. 110 // 111 // An offset of ^uint32(0) indicates that there is no entry. 112 // 113 // funcdata [nfuncdata]uint32 114 }