-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
metadata.c
8098 lines (7109 loc) · 244 KB
/
metadata.c
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
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* \file
* Routines for accessing the metadata
*
* Authors:
* Miguel de Icaza ([email protected])
* Paolo Molaro ([email protected])
*
* Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
* Copyright 2004-2009 Novell, Inc (http://www.novell.com)
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <mono/metadata/metadata.h>
#include "tabledefs.h"
#include "mono-endian.h"
#include "cil-coff.h"
#include <mono/metadata/tokentype.h>
#include "class-internals.h"
#include "metadata-internals.h"
#include "reflection-internals.h"
#include "metadata-update.h"
#include <mono/metadata/class.h>
#include "marshal.h"
#include <mono/metadata/debug-helpers.h>
#include "abi-details.h"
#include "components.h"
#include <mono/metadata/exception-internals.h>
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/mono-memory-model.h>
#include <mono/utils/mono-digest.h>
#include <mono/utils/bsearch.h>
#include <mono/utils/atomic.h>
#include <mono/utils/unlocked.h>
#include <mono/utils/mono-logger-internals.h>
/* Auxiliary structure used for caching inflated signatures */
typedef struct {
MonoMethodSignature *sig;
MonoGenericContext context;
} MonoInflatedMethodSignature;
enum {
MONO_TYPE_EQ_FLAGS_SIG_ONLY = 1,
MONO_TYPE_EQ_FLAG_IGNORE_CMODS = 2,
};
static gboolean do_mono_metadata_parse_type (MonoType *type, MonoImage *m, MonoGenericContainer *container, gboolean transient,
const char *ptr, const char **rptr, MonoError *error);
static gboolean do_mono_metadata_type_equal (MonoType *t1, MonoType *t2, int equiv_flags);
static gboolean mono_metadata_class_equal (MonoClass *c1, MonoClass *c2, gboolean signature_only);
static gboolean mono_metadata_fnptr_equal (MonoMethodSignature *s1, MonoMethodSignature *s2, int equiv_flags);
static gboolean _mono_metadata_generic_class_equal (const MonoGenericClass *g1, const MonoGenericClass *g2,
gboolean signature_only);
static void free_generic_inst (MonoGenericInst *ginst);
static void free_generic_class (MonoGenericClass *ginst);
static void free_inflated_signature (MonoInflatedMethodSignature *sig);
static void free_aggregate_modifiers (MonoAggregateModContainer *amods);
static void mono_metadata_field_info_full (MonoImage *meta, guint32 index, guint32 *offset, guint32 *rva, MonoMarshalSpec **marshal_spec, gboolean alloc_from_image);
static MonoType* mono_signature_get_params_internal (MonoMethodSignature *sig, gpointer *iter);
/*
* This enumeration is used to describe the data types in the metadata
* tables
*/
enum {
MONO_MT_END,
/* Sized elements */
MONO_MT_UINT32,
MONO_MT_UINT16,
MONO_MT_UINT8,
/* Index into Blob heap */
MONO_MT_BLOB_IDX,
/* Index into String heap */
MONO_MT_STRING_IDX,
/* GUID index */
MONO_MT_GUID_IDX,
/* Pointer into a table */
MONO_MT_TABLE_IDX,
/* HasConstant:Parent pointer (Param, Field or Property) */
MONO_MT_CONST_IDX,
/* HasCustomAttribute index. Indexes any table except CustomAttribute */
MONO_MT_HASCAT_IDX,
/* CustomAttributeType encoded index */
MONO_MT_CAT_IDX,
/* HasDeclSecurity index: TypeDef Method or Assembly */
MONO_MT_HASDEC_IDX,
/* Implementation coded index: File, Export AssemblyRef */
MONO_MT_IMPL_IDX,
/* HasFieldMarshal coded index: Field or Param table */
MONO_MT_HFM_IDX,
/* MemberForwardedIndex: Field or Method */
MONO_MT_MF_IDX,
/* TypeDefOrRef coded index: typedef, typeref, typespec */
MONO_MT_TDOR_IDX,
/* MemberRefParent coded index: typeref, moduleref, method, memberref, typesepc, typedef */
MONO_MT_MRP_IDX,
/* MethodDefOrRef coded index: Method or Member Ref table */
MONO_MT_MDOR_IDX,
/* HasSemantic coded index: Event or Property */
MONO_MT_HS_IDX,
/* ResolutionScope coded index: Module, ModuleRef, AssemblytRef, TypeRef */
MONO_MT_RS_IDX,
/* CustomDebugInformation parent encoded index */
MONO_MT_HASCUSTDEBUG_IDX
};
const static unsigned char TableSchemas [] = {
#define ASSEMBLY_SCHEMA_OFFSET 0
MONO_MT_UINT32, /* "HashId" }, */
MONO_MT_UINT16, /* "Major" }, */
MONO_MT_UINT16, /* "Minor" }, */
MONO_MT_UINT16, /* "BuildNumber" }, */
MONO_MT_UINT16, /* "RevisionNumber" }, */
MONO_MT_UINT32, /* "Flags" }, */
MONO_MT_BLOB_IDX, /* "PublicKey" }, */
MONO_MT_STRING_IDX, /* "Name" }, */
MONO_MT_STRING_IDX, /* "Culture" }, */
MONO_MT_END,
#define ASSEMBLYOS_SCHEMA_OFFSET ASSEMBLY_SCHEMA_OFFSET + 10
MONO_MT_UINT32, /* "OSPlatformID" }, */
MONO_MT_UINT32, /* "OSMajor" }, */
MONO_MT_UINT32, /* "OSMinor" }, */
MONO_MT_END,
#define ASSEMBLYPROC_SCHEMA_OFFSET ASSEMBLYOS_SCHEMA_OFFSET + 4
MONO_MT_UINT32, /* "Processor" }, */
MONO_MT_END,
#define ASSEMBLYREF_SCHEMA_OFFSET ASSEMBLYPROC_SCHEMA_OFFSET + 2
MONO_MT_UINT16, /* "Major" }, */
MONO_MT_UINT16, /* "Minor" }, */
MONO_MT_UINT16, /* "Build" }, */
MONO_MT_UINT16, /* "Revision" }, */
MONO_MT_UINT32, /* "Flags" }, */
MONO_MT_BLOB_IDX, /* "PublicKeyOrToken" }, */
MONO_MT_STRING_IDX, /* "Name" }, */
MONO_MT_STRING_IDX, /* "Culture" }, */
MONO_MT_BLOB_IDX, /* "HashValue" }, */
MONO_MT_END,
#define ASSEMBLYREFOS_SCHEMA_OFFSET ASSEMBLYREF_SCHEMA_OFFSET + 10
MONO_MT_UINT32, /* "OSPlatformID" }, */
MONO_MT_UINT32, /* "OSMajorVersion" }, */
MONO_MT_UINT32, /* "OSMinorVersion" }, */
MONO_MT_TABLE_IDX, /* "AssemblyRef:AssemblyRef" }, */
MONO_MT_END,
#define ASSEMBLYREFPROC_SCHEMA_OFFSET ASSEMBLYREFOS_SCHEMA_OFFSET + 5
MONO_MT_UINT32, /* "Processor" }, */
MONO_MT_TABLE_IDX, /* "AssemblyRef:AssemblyRef" }, */
MONO_MT_END,
#define CLASS_LAYOUT_SCHEMA_OFFSET ASSEMBLYREFPROC_SCHEMA_OFFSET + 3
MONO_MT_UINT16, /* "PackingSize" }, */
MONO_MT_UINT32, /* "ClassSize" }, */
MONO_MT_TABLE_IDX, /* "Parent:TypeDef" }, */
MONO_MT_END,
#define CONSTANT_SCHEMA_OFFSET CLASS_LAYOUT_SCHEMA_OFFSET + 4
MONO_MT_UINT8, /* "Type" }, */
MONO_MT_UINT8, /* "PaddingZero" }, */
MONO_MT_CONST_IDX, /* "Parent" }, */
MONO_MT_BLOB_IDX, /* "Value" }, */
MONO_MT_END,
#define CUSTOM_ATTR_SCHEMA_OFFSET CONSTANT_SCHEMA_OFFSET + 5
MONO_MT_HASCAT_IDX, /* "Parent" }, */
MONO_MT_CAT_IDX, /* "Type" }, */
MONO_MT_BLOB_IDX, /* "Value" }, */
MONO_MT_END,
#define DECL_SEC_SCHEMA_OFFSET CUSTOM_ATTR_SCHEMA_OFFSET + 4
MONO_MT_UINT16, /* "Action" }, */
MONO_MT_HASDEC_IDX, /* "Parent" }, */
MONO_MT_BLOB_IDX, /* "PermissionSet" }, */
MONO_MT_END,
#define EVENTMAP_SCHEMA_OFFSET DECL_SEC_SCHEMA_OFFSET + 4
MONO_MT_TABLE_IDX, /* "Parent:TypeDef" }, */
MONO_MT_TABLE_IDX, /* "EventList:Event" }, */
MONO_MT_END,
#define EVENT_SCHEMA_OFFSET EVENTMAP_SCHEMA_OFFSET + 3
MONO_MT_UINT16, /* "EventFlags#EventAttribute" }, */
MONO_MT_STRING_IDX, /* "Name" }, */
MONO_MT_TDOR_IDX, /* "EventType" }, TypeDef or TypeRef or TypeSpec */
MONO_MT_END,
#define EVENT_POINTER_SCHEMA_OFFSET EVENT_SCHEMA_OFFSET + 4
MONO_MT_TABLE_IDX, /* "Event" }, */
MONO_MT_END,
#define EXPORTED_TYPE_SCHEMA_OFFSET EVENT_POINTER_SCHEMA_OFFSET + 2
MONO_MT_UINT32, /* "Flags" }, */
MONO_MT_TABLE_IDX, /* "TypeDefId" }, */
MONO_MT_STRING_IDX, /* "TypeName" }, */
MONO_MT_STRING_IDX, /* "TypeNameSpace" }, */
MONO_MT_IMPL_IDX, /* "Implementation" }, */
MONO_MT_END,
#define FIELD_SCHEMA_OFFSET EXPORTED_TYPE_SCHEMA_OFFSET + 6
MONO_MT_UINT16, /* "Flags" }, */
MONO_MT_STRING_IDX, /* "Name" }, */
MONO_MT_BLOB_IDX, /* "Signature" }, */
MONO_MT_END,
#define FIELD_LAYOUT_SCHEMA_OFFSET FIELD_SCHEMA_OFFSET + 4
MONO_MT_UINT32, /* "Offset" }, */
MONO_MT_TABLE_IDX, /* "Field:Field" }, */
MONO_MT_END,
#define FIELD_MARSHAL_SCHEMA_OFFSET FIELD_LAYOUT_SCHEMA_OFFSET + 3
MONO_MT_HFM_IDX, /* "Parent" }, */
MONO_MT_BLOB_IDX, /* "NativeType" }, */
MONO_MT_END,
#define FIELD_RVA_SCHEMA_OFFSET FIELD_MARSHAL_SCHEMA_OFFSET + 3
MONO_MT_UINT32, /* "RVA" }, */
MONO_MT_TABLE_IDX, /* "Field:Field" }, */
MONO_MT_END,
#define ENCLOG_SCHEMA_OFFSET FIELD_RVA_SCHEMA_OFFSET + 3
MONO_MT_UINT32, /* "Token" }, */
MONO_MT_UINT32, /* "FuncCode" }, */
MONO_MT_END,
#define ENCMAP_SCHEMA_OFFSET ENCLOG_SCHEMA_OFFSET + 3
MONO_MT_UINT32, /* "Token" }, */
MONO_MT_END,
#define FIELD_POINTER_SCHEMA_OFFSET ENCMAP_SCHEMA_OFFSET + 2
MONO_MT_TABLE_IDX, /* "Field" }, */
MONO_MT_END,
#define FILE_SCHEMA_OFFSET FIELD_POINTER_SCHEMA_OFFSET + 2
MONO_MT_UINT32, /* "Flags" }, */
MONO_MT_STRING_IDX, /* "Name" }, */
MONO_MT_BLOB_IDX, /* "Value" }, */
MONO_MT_END,
#define IMPLMAP_SCHEMA_OFFSET FILE_SCHEMA_OFFSET + 4
MONO_MT_UINT16, /* "MappingFlag" }, */
MONO_MT_MF_IDX, /* "MemberForwarded" }, */
MONO_MT_STRING_IDX, /* "ImportName" }, */
MONO_MT_TABLE_IDX, /* "ImportScope:ModuleRef" }, */
MONO_MT_END,
#define IFACEMAP_SCHEMA_OFFSET IMPLMAP_SCHEMA_OFFSET + 5
MONO_MT_TABLE_IDX, /* "Class:TypeDef" }, */
MONO_MT_TDOR_IDX, /* "Interface=TypeDefOrRef" }, */
MONO_MT_END,
#define MANIFEST_SCHEMA_OFFSET IFACEMAP_SCHEMA_OFFSET + 3
MONO_MT_UINT32, /* "Offset" }, */
MONO_MT_UINT32, /* "Flags" }, */
MONO_MT_STRING_IDX, /* "Name" }, */
MONO_MT_IMPL_IDX, /* "Implementation" }, */
MONO_MT_END,
#define MEMBERREF_SCHEMA_OFFSET MANIFEST_SCHEMA_OFFSET + 5
MONO_MT_MRP_IDX, /* "Class" }, */
MONO_MT_STRING_IDX, /* "Name" }, */
MONO_MT_BLOB_IDX, /* "Signature" }, */
MONO_MT_END,
#define METHOD_SCHEMA_OFFSET MEMBERREF_SCHEMA_OFFSET + 4
MONO_MT_UINT32, /* "RVA" }, */
MONO_MT_UINT16, /* "ImplFlags#MethodImplAttributes" }, */
MONO_MT_UINT16, /* "Flags#MethodAttribute" }, */
MONO_MT_STRING_IDX, /* "Name" }, */
MONO_MT_BLOB_IDX, /* "Signature" }, */
MONO_MT_TABLE_IDX, /* "ParamList:Param" }, */
MONO_MT_END,
#define METHOD_IMPL_SCHEMA_OFFSET METHOD_SCHEMA_OFFSET + 7
MONO_MT_TABLE_IDX, /* "Class:TypeDef" }, */
MONO_MT_MDOR_IDX, /* "MethodBody" }, */
MONO_MT_MDOR_IDX, /* "MethodDeclaration" }, */
MONO_MT_END,
#define METHOD_SEMA_SCHEMA_OFFSET METHOD_IMPL_SCHEMA_OFFSET + 4
MONO_MT_UINT16, /* "MethodSemantic" }, */
MONO_MT_TABLE_IDX, /* "Method:Method" }, */
MONO_MT_HS_IDX, /* "Association" }, */
MONO_MT_END,
#define METHOD_POINTER_SCHEMA_OFFSET METHOD_SEMA_SCHEMA_OFFSET + 4
MONO_MT_TABLE_IDX, /* "Method" }, */
MONO_MT_END,
#define MODULE_SCHEMA_OFFSET METHOD_POINTER_SCHEMA_OFFSET + 2
MONO_MT_UINT16, /* "Generation" }, */
MONO_MT_STRING_IDX, /* "Name" }, */
MONO_MT_GUID_IDX, /* "MVID" }, */
MONO_MT_GUID_IDX, /* "EncID" }, */
MONO_MT_GUID_IDX, /* "EncBaseID" }, */
MONO_MT_END,
#define MODULEREF_SCHEMA_OFFSET MODULE_SCHEMA_OFFSET + 6
MONO_MT_STRING_IDX, /* "Name" }, */
MONO_MT_END,
#define NESTED_CLASS_SCHEMA_OFFSET MODULEREF_SCHEMA_OFFSET + 2
MONO_MT_TABLE_IDX, /* "NestedClass:TypeDef" }, */
MONO_MT_TABLE_IDX, /* "EnclosingClass:TypeDef" }, */
MONO_MT_END,
#define PARAM_SCHEMA_OFFSET NESTED_CLASS_SCHEMA_OFFSET + 3
MONO_MT_UINT16, /* "Flags" }, */
MONO_MT_UINT16, /* "Sequence" }, */
MONO_MT_STRING_IDX, /* "Name" }, */
MONO_MT_END,
#define PARAM_POINTER_SCHEMA_OFFSET PARAM_SCHEMA_OFFSET + 4
MONO_MT_TABLE_IDX, /* "Param" }, */
MONO_MT_END,
#define PROPERTY_SCHEMA_OFFSET PARAM_POINTER_SCHEMA_OFFSET + 2
MONO_MT_UINT16, /* "Flags" }, */
MONO_MT_STRING_IDX, /* "Name" }, */
MONO_MT_BLOB_IDX, /* "Type" }, */
MONO_MT_END,
#define PROPERTY_POINTER_SCHEMA_OFFSET PROPERTY_SCHEMA_OFFSET + 4
MONO_MT_TABLE_IDX, /* "Property" }, */
MONO_MT_END,
#define PROPERTY_MAP_SCHEMA_OFFSET PROPERTY_POINTER_SCHEMA_OFFSET + 2
MONO_MT_TABLE_IDX, /* "Parent:TypeDef" }, */
MONO_MT_TABLE_IDX, /* "PropertyList:Property" }, */
MONO_MT_END,
#define STDALON_SIG_SCHEMA_OFFSET PROPERTY_MAP_SCHEMA_OFFSET + 3
MONO_MT_BLOB_IDX, /* "Signature" }, */
MONO_MT_END,
#define TYPEDEF_SCHEMA_OFFSET STDALON_SIG_SCHEMA_OFFSET + 2
MONO_MT_UINT32, /* "Flags" }, */
MONO_MT_STRING_IDX, /* "Name" }, */
MONO_MT_STRING_IDX, /* "Namespace" }, */
MONO_MT_TDOR_IDX, /* "Extends" }, */
MONO_MT_TABLE_IDX, /* "FieldList:Field" }, */
MONO_MT_TABLE_IDX, /* "MethodList:Method" }, */
MONO_MT_END,
#define TYPEREF_SCHEMA_OFFSET TYPEDEF_SCHEMA_OFFSET + 7
MONO_MT_RS_IDX, /* "ResolutionScope=ResolutionScope" }, */
MONO_MT_STRING_IDX, /* "Name" }, */
MONO_MT_STRING_IDX, /* "Namespace" }, */
MONO_MT_END,
#define TYPESPEC_SCHEMA_OFFSET TYPEREF_SCHEMA_OFFSET + 4
MONO_MT_BLOB_IDX, /* "Signature" }, */
MONO_MT_END,
#define GENPARAM_SCHEMA_OFFSET TYPESPEC_SCHEMA_OFFSET + 2
MONO_MT_UINT16, /* "Number" }, */
MONO_MT_UINT16, /* "Flags" }, */
MONO_MT_TABLE_IDX, /* "Owner" }, TypeDef or MethodDef */
MONO_MT_STRING_IDX, /* "Name" }, */
MONO_MT_END,
#define METHOD_SPEC_SCHEMA_OFFSET GENPARAM_SCHEMA_OFFSET + 5
MONO_MT_MDOR_IDX, /* "Method" }, */
MONO_MT_BLOB_IDX, /* "Signature" }, */
MONO_MT_END,
#define GEN_CONSTRAINT_SCHEMA_OFFSET METHOD_SPEC_SCHEMA_OFFSET + 3
MONO_MT_TABLE_IDX, /* "GenericParam" }, */
MONO_MT_TDOR_IDX, /* "Constraint" }, */
MONO_MT_END,
#define DOCUMENT_SCHEMA_OFFSET GEN_CONSTRAINT_SCHEMA_OFFSET + 3
MONO_MT_BLOB_IDX, /* Name */
MONO_MT_GUID_IDX, /* HashAlgorithm */
MONO_MT_BLOB_IDX, /* Hash */
MONO_MT_GUID_IDX, /* Language */
MONO_MT_END,
#define METHODBODY_SCHEMA_OFFSET DOCUMENT_SCHEMA_OFFSET + 5
MONO_MT_TABLE_IDX, /* Document */
MONO_MT_BLOB_IDX, /* SequencePoints */
MONO_MT_END,
#define LOCALSCOPE_SCHEMA_OFFSET METHODBODY_SCHEMA_OFFSET + 3
MONO_MT_TABLE_IDX, /* Method */
MONO_MT_TABLE_IDX, /* ImportScope */
MONO_MT_TABLE_IDX, /* VariableList */
MONO_MT_TABLE_IDX, /* ConstantList */
MONO_MT_UINT32, /* StartOffset */
MONO_MT_UINT32, /* Length */
MONO_MT_END,
#define LOCALVARIABLE_SCHEMA_OFFSET LOCALSCOPE_SCHEMA_OFFSET + 7
MONO_MT_UINT16, /* Attributes */
MONO_MT_UINT16, /* Index */
MONO_MT_STRING_IDX, /* Name */
MONO_MT_END,
#define LOCALCONSTANT_SCHEMA_OFFSET LOCALVARIABLE_SCHEMA_OFFSET + 4
MONO_MT_STRING_IDX, /* Name (String heap index) */
MONO_MT_BLOB_IDX, /* Signature (Blob heap index, LocalConstantSig blob) */
MONO_MT_END,
#define IMPORTSCOPE_SCHEMA_OFFSET LOCALCONSTANT_SCHEMA_OFFSET + 3
MONO_MT_TABLE_IDX, /* Parent (ImportScope row id or nil) */
MONO_MT_BLOB_IDX, /* Imports (Blob index, encoding: Imports blob) */
MONO_MT_END,
#define ASYNCMETHOD_SCHEMA_OFFSET IMPORTSCOPE_SCHEMA_OFFSET + 3
MONO_MT_TABLE_IDX, /* MoveNextMethod (MethodDef row id) */
MONO_MT_TABLE_IDX, /* KickoffMethod (MethodDef row id) */
MONO_MT_END,
#define CUSTOMDEBUGINFORMATION_SCHEMA_OFFSET ASYNCMETHOD_SCHEMA_OFFSET + 3
MONO_MT_HASCUSTDEBUG_IDX, /* Parent (HasCustomDebugInformation coded index) */
MONO_MT_GUID_IDX, /* Kind (Guid heap index) */
MONO_MT_BLOB_IDX, /* Value (Blob heap index) */
MONO_MT_END,
#define NULL_SCHEMA_OFFSET CUSTOMDEBUGINFORMATION_SCHEMA_OFFSET + 4
MONO_MT_END
};
/* Must be the same order as MONO_TABLE_* */
const static unsigned char
table_description [] = {
MODULE_SCHEMA_OFFSET,
TYPEREF_SCHEMA_OFFSET,
TYPEDEF_SCHEMA_OFFSET,
FIELD_POINTER_SCHEMA_OFFSET,
FIELD_SCHEMA_OFFSET,
METHOD_POINTER_SCHEMA_OFFSET,
METHOD_SCHEMA_OFFSET,
PARAM_POINTER_SCHEMA_OFFSET,
PARAM_SCHEMA_OFFSET,
IFACEMAP_SCHEMA_OFFSET,
MEMBERREF_SCHEMA_OFFSET, /* 0xa */
CONSTANT_SCHEMA_OFFSET,
CUSTOM_ATTR_SCHEMA_OFFSET,
FIELD_MARSHAL_SCHEMA_OFFSET,
DECL_SEC_SCHEMA_OFFSET,
CLASS_LAYOUT_SCHEMA_OFFSET,
FIELD_LAYOUT_SCHEMA_OFFSET, /* 0x10 */
STDALON_SIG_SCHEMA_OFFSET,
EVENTMAP_SCHEMA_OFFSET,
EVENT_POINTER_SCHEMA_OFFSET,
EVENT_SCHEMA_OFFSET,
PROPERTY_MAP_SCHEMA_OFFSET,
PROPERTY_POINTER_SCHEMA_OFFSET,
PROPERTY_SCHEMA_OFFSET,
METHOD_SEMA_SCHEMA_OFFSET,
METHOD_IMPL_SCHEMA_OFFSET,
MODULEREF_SCHEMA_OFFSET, /* 0x1a */
TYPESPEC_SCHEMA_OFFSET,
IMPLMAP_SCHEMA_OFFSET,
FIELD_RVA_SCHEMA_OFFSET,
ENCLOG_SCHEMA_OFFSET,
ENCMAP_SCHEMA_OFFSET,
ASSEMBLY_SCHEMA_OFFSET, /* 0x20 */
ASSEMBLYPROC_SCHEMA_OFFSET,
ASSEMBLYOS_SCHEMA_OFFSET,
ASSEMBLYREF_SCHEMA_OFFSET,
ASSEMBLYREFPROC_SCHEMA_OFFSET,
ASSEMBLYREFOS_SCHEMA_OFFSET,
FILE_SCHEMA_OFFSET,
EXPORTED_TYPE_SCHEMA_OFFSET,
MANIFEST_SCHEMA_OFFSET,
NESTED_CLASS_SCHEMA_OFFSET,
GENPARAM_SCHEMA_OFFSET, /* 0x2a */
METHOD_SPEC_SCHEMA_OFFSET,
GEN_CONSTRAINT_SCHEMA_OFFSET,
NULL_SCHEMA_OFFSET,
NULL_SCHEMA_OFFSET,
NULL_SCHEMA_OFFSET,
DOCUMENT_SCHEMA_OFFSET, /* 0x30 */
METHODBODY_SCHEMA_OFFSET,
LOCALSCOPE_SCHEMA_OFFSET,
LOCALVARIABLE_SCHEMA_OFFSET,
LOCALCONSTANT_SCHEMA_OFFSET,
IMPORTSCOPE_SCHEMA_OFFSET,
ASYNCMETHOD_SCHEMA_OFFSET,
CUSTOMDEBUGINFORMATION_SCHEMA_OFFSET
};
// This, instead of an array of pointers, to optimize away a pointer and a relocation per string.
#define MSGSTRFIELD(line) MSGSTRFIELD1(line)
#define MSGSTRFIELD1(line) str##line
static const struct msgstr_t {
#define TABLEDEF(a,b) char MSGSTRFIELD(__LINE__) [sizeof (b)];
#include "mono/cil/tables.def"
#undef TABLEDEF
} tablestr = {
#define TABLEDEF(a,b) b,
#include "mono/cil/tables.def"
#undef TABLEDEF
};
static const gint16 tableidx [] = {
#define TABLEDEF(a,b) offsetof (struct msgstr_t, MSGSTRFIELD(__LINE__)),
#include "mono/cil/tables.def"
#undef TABLEDEF
};
/* On legacy, if TRUE (but also see DISABLE_DESKTOP_LOADER #define), Mono will check
* that the public key token, culture and version of a candidate assembly matches
* the requested strong name. On netcore, it will check the culture and version.
* If FALSE, as long as the name matches, the candidate will be allowed.
*/
static gboolean check_assembly_names_strictly = FALSE;
// Amount initially reserved in each imageset's mempool.
// FIXME: This number is arbitrary, a more practical number should be found
#define INITIAL_IMAGE_SET_SIZE 1024
/**
* mono_meta_table_name:
* \param table table index
*
* Returns the name of the given ECMA metadata logical format table
* as described in ECMA 335, Partition II, Section 22.
*
* \returns the name for the \p table index
*/
const char *
mono_meta_table_name (int table)
{
if ((table < 0) || (table > MONO_TABLE_LAST))
return "";
return (const char*)&tablestr + tableidx [table];
}
/* The guy who wrote the spec for this should not be allowed near a
* computer again.
If e is a coded token(see clause 23.1.7) that points into table ti out of n possible tables t0, .. tn-1,
then it is stored as e << (log n) & tag{ t0, .. tn-1}[ ti] using 2 bytes if the maximum number of
rows of tables t0, ..tn-1, is less than 2^16 - (log n), and using 4 bytes otherwise. The family of
finite maps tag{ t0, ..tn-1} is defined below. Note that to decode a physical row, you need the
inverse of this mapping.
*/
static int
rtsize (MonoImage *meta, int sz, int bits)
{
if (G_UNLIKELY (meta->minimal_delta))
return 4;
if (sz < (1 << bits))
return 2;
else
return 4;
}
static int
idx_size (MonoImage *meta, int idx)
{
if (G_UNLIKELY (meta->minimal_delta))
return 4;
if (meta->referenced_tables && (meta->referenced_tables & ((guint64)1 << idx)))
return meta->referenced_table_rows [idx] < 65536 ? 2 : 4;
else
return table_info_get_rows (&meta->tables [idx]) < 65536 ? 2 : 4;
}
static int
get_nrows (MonoImage *meta, int idx)
{
if (meta->referenced_tables && (meta->referenced_tables & ((guint64)1 << idx)))
return meta->referenced_table_rows [idx];
else
return table_info_get_rows (&meta->tables [idx]);
}
/* Reference: Partition II - 23.2.6 */
/**
* mono_metadata_compute_size:
* \param meta metadata context
* \param tableindex metadata table number
* \param result_bitfield pointer to \c guint32 where to store additional info
*
* \c mono_metadata_compute_size computes the length in bytes of a single
* row in a metadata table. The size of each column is encoded in the
* \p result_bitfield return value along with the number of columns in the table.
* the resulting bitfield should be handed to the \c mono_metadata_table_size
* and \c mono_metadata_table_count macros.
* This is a Mono runtime internal only function.
*/
int
mono_metadata_compute_size (MonoImage *meta, int tableindex, guint32 *result_bitfield)
{
guint32 bitfield = 0;
int size = 0, field_size = 0;
int i, n, code;
int shift = 0;
const unsigned char *description = TableSchemas + table_description [tableindex];
for (i = 0; (code = description [i]) != MONO_MT_END; i++){
switch (code){
case MONO_MT_UINT32:
field_size = 4; break;
case MONO_MT_UINT16:
field_size = 2; break;
case MONO_MT_UINT8:
field_size = 1; break;
case MONO_MT_BLOB_IDX:
field_size = meta->idx_blob_wide ? 4 : 2; break;
case MONO_MT_STRING_IDX:
field_size = meta->idx_string_wide ? 4 : 2; break;
case MONO_MT_GUID_IDX:
field_size = meta->idx_guid_wide ? 4 : 2; break;
case MONO_MT_TABLE_IDX:
/* Uhm, a table index can point to other tables besides the current one
* so, it's not correct to use the rowcount of the current table to
* get the size for this column - lupus
*/
switch (tableindex) {
case MONO_TABLE_ASSEMBLYREFOS:
g_assert (i == 3);
field_size = idx_size (meta, MONO_TABLE_ASSEMBLYREF); break;
case MONO_TABLE_ASSEMBLYREFPROCESSOR:
g_assert (i == 1);
field_size = idx_size (meta, MONO_TABLE_ASSEMBLYREF); break;
case MONO_TABLE_CLASSLAYOUT:
g_assert (i == 2);
field_size = idx_size (meta, MONO_TABLE_TYPEDEF); break;
case MONO_TABLE_EVENTMAP:
g_assert (i == 0 || i == 1);
field_size = i ? idx_size (meta, MONO_TABLE_EVENT):
idx_size (meta, MONO_TABLE_TYPEDEF);
break;
case MONO_TABLE_EVENT_POINTER:
g_assert (i == 0);
field_size = idx_size (meta, MONO_TABLE_EVENT); break;
case MONO_TABLE_EXPORTEDTYPE:
g_assert (i == 1);
/* the index is in another metadata file, so it must be 4 */
field_size = 4; break;
case MONO_TABLE_FIELDLAYOUT:
g_assert (i == 1);
field_size = idx_size (meta, MONO_TABLE_FIELD); break;
case MONO_TABLE_FIELDRVA:
g_assert (i == 1);
field_size = idx_size (meta, MONO_TABLE_FIELD); break;
case MONO_TABLE_FIELD_POINTER:
g_assert (i == 0);
field_size = idx_size (meta, MONO_TABLE_FIELD); break;
case MONO_TABLE_IMPLMAP:
g_assert (i == 3);
field_size = idx_size (meta, MONO_TABLE_MODULEREF); break;
case MONO_TABLE_INTERFACEIMPL:
g_assert (i == 0);
field_size = idx_size (meta, MONO_TABLE_TYPEDEF); break;
case MONO_TABLE_METHOD:
g_assert (i == 5);
field_size = idx_size (meta, MONO_TABLE_PARAM); break;
case MONO_TABLE_METHODIMPL:
g_assert (i == 0);
field_size = idx_size (meta, MONO_TABLE_TYPEDEF); break;
case MONO_TABLE_METHODSEMANTICS:
g_assert (i == 1);
field_size = idx_size (meta, MONO_TABLE_METHOD); break;
case MONO_TABLE_METHOD_POINTER:
g_assert (i == 0);
field_size = idx_size (meta, MONO_TABLE_METHOD); break;
case MONO_TABLE_NESTEDCLASS:
g_assert (i == 0 || i == 1);
field_size = idx_size (meta, MONO_TABLE_TYPEDEF); break;
case MONO_TABLE_PARAM_POINTER:
g_assert (i == 0);
field_size = idx_size (meta, MONO_TABLE_PARAM); break;
case MONO_TABLE_PROPERTYMAP:
g_assert (i == 0 || i == 1);
field_size = i ? idx_size (meta, MONO_TABLE_PROPERTY):
idx_size (meta, MONO_TABLE_TYPEDEF);
break;
case MONO_TABLE_PROPERTY_POINTER:
g_assert (i == 0);
field_size = idx_size (meta, MONO_TABLE_PROPERTY); break;
case MONO_TABLE_TYPEDEF:
g_assert (i == 4 || i == 5);
field_size = i == 4 ? idx_size (meta, MONO_TABLE_FIELD):
idx_size (meta, MONO_TABLE_METHOD);
break;
case MONO_TABLE_GENERICPARAM:
g_assert (i == 2);
n = MAX (get_nrows (meta, MONO_TABLE_METHOD), get_nrows (meta, MONO_TABLE_TYPEDEF));
/*This is a coded token for 2 tables, so takes 1 bit */
field_size = rtsize (meta, n, 16 - MONO_TYPEORMETHOD_BITS);
break;
case MONO_TABLE_GENERICPARAMCONSTRAINT:
g_assert (i == 0);
field_size = idx_size (meta, MONO_TABLE_GENERICPARAM);
break;
case MONO_TABLE_LOCALSCOPE:
switch (i) {
case 0:
// FIXME: This table is in another file
field_size = idx_size (meta, MONO_TABLE_METHOD);
break;
case 1:
field_size = idx_size (meta, MONO_TABLE_IMPORTSCOPE);
break;
case 2:
field_size = idx_size (meta, MONO_TABLE_LOCALVARIABLE);
break;
case 3:
field_size = idx_size (meta, MONO_TABLE_LOCALCONSTANT);
break;
default:
g_assert_not_reached ();
break;
}
break;
case MONO_TABLE_METHODBODY:
g_assert (i == 0);
field_size = idx_size (meta, MONO_TABLE_DOCUMENT); break;
case MONO_TABLE_IMPORTSCOPE:
g_assert(i == 0);
field_size = idx_size (meta, MONO_TABLE_IMPORTSCOPE); break;
case MONO_TABLE_STATEMACHINEMETHOD:
g_assert(i == 0 || i == 1);
field_size = idx_size(meta, MONO_TABLE_METHOD); break;
default:
g_error ("Can't handle MONO_MT_TABLE_IDX for table %d element %d", tableindex, i);
}
break;
/*
* HasConstant: ParamDef, FieldDef, Property
*/
case MONO_MT_CONST_IDX:
n = MAX (get_nrows (meta, MONO_TABLE_PARAM),
get_nrows (meta, MONO_TABLE_FIELD));
n = MAX (n, get_nrows (meta, MONO_TABLE_PROPERTY));
/* 2 bits to encode tag */
field_size = rtsize (meta, n, 16-2);
break;
/*
* HasCustomAttribute: points to any table but
* itself.
*/
case MONO_MT_HASCAT_IDX:
/*
* We believe that since the signature and
* permission are indexing the Blob heap,
* we should consider the blob size first
*/
/* I'm not a believer - lupus
if (meta->idx_blob_wide){
field_size = 4;
break;
}*/
n = MAX (get_nrows (meta, MONO_TABLE_METHOD),
get_nrows (meta, MONO_TABLE_FIELD));
n = MAX (n, get_nrows (meta, MONO_TABLE_TYPEREF));
n = MAX (n, get_nrows (meta, MONO_TABLE_TYPEDEF));
n = MAX (n, get_nrows (meta, MONO_TABLE_PARAM));
n = MAX (n, get_nrows (meta, MONO_TABLE_INTERFACEIMPL));
n = MAX (n, get_nrows (meta, MONO_TABLE_MEMBERREF));
n = MAX (n, get_nrows (meta, MONO_TABLE_MODULE));
n = MAX (n, get_nrows (meta, MONO_TABLE_DECLSECURITY));
n = MAX (n, get_nrows (meta, MONO_TABLE_PROPERTY));
n = MAX (n, get_nrows (meta, MONO_TABLE_EVENT));
n = MAX (n, get_nrows (meta, MONO_TABLE_STANDALONESIG));
n = MAX (n, get_nrows (meta, MONO_TABLE_MODULEREF));
n = MAX (n, get_nrows (meta, MONO_TABLE_TYPESPEC));
n = MAX (n, get_nrows (meta, MONO_TABLE_ASSEMBLY));
n = MAX (n, get_nrows (meta, MONO_TABLE_ASSEMBLYREF));
n = MAX (n, get_nrows (meta, MONO_TABLE_FILE));
n = MAX (n, get_nrows (meta, MONO_TABLE_EXPORTEDTYPE));
n = MAX (n, get_nrows (meta, MONO_TABLE_MANIFESTRESOURCE));
n = MAX (n, get_nrows (meta, MONO_TABLE_GENERICPARAM));
n = MAX (n, get_nrows (meta, MONO_TABLE_GENERICPARAMCONSTRAINT));
n = MAX (n, get_nrows (meta, MONO_TABLE_METHODSPEC));
/* 5 bits to encode */
field_size = rtsize (meta, n, 16-5);
break;
/*
* HasCustomAttribute: points to any table but
* itself.
*/
case MONO_MT_HASCUSTDEBUG_IDX:
n = MAX(get_nrows (meta, MONO_TABLE_METHOD),
get_nrows (meta, MONO_TABLE_FIELD));
n = MAX(n, get_nrows (meta, MONO_TABLE_TYPEREF));
n = MAX(n, get_nrows (meta, MONO_TABLE_TYPEDEF));
n = MAX(n, get_nrows (meta, MONO_TABLE_PARAM));
n = MAX(n, get_nrows (meta, MONO_TABLE_INTERFACEIMPL));
n = MAX(n, get_nrows (meta, MONO_TABLE_MEMBERREF));
n = MAX(n, get_nrows (meta, MONO_TABLE_MODULE));
n = MAX(n, get_nrows (meta, MONO_TABLE_DECLSECURITY));
n = MAX(n, get_nrows (meta, MONO_TABLE_PROPERTY));
n = MAX(n, get_nrows (meta, MONO_TABLE_EVENT));
n = MAX(n, get_nrows (meta, MONO_TABLE_STANDALONESIG));
n = MAX(n, get_nrows (meta, MONO_TABLE_MODULEREF));
n = MAX(n, get_nrows (meta, MONO_TABLE_TYPESPEC));
n = MAX(n, get_nrows (meta, MONO_TABLE_ASSEMBLY));
n = MAX(n, get_nrows (meta, MONO_TABLE_ASSEMBLYREF));
n = MAX(n, get_nrows (meta, MONO_TABLE_FILE));
n = MAX(n, get_nrows (meta, MONO_TABLE_EXPORTEDTYPE));
n = MAX(n, get_nrows (meta, MONO_TABLE_MANIFESTRESOURCE));
n = MAX(n, get_nrows (meta, MONO_TABLE_GENERICPARAM));
n = MAX(n, get_nrows (meta, MONO_TABLE_GENERICPARAMCONSTRAINT));
n = MAX(n, get_nrows (meta, MONO_TABLE_METHODSPEC));
n = MAX(n, get_nrows (meta, MONO_TABLE_DOCUMENT));
n = MAX(n, get_nrows (meta, MONO_TABLE_LOCALSCOPE));
n = MAX(n, get_nrows (meta, MONO_TABLE_LOCALVARIABLE));
n = MAX(n, get_nrows (meta, MONO_TABLE_LOCALCONSTANT));
n = MAX(n, get_nrows (meta, MONO_TABLE_IMPORTSCOPE));
/* 5 bits to encode */
field_size = rtsize(meta, n, 16 - 5);
break;
/*
* CustomAttributeType: MethodDef, MemberRef.
*/
case MONO_MT_CAT_IDX:
n = MAX (get_nrows (meta, MONO_TABLE_METHOD),
get_nrows (meta, MONO_TABLE_MEMBERREF));
/* 3 bits to encode */
field_size = rtsize (meta, n, 16-3);
break;
/*
* HasDeclSecurity: Typedef, MethodDef, Assembly
*/
case MONO_MT_HASDEC_IDX:
n = MAX (get_nrows (meta, MONO_TABLE_TYPEDEF),
get_nrows (meta, MONO_TABLE_METHOD));
n = MAX (n, get_nrows (meta, MONO_TABLE_ASSEMBLY));
/* 2 bits to encode */
field_size = rtsize (meta, n, 16-2);
break;
/*
* Implementation: File, AssemblyRef, ExportedType
*/
case MONO_MT_IMPL_IDX:
n = MAX (get_nrows (meta, MONO_TABLE_FILE),
get_nrows (meta, MONO_TABLE_ASSEMBLYREF));
n = MAX (n, get_nrows (meta, MONO_TABLE_EXPORTEDTYPE));
/* 2 bits to encode tag */
field_size = rtsize (meta, n, 16-2);
break;
/*
* HasFieldMarshall: FieldDef, ParamDef
*/
case MONO_MT_HFM_IDX:
n = MAX (get_nrows (meta, MONO_TABLE_FIELD),
get_nrows (meta, MONO_TABLE_PARAM));
/* 1 bit used to encode tag */
field_size = rtsize (meta, n, 16-1);
break;
/*
* MemberForwarded: FieldDef, MethodDef
*/
case MONO_MT_MF_IDX:
n = MAX (get_nrows (meta, MONO_TABLE_FIELD),
get_nrows (meta, MONO_TABLE_METHOD));
/* 1 bit used to encode tag */
field_size = rtsize (meta, n, 16-1);
break;
/*
* TypeDefOrRef: TypeDef, ParamDef, TypeSpec
* LAMESPEC
* It is TypeDef, _TypeRef_, TypeSpec, instead.
*/
case MONO_MT_TDOR_IDX:
n = MAX (get_nrows (meta, MONO_TABLE_TYPEDEF),
get_nrows (meta, MONO_TABLE_TYPEREF));
n = MAX (n, get_nrows (meta, MONO_TABLE_TYPESPEC));
/* 2 bits to encode */
field_size = rtsize (meta, n, 16-2);
break;
/*
* MemberRefParent: TypeDef, TypeRef, MethodDef, ModuleRef, TypeSpec, MemberRef
*/
case MONO_MT_MRP_IDX:
n = MAX (get_nrows (meta, MONO_TABLE_TYPEDEF),
get_nrows (meta, MONO_TABLE_TYPEREF));
n = MAX (n, get_nrows (meta, MONO_TABLE_METHOD));
n = MAX (n, get_nrows (meta, MONO_TABLE_MODULEREF));
n = MAX (n, get_nrows (meta, MONO_TABLE_TYPESPEC));
/* 3 bits to encode */
field_size = rtsize (meta, n, 16 - 3);
break;
/*
* MethodDefOrRef: MethodDef, MemberRef
*/
case MONO_MT_MDOR_IDX:
n = MAX (get_nrows (meta, MONO_TABLE_METHOD),
get_nrows (meta, MONO_TABLE_MEMBERREF));
/* 1 bit used to encode tag */
field_size = rtsize (meta, n, 16-1);
break;
/*
* HasSemantics: Property, Event
*/
case MONO_MT_HS_IDX:
n = MAX (get_nrows (meta, MONO_TABLE_PROPERTY),
get_nrows (meta, MONO_TABLE_EVENT));
/* 1 bit used to encode tag */
field_size = rtsize (meta, n, 16-1);
break;
/*
* ResolutionScope: Module, ModuleRef, AssemblyRef, TypeRef
*/
case MONO_MT_RS_IDX:
n = MAX (get_nrows (meta, MONO_TABLE_MODULE),
get_nrows (meta, MONO_TABLE_MODULEREF));
n = MAX (n, get_nrows (meta, MONO_TABLE_ASSEMBLYREF));
n = MAX (n, get_nrows (meta, MONO_TABLE_TYPEREF));
/* 2 bits used to encode tag (ECMA spec claims 3) */
field_size = rtsize (meta, n, 16 - 2);
break;
}
/*
* encode field size as follows (we just need to
* distinguish them).
*
* 4 -> 3
* 2 -> 1
* 1 -> 0
*/
bitfield |= (field_size-1) << shift;
shift += 2;
size += field_size;
/*g_print ("table %02x field %d size %d\n", tableindex, i, field_size);*/
}
*result_bitfield = (i << 24) | bitfield;
return size;
}
/* returns true if given index is not in bounds with provided table/index pair */
gboolean
mono_metadata_table_bounds_check_slow (MonoImage *image, int table_index, int token_index)
{
if (G_LIKELY (GINT_TO_UINT32(token_index) <= table_info_get_rows (&image->tables [table_index])))
return FALSE;
if (G_LIKELY (!image->has_updates))