funcdata_go118.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // go:build go1.18 && !go1.20
  2. //go:build go1.18 && !go1.20
  3. // +build go1.18,!go1.20
  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. package loader
  20. import (
  21. `github.com/bytedance/sonic/internal/rt`
  22. )
  23. const (
  24. _Magic uint32 = 0xfffffff0
  25. )
  26. type moduledata struct {
  27. pcHeader *pcHeader
  28. funcnametab []byte
  29. cutab []uint32
  30. filetab []byte
  31. pctab []byte
  32. pclntable []byte
  33. ftab []funcTab
  34. findfunctab uintptr
  35. minpc, maxpc uintptr // first func address, last func address + last func size
  36. text, etext uintptr // start/end of text, (etext-text) must be greater than MIN_FUNC
  37. noptrdata, enoptrdata uintptr
  38. data, edata uintptr
  39. bss, ebss uintptr
  40. noptrbss, enoptrbss uintptr
  41. end, gcdata, gcbss uintptr
  42. types, etypes uintptr
  43. rodata uintptr
  44. gofunc uintptr // go.func.* is actual funcinfo object in image
  45. textsectmap []textSection // see runtime/symtab.go: textAddr()
  46. typelinks []int32 // offsets from types
  47. itablinks []*rt.GoItab
  48. ptab []ptabEntry
  49. pluginpath string
  50. pkghashes []modulehash
  51. modulename string
  52. modulehashes []modulehash
  53. hasmain uint8 // 1 if module contains the main function, 0 otherwise
  54. gcdatamask, gcbssmask bitVector
  55. typemap map[int32]*rt.GoType // offset to *_rtype in previous module
  56. bad bool // module failed to load and should be ignored
  57. next *moduledata
  58. }
  59. type _func struct {
  60. entryOff uint32 // start pc, as offset from moduledata.text/pcHeader.textStart
  61. nameOff int32 // function name, as index into moduledata.funcnametab.
  62. args int32 // in/out args size
  63. deferreturn uint32 // offset of start of a deferreturn call instruction from entry, if any.
  64. pcsp uint32
  65. pcfile uint32
  66. pcln uint32
  67. npcdata uint32
  68. cuOffset uint32 // runtime.cutab offset of this function's CU
  69. funcID uint8 // set for certain special runtime functions
  70. flag uint8
  71. _ [1]byte // pad
  72. nfuncdata uint8 //
  73. // The end of the struct is followed immediately by two variable-length
  74. // arrays that reference the pcdata and funcdata locations for this
  75. // function.
  76. // pcdata contains the offset into moduledata.pctab for the start of
  77. // that index's table. e.g.,
  78. // &moduledata.pctab[_func.pcdata[_PCDATA_UnsafePoint]] is the start of
  79. // the unsafe point table.
  80. //
  81. // An offset of 0 indicates that there is no table.
  82. //
  83. // pcdata [npcdata]uint32
  84. // funcdata contains the offset past moduledata.gofunc which contains a
  85. // pointer to that index's funcdata. e.g.,
  86. // *(moduledata.gofunc + _func.funcdata[_FUNCDATA_ArgsPointerMaps]) is
  87. // the argument pointer map.
  88. //
  89. // An offset of ^uint32(0) indicates that there is no entry.
  90. //
  91. // funcdata [nfuncdata]uint32
  92. }