Skip to content

Commit 8db7154

Browse files
authored
Fix R2RDump generic signature parsing (#33825)
The signature parsing wasn't handling module overrides correctly. For generic type parameters, the current module needs to be reset to the outer module.
1 parent 35df31c commit 8db7154

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/coreclr/src/tools/crossgen2/ILCompiler.Reflection.ReadyToRun/ReadyToRunSignature.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,23 @@ private SignatureDecoder(IAssemblyResolver options, MetadataReader metadataReade
407407
_contextReader = contextReader;
408408
}
409409

410+
/// <summary>
411+
/// Construct the signature decoder by storing the image byte array and offset within the array.
412+
/// This variant uses the outer global metadata reader
413+
/// </summary>
414+
/// <param name="options">Dump options and paths</param>
415+
/// <param name="signature">Signature to parse</param>
416+
/// <param name="offset">Signature offset within the signature byte array</param>
417+
/// <param name="contextReader">Top-level signature context reader</param>
418+
private SignatureDecoder(IAssemblyResolver options, byte[] signature, int offset, ReadyToRunReader contextReader)
419+
{
420+
_metadataReader = contextReader.GetGlobalMetadataReader();
421+
_options = options;
422+
_image = signature;
423+
_offset = offset;
424+
_contextReader = contextReader;
425+
}
426+
410427
/// <summary>
411428
/// Read a single byte from the signature stream and advances the current offset.
412429
/// </summary>
@@ -996,7 +1013,9 @@ private void ParseType(StringBuilder builder)
9961013
break;
9971014

9981015
case CorElementType.ELEMENT_TYPE_GENERICINST:
999-
ParseGenericTypeInstance(builder);
1016+
SignatureDecoder outerTypeDecoder = new SignatureDecoder(_options, _image, _offset, _contextReader);
1017+
outerTypeDecoder.ParseGenericTypeInstance(builder);
1018+
_offset = outerTypeDecoder._offset;
10001019
break;
10011020

10021021
case CorElementType.ELEMENT_TYPE_TYPEDBYREF:

0 commit comments

Comments
 (0)