2009-06-12 Bill Holmes <billholmes54@gmail.com>
[mono.git] / mono / tests / metadata-verifier / cli-blob-tests.md
1 method-def-sig {
2         assembly assembly-with-methods.exe
3
4         #bad first byte
5         #method zero is a default ctor
6         #0 -> default 5 -> vararg
7
8         #signature size, zero is invalid
9         invalid offset blob.i (table-row (6 0) + 10) set-byte 0
10
11         #cconv
12         invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x26
13         invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x27
14         invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x28
15         invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x29
16         invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2A
17         invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2B
18         invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2C
19         invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2D
20         invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2E
21         invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2F
22
23         #upper nimble flags 0x80 is invalid     
24         invalid offset blob.i (table-row (6 0) + 10) + 1 set-bit 7
25
26         #sig is too small to decode param count
27         invalid offset blob.i (table-row (6 0) + 10) set-byte 1
28
29         #sig is too small to decode return type
30         invalid offset blob.i (table-row (6 0) + 10) set-byte 2
31
32         #zero generic args
33         #method 1 is generic
34         #bytes: size cconv gen_param_count
35         invalid offset blob.i (table-row (6 1) + 10) + 2 set-byte 0
36
37         #set ret type to an invalid value
38         invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0
39         invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x17
40         invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x1A
41         invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x21 #mono doesn't support internal type
42         invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x40 #modifier
43         invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x41 #sentinel
44         invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x45 #pinner
45         invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x50 #type
46         invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x51 #boxed
47         invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x52 #reserved
48         invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x53 #field
49         invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x54 #property
50         invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x55 #enum
51
52         #bad args
53         #method 12 has sig void (int,int,int)
54         #bytes: size cconv param_count void int32 int32 int32
55         valid offset blob.i (table-row (6 12) + 10) + 4 set-byte 0x05
56         valid offset blob.i (table-row (6 12) + 10) + 5 set-byte 0x06
57         valid offset blob.i (table-row (6 12) + 10) + 6 set-byte 0x07
58
59         #void
60         invalid offset blob.i (table-row (6 12) + 10) + 5 set-byte 0x01
61
62         #byref without anything after
63         invalid offset blob.i (table-row (6 12) + 10) + 4 set-byte 0x10
64         invalid offset blob.i (table-row (6 12) + 10) + 5 set-byte 0x10
65         invalid offset blob.i (table-row (6 12) + 10) + 6 set-byte 0x10
66 }
67
68 #Test for stuff in the ret that can't be expressed with C#
69 method-def-ret-misc {
70         assembly assembly-with-custommod.exe
71
72         #method 0 has a modreq
73         #bytes: size cconv param_count mod_req compressed_token
74         invalid offset blob.i (table-row (6 0) + 10) + 4 set-byte 0x7C
75         invalid offset blob.i (table-row (6 0) + 10) + 4 set-byte 0x07
76
77         #switch modreq to modopt
78         valid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x20
79
80         #2 times byref
81         #method 4 returns byref
82         #bytes: size cconv param_count byref int32
83         invalid offset blob.i (table-row (6 4) + 10) + 4 set-byte 0x10
84         #byref of typedref
85         invalid offset blob.i (table-row (6 4) + 10) + 4 set-byte 0x16
86
87 }
88
89 method-ref-sig {
90         assembly assembly-with-signatures.exe
91
92         #member ref 0 is has a vararg sig 
93         #member ref 1 don't use vararg
94
95         #2 sentinels
96         #bytes: size cconv pcount void str obj obj obj obj ... i32 i32 i32
97         invalid offset blob.i (table-row (0xA 0) + 4) + 10 set-byte 0x41
98         invalid offset blob.i (table-row (0xA 0) + 4) + 11 set-byte 0x41
99
100         #sentinel but not vararg
101         invalid offset blob.i (table-row (0xA 0) + 4) + 1 set-byte 0
102 }
103
104 stand-alone-method-sig {
105         assembly assembly-with-custommod.exe
106
107         #standalone sig 0x3 points to an icall sig
108         valid offset blob.i (table-row (0x11 3)) + 1 set-byte 0x0
109         valid offset blob.i (table-row (0x11 3)) + 1 set-byte 0x1
110         valid offset blob.i (table-row (0x11 3)) + 1 set-byte 0x2
111         valid offset blob.i (table-row (0x11 3)) + 1 set-byte 0x3
112         valid offset blob.i (table-row (0x11 3)) + 1 set-byte 0x4
113         valid offset blob.i (table-row (0x11 3)) + 1 set-byte 0x5
114
115         #sig is int32 (int32)
116         #size cconv pcount(1) int32 int32 ->
117         #size cconv gcount(1) pcount(0) int32
118         #cannot have generics
119         invalid offset blob.i (table-row (0x11 3)) + 1 set-byte 0x10,
120                         offset blob.i (table-row (0x11 3)) + 2 set-byte 1,
121                         offset blob.i (table-row (0x11 3)) + 3 set-byte 0
122 }
123
124 field-sig {
125         assembly assembly-with-complex-type.exe
126
127         #first byte must be 6
128         invalid offset blob.i (table-row (4 0) + 4) + 1 set-byte 0x0
129         invalid offset blob.i (table-row (4 0) + 4) + 1 set-byte 0x5
130         invalid offset blob.i (table-row (4 0) + 4) + 1 set-byte 0x7
131         invalid offset blob.i (table-row (4 0) + 4) + 1 set-byte 0x16
132         invalid offset blob.i (table-row (4 0) + 4) + 1 set-byte 0x26
133 }
134
135 property-sig {
136         assembly assembly-with-properties.exe
137
138         #bad size
139         invalid offset blob.i (table-row (0x17 0) + 4) set-byte 0x0
140         invalid offset blob.i (table-row (0x17 0) + 4) set-byte 0x1
141
142         #cconv must be 0x08 or 0x28
143         valid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x08
144         valid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x28
145
146         invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x09
147         invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x29
148         invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x48
149         invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x18
150         invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x07
151         invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x00
152 }
153
154 locals-sig {
155         assembly assembly-with-locals.exe
156
157         #bad local sig
158         #row 0 has tons of locals
159         #row 1 is int32&, int32 
160         #row 2 is typedref
161
162         #typedref with byref
163         #row 1 is:      cconv pcount(2) byref int32      int32 
164         #row 1 goes to: cconv pcount(2) byref typedbyref int32
165         invalid offset blob.i (table-row (0x11 1)) + 4 set-byte 0x18
166
167         #byref pinned int32
168         #row 1 is:      cconv pcount(2) byref int32  int32 
169         #row 1 goes to: cconv pcount(1) byref pinned int32
170
171         invalid offset blob.i (table-row (0x11 1)) + 2 set-byte 0x01,
172                         offset blob.i (table-row (0x11 1)) + 4 set-byte 0x45
173
174         #pinned pinned int32
175         #row 1 is:      cconv pcount(2) byref  int32  int32 
176         #row 1 goes to: cconv pcount(1) pinned pinned int32
177
178         invalid offset blob.i (table-row (0x11 1)) + 2 set-byte 0x01,
179                         offset blob.i (table-row (0x11 1)) + 3 set-byte 0x45,
180                         offset blob.i (table-row (0x11 1)) + 4 set-byte 0x45
181 }
182
183 type-enc {
184         assembly assembly-with-types.exe
185
186         #valid
187         #change type from int to string
188         valid offset blob.i (table-row (0x04 0) + 4) + 2 set-byte 0x0E
189
190         #field 10 is cconv PTR int32
191         #make it: cconv PTR modreq
192         invalid offset blob.i (table-row (0x04 11) + 4) + 3 set-byte 0x1f
193
194         #pointer to pointer (not enought room to parse pointed to type)
195         #make it: cconv PTR PTR
196         invalid offset blob.i (table-row (0x04 11) + 4) + 3 set-byte 0x0f
197
198         #value type / class
199         #make it not have room for the token
200         invalid offset blob.i (table-row (0x04 0) + 4) + 2 set-byte 0x11
201         invalid offset blob.i (table-row (0x04 0) + 4) + 2 set-byte 0x12
202
203         #var / mvar
204         #make it not have room for the token
205         invalid offset blob.i (table-row (0x04 0) + 4) + 2 set-byte 0x13
206         invalid offset blob.i (table-row (0x04 0) + 4) + 2 set-byte 0x1e
207
208         #general array
209         #field 3 is a int32[,,]: cconv ARRAY int32 rank(3) nsizes(0) nlowb(0)
210         #make the array type invalid (byref/typedref/void/plain wrong)
211         invalid offset blob.i (table-row (0x04 3) + 4) + 3 set-byte 0x00
212         invalid offset blob.i (table-row (0x04 3) + 4) + 3 set-byte 0x01
213         invalid offset blob.i (table-row (0x04 3) + 4) + 3 set-byte 0x10
214         #LAMEIMPL MS accepts arrays of typedbyref, which is illegal and unsafe
215         invalid offset blob.i (table-row (0x04 3) + 4) + 3 set-byte 0x16
216
217         #LAMEIMPL MS verifier doesn't catch this one (runtime does)
218         #rank 0 
219         invalid offset blob.i (table-row (0x04 3) + 4) + 4 set-byte 0x00
220         #large nsizes
221         invalid offset blob.i (table-row (0x04 3) + 4) + 5 set-byte 0x1F
222         #large nlowb
223         invalid offset blob.i (table-row (0x04 3) + 4) + 6 set-byte 0x1F
224
225
226         #generic inst
227         #field 20 is Test<int32>; 21 is class [mscorlib]System.IComparable`1<object>; 22 is valuetype Test2<!0>
228         #format is cconc GINST KIND token arg_count type*
229
230         #make bad kind
231         invalid offset blob.i (table-row (0x04 20) + 4) + 3 set-byte 0x05
232
233         #bad token
234         invalid offset blob.i (table-row (0x04 20) + 4) + 4 set-byte 0x3F
235         #zero arg_count
236         invalid offset blob.i (table-row (0x04 20) + 4) + 5 set-byte 0x0
237         #bad arg_count
238         invalid offset blob.i (table-row (0x04 20) + 4) + 5 set-byte 0x10
239
240         #fnptr
241         #field 10 is a fnptr
242         #format is: cconv FNPTR cconv pcount ret param* sentinel? param*
243         #LAMESPEC, it lacks the fact that fnptr allows for unmanaged call conv 
244         #bad callconv
245         invalid offset blob.i (table-row (0x04 10) + 4) + 3 set-byte 0x88
246
247         #szarray
248         #field 17 is an array with modreq on target
249         #format is: cconv SZARRAY cmod* type
250         #array type is void
251         invalid offset blob.i (table-row (0x04 17) + 4) + 3 set-byte 0x01
252 }
253
254 typespec-sig {
255         assembly assembly-with-typespec.exe
256
257         #LAMESPEC
258         #ecma spec doesn't allow simple types such as uint32. But MS does and there
259         #is no harm into supporting it.
260         #row zero is "void*" encoded as PTR VOID
261         valid offset blob.i (table-row (0x1B 0)) + 1 set-byte 0x09
262
263         #type zero is invalid
264         invalid offset blob.i (table-row (0x1B 0)) + 1 set-byte 0x0
265
266         #LAMESPEC part II, MS allows for cmods on a typespec as well 
267         #modreq int32 is invalid
268         #typespec 2 is "modreq int32*" encoded as: PTR CMOD_REQD token INT32
269         #change int to CMOD_REQD token INT32 
270         valid offset blob.i (table-row (0x1B 2)) + 1 set-byte 0x1f, #CMOD_REQD
271                         offset blob.i (table-row (0x1B 2)) + 2 set-byte read.byte (blob.i (table-row (0x1B 2)) + 3), #token
272                         offset blob.i (table-row (0x1B 2)) + 3 set-byte 0x08 #int8
273
274         #typedref is fine too.
275         valid offset blob.i (table-row (0x1B 2)) + 0 set-byte 0x16
276 }
277
278 methodspec-sig {
279         assembly assembly-with-generics.exe
280
281         #LAMESPEC spec is completelly wrong on this one. method spec holds simply a generic instantation
282         #no type on it
283
284         #first byte is the genericinst callconv 0xA
285         #row zero is Gen<!1> or: GENRICINST gcount(1) type*
286         invalid offset blob.i (table-row (0x2B 0) + 2) + 1 set-byte 0x08
287
288         #zero arg count
289         invalid offset blob.i (table-row (0x2B 0) + 2) + 2 set-byte 0x0
290
291         #bad argument
292         invalid offset blob.i (table-row (0x2B 0) + 2) + 3 set-byte 0x01
293 }