diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2019-05-02 21:16:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-02 21:16:25 +0200 |
commit | f76c817da05bc7ded0dd6d860a4e66b12b346f25 (patch) | |
tree | 0ba28459feae7daaeccb52686c0181e9f753c2a0 /src | |
parent | e548973a289698bda9a8583401a7e5a7bc1d55bb (diff) | |
parent | 4b603baf496544a6a6d67c4ef43ee1b3a200acfc (diff) | |
download | coreclr-f76c817da05bc7ded0dd6d860a4e66b12b346f25.tar.gz coreclr-f76c817da05bc7ded0dd6d860a4e66b12b346f25.tar.bz2 coreclr-f76c817da05bc7ded0dd6d860a4e66b12b346f25.zip |
Merge pull request #24332 from janvorli/fix-module-override
Fix module override effect on method instantiating signature
Diffstat (limited to 'src')
-rw-r--r-- | src/vm/zapsig.cpp | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/vm/zapsig.cpp b/src/vm/zapsig.cpp index cfccdea90a..8feb7bebcd 100644 --- a/src/vm/zapsig.cpp +++ b/src/vm/zapsig.cpp @@ -1315,7 +1315,7 @@ BOOL ZapSig::EncodeMethod( } else { - _ASSERTE(pInfoModule = pMethod->GetModule()); + _ASSERTE(pInfoModule == pMethod->GetModule()); } if (!ownerType.HasInstantiation()) @@ -1366,10 +1366,40 @@ BOOL ZapSig::EncodeMethod( { _ASSERTE(pResolvedToken->cbMethodSpec > 1); - if (*(BYTE*)pResolvedToken->pMethodSpec != (BYTE)IMAGE_CEE_CS_CALLCONV_GENERICINST) + // Copy the pResolvedToken->pMethodSpec, inserting ELEMENT_TYPE_MODULE_ZAPSIG in front of each type parameter in needed + SigParser sigParser(pResolvedToken->pMethodSpec); + BYTE callingConvention; + IfFailThrow(sigParser.GetByte(&callingConvention)); + if (callingConvention != (BYTE)IMAGE_CEE_CS_CALLCONV_GENERICINST) + { ThrowHR(COR_E_BADIMAGEFORMAT); + } + + ULONG numGenArgs; + IfFailThrow(sigParser.GetData(&numGenArgs)); + pSigBuilder->AppendData(numGenArgs); + + DWORD moduleIndex; + bool addModuleZapSig = (IsReadyToRunCompilation() && pMethod->GetModule()->IsInCurrentVersionBubble() && pInfoModule != (Module *) pResolvedToken->tokenScope); + if (addModuleZapSig) + { + moduleIndex = (*((EncodeModuleCallback)pfnEncodeModule))(pEncodeModuleContext, (Module *) pResolvedToken->tokenScope); + } - pSigBuilder->AppendBlob((PVOID)(((BYTE*)pResolvedToken->pMethodSpec) + 1), pResolvedToken->cbMethodSpec - 1); + while (numGenArgs != 0) + { + if (addModuleZapSig) + { + pSigBuilder->AppendElementType((CorElementType)ELEMENT_TYPE_MODULE_ZAPSIG); + pSigBuilder->AppendData(moduleIndex); + } + + PCCOR_SIGNATURE typeSigStart = sigParser.GetPtr(); + IfFailThrow(sigParser.SkipExactlyOne()); + PCCOR_SIGNATURE typeSigEnd = sigParser.GetPtr(); + pSigBuilder->AppendBlob((PVOID)typeSigStart, typeSigEnd - typeSigStart); + numGenArgs--; + } } else { |