diff options
author | Tomáš Rylek <trylek@microsoft.com> | 2019-05-02 15:23:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-02 15:23:08 +0200 |
commit | 1de8b99c660fdb0eab8688d16b7d77af6e362b56 (patch) | |
tree | ba5a787adc4be4557210fb15289082da5beeb267 /src/tools | |
parent | 20904a2629729e33531f30d87ae04b285cb34ee7 (diff) | |
download | coreclr-1de8b99c660fdb0eab8688d16b7d77af6e362b56.tar.gz coreclr-1de8b99c660fdb0eab8688d16b7d77af6e362b56.tar.bz2 coreclr-1de8b99c660fdb0eab8688d16b7d77af6e362b56.zip |
Bug fix in R2RDump signature decoder w.r.t. large version bubbles (#24352)
JanV discovered a complex signature where the generic type argument
got decoded in an incorrect module context by R2RDump. Investigating
the issue I found out that the problem was caused by my slight
misunderstanding - all module override indices within a signature
are relative to the global signature context module, not to the current
context module that may change during descent into the signature tree.
Thanks
Tomas
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/r2rdump/R2RSignature.cs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/tools/r2rdump/R2RSignature.cs b/src/tools/r2rdump/R2RSignature.cs index a3169530a8..95be66846a 100644 --- a/src/tools/r2rdump/R2RSignature.cs +++ b/src/tools/r2rdump/R2RSignature.cs @@ -319,6 +319,11 @@ namespace R2RDump private readonly EcmaMetadataReader _ecmaReader; /// <summary> + /// ECMA reader representing the top-level signature context. + /// </summary> + private readonly EcmaMetadataReader _contextReader; + + /// <summary> /// Dump options are used to specify details of signature formatting. /// </summary> private readonly DumpOptions _options; @@ -350,6 +355,7 @@ namespace R2RDump _options = options; _image = ecmaReader.Image; _offset = offset; + _contextReader = ecmaReader; } /// <summary> @@ -359,12 +365,14 @@ namespace R2RDump /// <param name="ecmaReader">Metadata reader for the R2R image</param> /// <param name="signature">Signature to parse</param> /// <param name="offset">Signature offset within the signature byte array</param> - public SignatureDecoder(DumpOptions options, EcmaMetadataReader ecmaReader, byte[] signature, int offset) + /// <param name="contextReader">Top-level signature context reader</param> + public SignatureDecoder(DumpOptions options, EcmaMetadataReader ecmaReader, byte[] signature, int offset, EcmaMetadataReader contextReader) { _ecmaReader = ecmaReader; _options = options; _image = signature; _offset = offset; + _contextReader = contextReader; } /// <summary> @@ -501,8 +509,8 @@ namespace R2RDump { fixupType &= ~(uint)CORCOMPILE_FIXUP_BLOB_KIND.ENCODE_MODULE_OVERRIDE; int moduleIndex = (int)ReadUInt(); - EcmaMetadataReader refAsmEcmaReader = _ecmaReader.OpenReferenceAssembly(moduleIndex); - moduleDecoder = new SignatureDecoder(_options, refAsmEcmaReader, _image, _offset); + EcmaMetadataReader refAsmEcmaReader = _contextReader.OpenReferenceAssembly(moduleIndex); + moduleDecoder = new SignatureDecoder(_options, refAsmEcmaReader, _image, _offset, _contextReader); } moduleDecoder.ParseSignature((ReadyToRunFixupKind)fixupType, builder); @@ -923,8 +931,8 @@ namespace R2RDump case CorElementType.ELEMENT_TYPE_MODULE_ZAPSIG: { int moduleIndex = (int)ReadUInt(); - EcmaMetadataReader refAsmReader = _ecmaReader.OpenReferenceAssembly(moduleIndex); - SignatureDecoder refAsmDecoder = new SignatureDecoder(_options, refAsmReader, _image, _offset); + EcmaMetadataReader refAsmReader = _contextReader.OpenReferenceAssembly(moduleIndex); + SignatureDecoder refAsmDecoder = new SignatureDecoder(_options, refAsmReader, _image, _offset, _contextReader); refAsmDecoder.ParseType(builder); _offset = refAsmDecoder.Offset; } @@ -976,7 +984,7 @@ namespace R2RDump string owningTypeOverride = null; if ((methodFlags & (uint)ReadyToRunMethodSigFlags.READYTORUN_METHOD_SIG_OwnerType) != 0) { - SignatureDecoder owningTypeDecoder = new SignatureDecoder(_options, _ecmaReader, _image, _offset); + SignatureDecoder owningTypeDecoder = new SignatureDecoder(_options, _ecmaReader, _image, _offset, _contextReader); owningTypeOverride = owningTypeDecoder.ReadTypeSignature(); _offset = owningTypeDecoder._offset; } |