forked from goretk/gore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
moduledata.go
914 lines (728 loc) · 26.1 KB
/
moduledata.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
// This file is part of GoRE.
//
// Copyright (C) 2019-2022 GoRE Authors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package gore
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"io"
"reflect"
)
// Moduledata extracts the file's moduledata.
func (f *GoFile) Moduledata() (Moduledata, error) {
// We need the Go version to be defined to find the module data.
ver, err := f.GetCompilerVersion()
if err != nil {
return nil, fmt.Errorf("could not get the Go version for the moduledata extraction: %w", err)
}
f.FileInfo.goversion = ver
md, err := parseModuledata(f.FileInfo, f.fh)
if err != nil {
return nil, fmt.Errorf("error when parsing the moduledata: %w", err)
}
return md, nil
}
// Moduledata holds information about the layout of the executable image in memory.
type Moduledata interface {
// Text returns the text secion.
Text() ModuleDataSection
// NoPtrData returns the noptrdata section.
NoPtrData() ModuleDataSection
// Data returns the data section.
Data() ModuleDataSection
// Bss returns the bss section.
Bss() ModuleDataSection
// NoPtrBss returns the noptrbss section.
NoPtrBss() ModuleDataSection
// Types returns the types section.
Types() ModuleDataSection
// PCLNTab returns the pclntab section.
PCLNTab() ModuleDataSection
// FuncTab returns the functab section.
FuncTab() ModuleDataSection
// ITabLinks returns the itablinks section.
ITabLinks() ModuleDataSection
// TypeLink returns the typelink section.
TypeLink() ([]int32, error)
// GoFuncValue returns the value of the 'go:func.*' symbol.
GoFuncValue() uint64
}
type moduledata struct {
TextAddr, TextLen uint64
NoPtrDataAddr, NoPtrDataLen uint64
DataAddr, DataLen uint64
BssAddr, BssLen uint64
NoPtrBssAddr, NoPtrBssLen uint64
TypesAddr, TypesLen uint64
TypelinkAddr, TypelinkLen uint64
ITabLinkAddr, ITabLinkLen uint64
FuncTabAddr, FuncTabLen uint64
PCLNTabAddr, PCLNTabLen uint64
GoFuncVal uint64
fh fileHandler
}
// Text returns the text secion.
func (m moduledata) Text() ModuleDataSection {
return ModuleDataSection{
Address: m.TextAddr,
Length: m.TextLen,
fh: m.fh,
}
}
// NoPtrData returns the noptrdata section.
func (m moduledata) NoPtrData() ModuleDataSection {
return ModuleDataSection{
Address: m.NoPtrDataAddr,
Length: m.NoPtrDataLen,
fh: m.fh,
}
}
// Data returns the data section.
func (m moduledata) Data() ModuleDataSection {
return ModuleDataSection{
Address: m.DataAddr,
Length: m.DataLen,
fh: m.fh,
}
}
// Bss returns the bss section.
func (m moduledata) Bss() ModuleDataSection {
return ModuleDataSection{
Address: m.BssAddr,
Length: m.BssLen,
fh: m.fh,
}
}
// NoPtrBss returns the noptrbss section.
func (m moduledata) NoPtrBss() ModuleDataSection {
return ModuleDataSection{
Address: m.NoPtrBssAddr,
Length: m.NoPtrBssLen,
fh: m.fh,
}
}
// Types returns the types section.
func (m moduledata) Types() ModuleDataSection {
return ModuleDataSection{
Address: m.TypesAddr,
Length: m.TypesLen,
fh: m.fh,
}
}
// PCLNTab returns the pclntab section.
func (m moduledata) PCLNTab() ModuleDataSection {
return ModuleDataSection{
Address: m.PCLNTabAddr,
Length: m.PCLNTabLen,
fh: m.fh,
}
}
// FuncTab returns the functab section.
func (m moduledata) FuncTab() ModuleDataSection {
return ModuleDataSection{
Address: m.FuncTabAddr,
Length: m.FuncTabLen,
fh: m.fh,
}
}
// ITabLinks returns the itablinks section.
func (m moduledata) ITabLinks() ModuleDataSection {
return ModuleDataSection{
Address: m.ITabLinkAddr,
Length: m.ITabLinkLen,
fh: m.fh,
}
}
// TypeLink returns the typelink section.
func (m moduledata) TypeLink() ([]int32, error) {
base, data, err := m.fh.getSectionDataFromOffset(m.TypelinkAddr)
if err != nil {
return nil, fmt.Errorf("failed to get the typelink data section: %w", err)
}
r := bytes.NewReader(data[m.TypelinkAddr-base:])
a := make([]int32, 0, m.TypelinkLen)
bo := m.fh.getFileInfo().ByteOrder
for i := uint64(0); i < m.TypelinkLen; i++ {
// Type offsets are always int32
var off int32
err = binary.Read(r, bo, &off)
if err != nil {
return nil, fmt.Errorf("failed to read typelink item %d: %w", i, err)
}
a = append(a, off)
}
return a, nil
}
// GoFuncValue returns the value of the "go:func.*" symbol.
func (m moduledata) GoFuncValue() uint64 {
return m.GoFuncVal
}
// ModuleDataSection is a section defined in the Moduledata structure.
type ModuleDataSection struct {
// Address is the virtual address where the section start.
Address uint64
// Length is the byte length for the data in this section.
Length uint64
fh fileHandler
}
// Data returns the data in the section.
func (m ModuleDataSection) Data() ([]byte, error) {
// If we don't have any data, return an empty slice.
if m.Length == 0 {
return []byte{}, nil
}
base, data, err := m.fh.getSectionDataFromOffset(m.Address)
if err != nil {
return nil, fmt.Errorf("getting module data section failed: %w", err)
}
start := m.Address - base
if uint64(len(data)) < start+m.Length {
return nil, fmt.Errorf("the length of module data section is to big: address 0x%x, base 0x%x, length 0x%x", m.Address, base, m.Length)
}
buf := make([]byte, m.Length)
copy(buf, data[start:start+m.Length])
return buf, nil
}
func findModuledata(f fileHandler) ([]byte, error) {
_, secData, err := f.getSectionData(f.moduledataSection())
if err != nil {
return nil, err
}
tabAddr, _, err := f.getPCLNTABData()
if err != nil {
return nil, err
}
// Search for moduledata
buf := new(bytes.Buffer)
err = binary.Write(buf, binary.LittleEndian, &tabAddr)
if err != nil {
return nil, err
}
off := bytes.Index(secData, buf.Bytes()[:intSize32])
if off == -1 {
return nil, errors.New("could not find moduledata")
}
// TODO: Verify that hit is correct.
return secData[off : off+0x300], nil
}
func parseModuledata(fileInfo *FileInfo, f fileHandler) (moduledata, error) {
data, err := findModuledata(f)
if err != nil {
return moduledata{}, err
}
// buf will hold the struct type that represents the data in the file we are processing.
var buf interface{}
is32bit := fileInfo.WordSize == intSize32
// Determine what kind of struct we need to extract the module data from the file.
if GoVersionCompare("go1.20rc1", fileInfo.goversion.Name) <= 0 {
if is32bit {
buf = &moduledata2032{}
} else {
buf = &moduledata2064{}
}
} else if GoVersionCompare("go1.18beta1", fileInfo.goversion.Name) <= 0 {
if is32bit {
buf = &moduledata1832{}
} else {
buf = &moduledata1864{}
}
} else if GoVersionCompare("go1.16beta1", fileInfo.goversion.Name) <= 0 {
if is32bit {
buf = &moduledata1632{}
} else {
buf = &moduledata1664{}
}
} else if GoVersionCompare("go1.8beta1", fileInfo.goversion.Name) <= 0 {
if is32bit {
buf = &moduledata832{}
} else {
buf = &moduledata864{}
}
} else if GoVersionCompare("go1.7beta1", fileInfo.goversion.Name) <= 0 {
if is32bit {
buf = &moduledata732{}
} else {
buf = &moduledata764{}
}
} else {
if is32bit {
buf = &moduledata532{}
} else {
buf = &moduledata564{}
}
}
// Read the module struct from the file.
r := bytes.NewReader(data)
err = readStruct(r, fileInfo.ByteOrder, buf)
if err != nil {
return moduledata{}, fmt.Errorf("error when reading module data from file: %w", err)
}
// Convert the read struct to the type we return to the caller.
md, err := processModuledata(buf)
if err != nil {
return md, fmt.Errorf("error when processing module data: %w", err)
}
// Add the file handler.
md.fh = f
return md, nil
}
func readUIntTo64(r io.Reader, byteOrder binary.ByteOrder, is32bit bool) (uint64, error) {
if is32bit {
var addr uint32
err := binary.Read(r, byteOrder, &addr)
return uint64(addr), err
}
var addr uint64
err := binary.Read(r, byteOrder, &addr)
return addr, err
}
// readStruct performs a binary read from the reader to the data object. Data object must
// be a pointer to the struct.
func readStruct(r io.Reader, byteOrder binary.ByteOrder, data interface{}) error {
return binary.Read(r, byteOrder, data)
}
func processModuledata(data interface{}) (moduledata, error) {
md := moduledata{}
// This will panic if the data passed in is not a pointer to
// a struct. But this function should not be called outside
// of this file, we can ensure this is always the case.
val := reflect.ValueOf(data).Elem()
extractModFieldValue(&md, "TextAddr", val, "Text")
extractModFieldValue(&md, "TextLen", val, "Etext")
if md.TextLen > md.TextAddr {
md.TextLen = md.TextLen - md.TextAddr
}
extractModFieldValue(&md, "NoPtrDataAddr", val, "Noptrdata")
extractModFieldValue(&md, "NoPtrDataLen", val, "Enoptrdata")
if md.NoPtrDataLen > md.NoPtrDataAddr {
md.NoPtrDataLen = md.NoPtrDataLen - md.NoPtrDataAddr
}
extractModFieldValue(&md, "DataAddr", val, "Data")
extractModFieldValue(&md, "DataLen", val, "Edata")
if md.DataLen > md.DataAddr {
md.DataLen = md.DataLen - md.DataAddr
}
extractModFieldValue(&md, "BssAddr", val, "Bss")
extractModFieldValue(&md, "BssLen", val, "Ebss")
if md.BssLen > md.BssAddr {
md.BssLen = md.BssLen - md.BssAddr
}
extractModFieldValue(&md, "NoPtrBssAddr", val, "Noptrbss")
extractModFieldValue(&md, "NoPtrBssLen", val, "Enoptrbss")
if md.NoPtrBssLen > md.NoPtrBssAddr {
md.NoPtrBssLen = md.NoPtrBssLen - md.NoPtrBssAddr
}
extractModFieldValue(&md, "TypelinkAddr", val, "Typelinks")
extractModFieldValue(&md, "TypelinkLen", val, "Typelinkslen")
extractModFieldValue(&md, "ITabLinkAddr", val, "Itablinks")
extractModFieldValue(&md, "ITabLinkLen", val, "Itablinkslen")
extractModFieldValue(&md, "FuncTabAddr", val, "Ftab")
extractModFieldValue(&md, "FuncTabLen", val, "Ftablen")
extractModFieldValue(&md, "PCLNTabAddr", val, "Pclntable")
extractModFieldValue(&md, "PCLNTabLen", val, "Pclntablelen")
extractModFieldValue(&md, "TypesAddr", val, "Types")
extractModFieldValue(&md, "TypesLen", val, "Etypes")
if md.TypesLen > md.TypesAddr {
md.TypesLen = md.TypesLen - md.TypesAddr
}
extractModFieldValue(&md, "GoFuncVal", val, "GoFunc")
return md, nil
}
func extractModFieldValue(md *moduledata, dst string, val reflect.Value, src string) {
field := val.FieldByName(src)
// Not all versions of the module struct has all the fields. If we don't have the
// field, we skip it.
if !field.IsValid() {
return
}
// Save 32 to 64 uint casting if needed.
var num uint64
switch field.Interface().(type) {
case uint64:
num = field.Uint()
case uint32:
t := field.Interface().(uint32)
num = uint64(t)
}
// Set the value.
mdField := reflect.ValueOf(md).Elem().FieldByName(dst)
mdField.SetUint(num)
}
/*
Internal module structures from Go's runtime.
*/
// Moduledata structure for Go 1.20 and newer
type moduledata2064 struct {
PcHeader uint64
Funcnametab, Funcnametablen, Funcnametabcap uint64
Cutab, Cutablen, Cutabcap uint64
Filetab, Filetablen, Filetabcap uint64
Pctab, Pctablen, Pctabcap uint64
Pclntable, Pclntablelen, Pclntablecap uint64
Ftab, Ftablen, Ftabcap uint64
Findfunctab uint64
Minpc, Maxpc uint64
Text, Etext uint64
Noptrdata, Enoptrdata uint64
Data, Edata uint64
Bss, Ebss uint64
Noptrbss, Enoptrbss uint64
Covctrs, Ecovctrs uint64
End, Gcdata, Gcbss uint64
Types, Etypes uint64
RData uint64
GoFunc uint64
Textsectmap, Textsectmaplen, Textsectmapcap uint64
Typelinks, Typelinkslen, Typelinkscap uint64 // offsets from types
Itablinks, Itablinkslen, Itablinkscap uint64
Ptab, Ptablen, Ptabcap uint64
Pluginpath, Pluginpathlen uint64
Pkghashes, Pkghasheslen, Pkghashescap uint64
Modulename, Modulenamelen uint64
Modulehashes, Modulehasheslen, Modulehashescap uint64
/* These fields we are not planning to use so skipping the parsing of them.
hasmain uint8 // 1 if module contains the main function, 0 otherwise
gcdatamask, gcbssmask bitvector
typemap map[typeOff]*_type // offset to *_rtype in previous module
bad bool // module failed to load and should be ignored
next *moduledata
*/
}
type moduledata2032 struct {
PcHeader uint32
Funcnametab, Funcnametablen, Funcnametabcap uint32
Cutab, Cutablen, Cutabcap uint32
Filetab, Filetablen, Filetabcap uint32
Pctab, Pctablen, Pctabcap uint32
Pclntable, Pclntablelen, Pclntablecap uint32
Ftab, Ftablen, Ftabcap uint32
Findfunctab uint32
Minpc, Maxpc uint32
Text, Etext uint32
Noptrdata, Enoptrdata uint32
Data, Edata uint32
Bss, Ebss uint32
Noptrbss, Enoptrbss uint32
Covctrs, Ecovctrs uint32
End, Gcdata, Gcbss uint32
Types, Etypes uint32
RData uint32
GoFunc uint32
Textsectmap, Textsectmaplen, Textsectmapcap uint32
Typelinks, Typelinkslen, Typelinkscap uint32 // offsets from types
Itablinks, Itablinkslen, Itablinkscap uint32
Ptab, Ptablen, Ptabcap uint32
Pluginpath, Pluginpathlen uint32
Pkghashes, Pkghasheslen, Pkghashescap uint32
Modulename, Modulenamelen uint32
Modulehashes, Modulehasheslen, Modulehashescap uint32
/* These fields we are not planning to use so skipping the parsing of them.
hasmain uint8 // 1 if module contains the main function, 0 otherwise
gcdatamask, gcbssmask bitvector
typemap map[typeOff]*_type // offset to *_rtype in previous module
bad bool // module failed to load and should be ignored
next *moduledata
*/
}
// Moduledata structure for Go 1.18 and Go 1.19
type moduledata1864 struct {
PcHeader uint64
Funcnametab, Funcnametablen, Funcnametabcap uint64
Cutab, Cutablen, Cutabcap uint64
Filetab, Filetablen, Filetabcap uint64
Pctab, Pctablen, Pctabcap uint64
Pclntable, Pclntablelen, Pclntablecap uint64
Ftab, Ftablen, Ftabcap uint64
Findfunctab uint64
Minpc, Maxpc uint64
Text, Etext uint64
Noptrdata, Enoptrdata uint64
Data, Edata uint64
Bss, Ebss uint64
Noptrbss, Enoptrbss uint64
End, Gcdata, Gcbss uint64
Types, Etypes uint64
RData uint64
GoFunc uint64
Textsectmap, Textsectmaplen, Textsectmapcap uint64
Typelinks, Typelinkslen, Typelinkscap uint64 // offsets from types
Itablinks, Itablinkslen, Itablinkscap uint64
Ptab, Ptablen, Ptabcap uint64
Pluginpath, Pluginpathlen uint64
Pkghashes, Pkghasheslen, Pkghashescap uint64
Modulename, Modulenamelen uint64
Modulehashes, Modulehasheslen, Modulehashescap uint64
/* These fields we are not planning to use so skipping the parsing of them.
hasmain uint8 // 1 if module contains the main function, 0 otherwise
gcdatamask, gcbssmask bitvector
typemap map[typeOff]*_type // offset to *_rtype in previous module
bad bool // module failed to load and should be ignored
next *moduledata
*/
}
type moduledata1832 struct {
PcHeader uint32
Funcnametab, Funcnametablen, Funcnametabcap uint32
Cutab, Cutablen, Cutabcap uint32
Filetab, Filetablen, Filetabcap uint32
Pctab, Pctablen, Pctabcap uint32
Pclntable, Pclntablelen, Pclntablecap uint32
Ftab, Ftablen, Ftabcap uint32
Findfunctab uint32
Minpc, Maxpc uint32
Text, Etext uint32
Noptrdata, Enoptrdata uint32
Data, Edata uint32
Bss, Ebss uint32
Noptrbss, Enoptrbss uint32
End, Gcdata, Gcbss uint32
Types, Etypes uint32
RData uint32
GoFunc uint32
Textsectmap, Textsectmaplen, Textsectmapcap uint32
Typelinks, Typelinkslen, Typelinkscap uint32 // offsets from types
Itablinks, Itablinkslen, Itablinkscap uint32
Ptab, Ptablen, Ptabcap uint32
Pluginpath, Pluginpathlen uint32
Pkghashes, Pkghasheslen, Pkghashescap uint32
Modulename, Modulenamelen uint32
Modulehashes, Modulehasheslen, Modulehashescap uint32
/* These fields we are not planning to use so skipping the parsing of them.
hasmain uint8 // 1 if module contains the main function, 0 otherwise
gcdatamask, gcbssmask bitvector
typemap map[typeOff]*_type // offset to *_rtype in previous module
bad bool // module failed to load and should be ignored
next *moduledata
*/
}
// Moduledata structure for Go 1.16 to 1.17
type moduledata1664 struct {
PcHeader uint64
Funcnametab, Funcnametablen, Funcnametabcap uint64
Cutab, Cutablen, Cutabcap uint64
Filetab, Filetablen, Filetabcap uint64
Pctab, Pctablen, Pctabcap uint64
Pclntable, Pclntablelen, Pclntablecap uint64
Ftab, Ftablen, Ftabcap uint64
Findfunctab uint64
Minpc, Maxpc uint64
Text, Etext uint64
Noptrdata, Enoptrdata uint64
Data, Edata uint64
Bss, Ebss uint64
Noptrbss, Enoptrbss uint64
End, Gcdata, Gcbss uint64
Types, Etypes uint64
Textsectmap, Textsectmaplen, Textsectmapcap uint64
Typelinks, Typelinkslen, Typelinkscap uint64 // offsets from types
Itablinks, Itablinkslen, Itablinkscap uint64
Ptab, Ptablen, Ptabcap uint64
Pluginpath, Pluginpathlen uint64
Pkghashes, Pkghasheslen, Pkghashescap uint64
Modulename, Modulenamelen uint64
Modulehashes, Modulehasheslen, Modulehashescap uint64
/* These fields we are not planning to use so skipping the parsing of them.
hasmain uint8 // 1 if module contains the main function, 0 otherwise
gcdatamask, gcbssmask bitvector
typemap map[typeOff]*_type // offset to *_rtype in previous module
bad bool // module failed to load and should be ignored
next *moduledata
*/
}
type moduledata1632 struct {
PcHeader uint32
Funcnametab, Funcnametablen, Funcnametabcap uint32
Cutab, Cutablen, Cutabcap uint32
Filetab, Filetablen, Filetabcap uint32
Pctab, Pctablen, Pctabcap uint32
Pclntable, Pclntablelen, Pclntablecap uint32
Ftab, Ftablen, Ftabcap uint32
Findfunctab uint32
Minpc, Maxpc uint32
Text, Etext uint32
Noptrdata, Enoptrdata uint32
Data, Edata uint32
Bss, Ebss uint32
Noptrbss, Enoptrbss uint32
End, Gcdata, Gcbss uint32
Types, Etypes uint32
Textsectmap, Textsectmaplen, Textsectmapcap uint32
Typelinks, Typelinkslen, Typelinkscap uint32 // offsets from types
Itablinks, Itablinkslen, Itablinkscap uint32
Ptab, Ptablen, Ptabcap uint32
Pluginpath, Pluginpathlen uint32
Pkghashes, Pkghasheslen, Pkghashescap uint32
Modulename, Modulenamelen uint32
Modulehashes, Modulehasheslen, Modulehashescap uint32
/* These fields we are not planning to use so skipping the parsing of them.
hasmain uint8 // 1 if module contains the main function, 0 otherwise
gcdatamask, gcbssmask bitvector
typemap map[typeOff]*_type // offset to *_rtype in previous module
bad bool // module failed to load and should be ignored
next *moduledata
*/
}
// Moduledata structure for Go 1.8 to 1.15
type moduledata864 struct {
Pclntable, Pclntablelen, Pclntablecap uint64
Ftab, Ftablen, Ftabcap uint64
Filetab, Filetablen, Filetabcap uint64
Findfunctab uint64
Minpc, Maxpc uint64
Text, Etext uint64
Noptrdata, Enoptrdata uint64
Data, Edata uint64
Bss, Ebss uint64
Noptrbss, Enoptrbss uint64
End, Gcdata, Gcbss uint64
Types, Etypes uint64
Textsectmap, Textsectmaplen, Textsectmapcap uint64
Typelinks, Typelinkslen, Typelinkscap uint64 // offsets from types
Itablinks, Itablinkslen, Itablinkscap uint64
Ptab, Ptablen, Ptabcap uint64
Pluginpath, Pluginpathlen uint64
Pkghashes, Pkghasheslen, Pkghashescap uint64
Modulename, Modulenamelen uint64
Modulehashes, Modulehasheslen, Modulehashescap uint64
/* These fields we are not planning to use so skipping the parsing of them.
hasmain uint8 // 1 if module contains the main function, 0 otherwise
gcdatamask, gcbssmask bitvector
typemap map[typeOff]*_type // offset to *_rtype in previous module
bad bool // module failed to load and should be ignored
next *moduledata
*/
}
type moduledata832 struct {
Pclntable, Pclntablelen, Pclntablecap uint32
Ftab, Ftablen, Ftabcap uint32
Filetab, Filetablen, Filetabcap uint32
Findfunctab uint32
Minpc, Maxpc uint32
Text, Etext uint32
Noptrdata, Enoptrdata uint32
Data, Edata uint32
Bss, Ebss uint32
Noptrbss, Enoptrbss uint32
End, Gcdata, Gcbss uint32
Types, Etypes uint32
Textsectmap, Textsectmaplen, Textsectmapcap uint32
Typelinks, Typelinkslen, Typelinkscap uint32 // offsets from types
Itablinks, Itablinkslen, Itablinkscap uint32
Ptab, Ptablen, Ptabcap uint32
Pluginpath, Pluginpathlen uint32
Pkghashes, Pkghasheslen, Pkghashescap uint32
Modulename, Modulenamelen uint32
Modulehashes, Modulehasheslen, Modulehashescap uint32
/* These fields we are not planning to use so skipping the parsing of them.
hasmain uint8 // 1 if module contains the main function, 0 otherwise
gcdatamask, gcbssmask bitvector
typemap map[typeOff]*_type // offset to *_rtype in previous module
bad bool // module failed to load and should be ignored
next *moduledata
*/
}
// Moduledata structure for Go 1.7
type moduledata764 struct {
Pclntable, Pclntablelen, Pclntablecap uint64
Ftab, Ftablen, Ftabcap uint64
Filetab, Filetablen, Filetabcap uint64
Findfunctab uint64
Minpc, Maxpc uint64
Text, Etext uint64
Noptrdata, Enoptrdata uint64
Data, Edata uint64
Bss, Ebss uint64
Noptrbss, Enoptrbss uint64
End, Gcdata, Gcbss uint64
Types, Etypes uint64
Typelinks, Typelinkslen, Typelinkscap uint64 // offsets from types
Itablinks, Itablinkslen, Itablinkscap uint64
Modulename, Modulenamelen uint64
Modulehashes, Modulehasheslen, Modulehashescap uint64
/* These fields we are not planning to use so skipping the parsing of them.
gcdatamask, gcbssmask bitvector
typemap map[typeOff]*_type // offset to *_rtype in previous module
next *moduledata
*/
}
type moduledata732 struct {
Pclntable, Pclntablelen, Pclntablecap uint32
Ftab, Ftablen, Ftabcap uint32
Filetab, Filetablen, Filetabcap uint32
Findfunctab uint32
Minpc, Maxpc uint32
Text, Etext uint32
Noptrdata, Enoptrdata uint32
Data, Edata uint32
Bss, Ebss uint32
Noptrbss, Enoptrbss uint32
End, Gcdata, Gcbss uint32
Types, Etypes uint32
Typelinks, Typelinkslen, Typelinkscap uint32 // offsets from types
Itablinks, Itablinkslen, Itablinkscap uint32
Modulename, Modulenamelen uint32
Modulehashes, Modulehasheslen, Modulehashescap uint32
/* These fields we are not planning to use so skipping the parsing of them.
gcdatamask, gcbssmask bitvector
typemap map[typeOff]*_type // offset to *_rtype in previous module
next *moduledata
*/
}
// Moduledata structure for Go 1.5 to 1.6
type moduledata564 struct {
Pclntable, Pclntablelen, Pclntablecap uint64
Ftab, Ftablen, Ftabcap uint64
Filetab, Filetablen, Filetabcap uint64
Findfunctab uint64
Minpc, Maxpc uint64
Text, Etext uint64
Noptrdata, Enoptrdata uint64
Data, Edata uint64
Bss, Ebss uint64
Noptrbss, Enoptrbss uint64
End, Gcdata, Gcbss uint64
Typelinks, Typelinkslen, Typelinkscap uint64
Modulename, Modulenamelen uint64
Modulehashes, Modulehasheslen, Modulehashescap uint64
/* These fields we are not planning to use so skipping the parsing of them.
gcdatamask, gcbssmask bitvector
typemap map[typeOff]*_type // offset to *_rtype in previous module
next *moduledata
*/
}
type moduledata532 struct {
Pclntable, Pclntablelen, Pclntablecap uint32
Ftab, Ftablen, Ftabcap uint32
Filetab, Filetablen, Filetabcap uint32
Findfunctab uint32
Minpc, Maxpc uint32
Text, Etext uint32
Noptrdata, Enoptrdata uint32
Data, Edata uint32
Bss, Ebss uint32
Noptrbss, Enoptrbss uint32
End, Gcdata, Gcbss uint32
Typelinks, Typelinkslen, Typelinkscap uint32
Modulename, Modulenamelen uint32
Modulehashes, Modulehasheslen, Modulehashescap uint32
/* These fields we are not planning to use so skipping the parsing of them.
gcdatamask, gcbssmask bitvector
typemap map[typeOff]*_type // offset to *_rtype in previous module
next *moduledata
*/
}