summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Sullivan <briansul@microsoft.com>2019-08-07 09:15:43 -0700
committerWilliam Godbe <wigodbe@microsoft.com>2019-08-07 09:15:43 -0700
commitb1efbdd7b6498cb92e1fce6927691764a1f06b55 (patch)
treea580e0ef5a98b45b56db1aeb70d894eecc360d33
parentb4a56b0339ff1eea904e1b8d3f89507552529d3b (diff)
downloadcoreclr-b1efbdd7b6498cb92e1fce6927691764a1f06b55.tar.gz
coreclr-b1efbdd7b6498cb92e1fce6927691764a1f06b55.tar.bz2
coreclr-b1efbdd7b6498cb92e1fce6927691764a1f06b55.zip
Fixes Issue #20262 for CoreCLR 5.0 (#25926) (#25988)
Disassembler: ildasm/dasm.cpp In the CoreCLR with reference assemblies and redirection it is more difficult to determine if a particular Assembly is the System assembly, like mscorlib.dll is for the Desktop CLR. In the CoreCLR runtimes, the System assembly can be System.Private.CoreLib.dll, System.Runtime.dll or netstandard.dll and in the future a different Assembly name could be used. We now determine the identity of the System assembly by querying if the Assembly defines the well known type System.Object as that type must be defined by the System assembly If this type is defined then we will output the ".mscorlib" directive to indicate that this assembly is the System assembly. Assembler: ilasm/assembler.cpp In Assembler:GetBaseAsmRef() add a check for System.Private.CoreLib as the System or Base assembly.
-rw-r--r--src/ilasm/assembler.cpp8
-rw-r--r--src/ildasm/dasm.cpp77
2 files changed, 47 insertions, 38 deletions
diff --git a/src/ilasm/assembler.cpp b/src/ilasm/assembler.cpp
index 38d83d083e..37158d6488 100644
--- a/src/ilasm/assembler.cpp
+++ b/src/ilasm/assembler.cpp
@@ -276,6 +276,14 @@ mdToken Assembler::GetAsmRef(__in __nullterminated const char* szName)
mdToken Assembler::GetBaseAsmRef()
{
+ // First we check for "System.Private.CoreLib" as the base or System assembly
+ //
+ AsmManAssembly* coreLibAsm = m_pManifest->GetAsmRefByAsmName("System.Private.CoreLib");
+ if(coreLibAsm != NULL)
+ {
+ return GetAsmRef(coreLibAsm->szAlias ? coreLibAsm->szAlias : coreLibAsm->szName);
+ }
+
AsmManAssembly* sysRuntime = m_pManifest->GetAsmRefByAsmName("System.Runtime");
if(sysRuntime != NULL)
{
diff --git a/src/ildasm/dasm.cpp b/src/ildasm/dasm.cpp
index f0796c4612..6535a07d29 100644
--- a/src/ildasm/dasm.cpp
+++ b/src/ildasm/dasm.cpp
@@ -928,50 +928,51 @@ bool HasSuppressingAttribute()
#endif
void DumpMscorlib(void* GUICookie)
{
- if(g_pAssemblyImport==NULL) g_pAssemblyImport = GetAssemblyImport(GUICookie);
- if(g_pAssemblyImport!=NULL)
- {
- mdAssembly tkAsm;
- if(SUCCEEDED(g_pAssemblyImport->GetAssemblyFromScope(&tkAsm))&&(tkAsm != mdAssemblyNil))
- {
- const void* pPublicKey;
- ULONG cbPublicKey = 0;
- ULONG ulHashAlgId;
- WCHAR wzName[1024];
- ULONG ulNameLen=0;
- ASSEMBLYMETADATA md;
- WCHAR wzLocale[1024];
- DWORD dwFlags;
- //char szString[4096];
-
- md.szLocale = wzLocale;
- md.cbLocale = 1024;
- md.rProcessor = NULL;
- md.ulProcessor = 0;
- md.rOS = NULL;
- md.ulOS = 0;
-
- if(SUCCEEDED(g_pAssemblyImport->GetAssemblyProps( // S_OK or error.
- tkAsm, // [IN] The Assembly for which to get the properties.
- &pPublicKey, // [OUT] Pointer to the public key.
- &cbPublicKey,// [OUT] Count of bytes in the public key.
- &ulHashAlgId,// [OUT] Hash Algorithm.
- wzName, // [OUT] Buffer to fill with name.
- 1024, // [IN] Size of buffer in wide chars.
- &ulNameLen, // [OUT] Actual # of wide chars in name.
- &md, // [OUT] Assembly MetaData.
- &dwFlags))) // [OUT] Flags.
+ // In the CoreCLR with reference assemblies and redirection it is more difficult to determine if
+ // a particular Assembly is the System assembly, like mscorlib.dll is for the Desktop CLR.
+ // In the CoreCLR runtimes, the System assembly can be System.Private.CoreLib.dll, System.Runtime.dll
+ // or netstandard.dll and in the future a different Assembly name could be used.
+ // We now determine the identity of the System assembly by querying if the Assembly defines the
+ // well known type System.Object as that type must be defined by the System assembly
+ // If this type is defined then we will output the ".mscorlib" directive to indicate that this
+ // assembly is the System assembly.
+ //
+ mdTypeDef tkObjectTypeDef = mdTypeDefNil;
+
+ // Lookup the type System.Object and see it it has a type definition in this assembly
+ if (SUCCEEDED(g_pPubImport->FindTypeDefByName(W("System.Object"), mdTypeDefNil, &tkObjectTypeDef)))
+ {
+ if (tkObjectTypeDef != mdTypeDefNil)
+ {
+ // We do have a type definition for System.Object in this assembly
+ //
+ DWORD dwClassAttrs = 0;
+ mdToken tkExtends = mdTypeDefNil;
+
+ // Retrieve the type def properties as well, so that we can check a few more things about
+ // the System.Object type
+ //
+ if (SUCCEEDED(g_pPubImport->GetTypeDefProps(tkObjectTypeDef, NULL, NULL, 0, &dwClassAttrs, &tkExtends)))
{
- if(wcscmp(wzName,W("mscorlib")) == 0)
+ bool bExtends = g_pPubImport->IsValidToken(tkExtends);
+ bool isClass = ((dwClassAttrs & tdClassSemanticsMask) == tdClass);
+
+ // We also check the type properties to make sure that we have a class and not a Value type definition
+ // and that this type definition isn't extending another type.
+ //
+ if (isClass & !bExtends)
{
- printLine(GUICookie,"");
- sprintf_s(szString,SZSTRING_SIZE,"%s%s ",g_szAsmCodeIndent,KEYWORD(".mscorlib"));
- printLine(GUICookie,szString);
- printLine(GUICookie,"");
+ // We will mark this assembly with the System assembly directive: .mscorlib
+ //
+ printLine(GUICookie, "");
+ sprintf_s(szString, SZSTRING_SIZE, "%s%s ", g_szAsmCodeIndent, KEYWORD(".mscorlib"));
+ printLine(GUICookie, szString);
+ printLine(GUICookie, "");
}
}
}
}
+
}
void DumpTypelist(void* GUICookie)
{