-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8027 from tmat/TypeDefRefSpec
Disallow TypeSpec after CLASS and VALUETYPE in signatures
- Loading branch information
Showing
10 changed files
with
188 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+2 KB
src/Compilers/Test/Resources/Core/MetadataTests/Invalid/Signatures/SignatureCycle2.exe
Binary file not shown.
55 changes: 55 additions & 0 deletions
55
src/Compilers/Test/Resources/Core/MetadataTests/Invalid/Signatures/SignatureCycle2.il
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// Example #2 -- call within same assembly to cyclical signature | ||
// | ||
// NOTE: build.bat creates the cycle by modifying the ilasm output | ||
// | ||
// From: | ||
// List`1<int32 modopt([TypeSpec #1])> | ||
// | | ||
// v | ||
// int32 | ||
// | ||
// To: | ||
// List`1<int32 modopt([TypeSpec #2]) | ||
// ^---------------------| | ||
// | ||
// Symptoms: | ||
// * peverify.exe succeeds | ||
// * program crashes (stack overflow) | ||
// * ildasm crashes (likely stack overflow) | ||
// | ||
|
||
.assembly extern mscorlib { .ver 4:0:0:0 .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) } | ||
.assembly SignatureCycle2 {} | ||
.module SignatureCycle2.exe | ||
|
||
.class public Extender extends class [mscorlib]System.Collections.Generic.List`1<int32 modopt(int32)> | ||
{ | ||
.method public specialname rtspecialname instance void .ctor() | ||
{ | ||
ldarg.0 | ||
call instance void class [mscorlib]System.Collections.Generic.List`1<int32 modopt(int32)>::.ctor() | ||
ldstr "hello world" | ||
call void [mscorlib]System.Console::WriteLine(object) | ||
ret | ||
} | ||
|
||
.method public static void Main() | ||
{ | ||
.entrypoint | ||
newobj instance void Extender::.ctor() | ||
call void User::X(class [mscorlib]System.Collections.Generic.List`1<int32 modopt(int32)>) | ||
ret | ||
} | ||
} | ||
|
||
.class public User extends [mscorlib]System.Object | ||
{ | ||
.method public static void X(class [mscorlib]System.Collections.Generic.List`1<int32 modopt(int32)>) | ||
{ | ||
ldstr "goodbye world" | ||
call void [mscorlib]System.Console::WriteLine(object) | ||
ret | ||
} | ||
} | ||
|
Binary file added
BIN
+2 KB
src/Compilers/Test/Resources/Core/MetadataTests/Invalid/Signatures/TypeSpecInWrongPlace.exe
Binary file not shown.
34 changes: 34 additions & 0 deletions
34
src/Compilers/Test/Resources/Core/MetadataTests/Invalid/Signatures/TypeSpecInWrongPlace.il
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// Example #5 -- using (CLASS | VALUETYPE) TypeSpec instead of embedding the type in to the signature. | ||
// | ||
// build.bat will change the siganture of User::X to use a TypeSpec for List<int> instead of embedding GENERICINST in the signature. | ||
// | ||
// * peverify correctly identifies error: | ||
// [MD]: Error: Signature has token following ELEMENT_TYPE_CLASS (_VALUETYPE) that is not a TypeDef or TypeRef (token: 0x1b000001; offset: 0x00000005). [token:0x06000002] | ||
// | ||
// This just demonstrates that the rule is not called out in the CLI spec | ||
|
||
.assembly extern mscorlib { .ver 4:0:0:0 .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) } | ||
.assembly TypeSpecInWrongPlace {} | ||
.module TypeSpecInWrongPlace.exe | ||
|
||
.class public Extender extends class [mscorlib]System.Collections.Generic.List`1<int32> | ||
{ | ||
.method public static void Main() | ||
{ | ||
.entrypoint | ||
newobj instance void class [mscorlib]System.Collections.Generic.List`1<int32>::.ctor() | ||
call void User::X(class [mscorlib]System.Collections.Generic.List`1<int32>) | ||
ret | ||
} | ||
} | ||
|
||
.class public User extends [mscorlib]System.Object | ||
{ | ||
.method public static void X(class [mscorlib]System.Collections.Generic.List`1<int32>) | ||
{ | ||
ldstr "goodbye world" | ||
call void [mscorlib]System.Console::WriteLine(object) | ||
ret | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/Compilers/Test/Resources/Core/MetadataTests/Invalid/Signatures/build.bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ilasm SignatureCycle2.il | ||
csi munge.csx SignatureCycle2.exe 15-12-05-01-20-06-08 15-12-05-01-20-0A-08 | ||
|
||
ilasm TypeSpecInWrongPlace.il | ||
csi munge.csx TypeSpecInWrongPlace.exe 00-01-01-15-12-05-01-08 00-01-01-12-06-00-00-00 | ||
|
14 changes: 14 additions & 0 deletions
14
src/Compilers/Test/Resources/Core/MetadataTests/Invalid/Signatures/munge.csx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
string file = Args[0]; | ||
string hexSearch = Args[1]; | ||
string hexReplace = Args[2]; | ||
|
||
File.WriteAllBytes( | ||
Args[0], | ||
BitConverter.ToString(File.ReadAllBytes(Args[0])) | ||
.Replace(hexSearch, hexReplace) | ||
.Split('-') | ||
.Select(s => Convert.ToByte(s, 16)) | ||
.ToArray()); | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters