Skip to content

Commit

Permalink
R2RDump fixes (dotnet#32460)
Browse files Browse the repository at this point in the history
  • Loading branch information
cshung authored Feb 18, 2020
1 parent 31c404c commit 2d6b77f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private void ParseUnwindCode(ref int i)
code.NextFrameOffset = (int)offset * 16;
if ((UnwindCodeArray[i].FrameOffset & 0xF0000000) != 0)
{
Console.WriteLine("Warning: Illegal unwindInfo unscaled offset: too large");
throw new BadImageFormatException("Warning: Illegal unwindInfo unscaled offset: too large");
}
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void ParseCoreHeader(byte[] image, ref int curOffset)
var sectionType = (ReadyToRunSectionType)type;
if (!Enum.IsDefined(typeof(ReadyToRunSectionType), type))
{
Console.WriteLine("Warning: Invalid ReadyToRun section type");
throw new BadImageFormatException("Warning: Invalid ReadyToRun section type");
}
int sectionStartRva = NativeReader.ReadInt32(image, ref curOffset);
int sectionLength = NativeReader.ReadInt32(image, ref curOffset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,17 @@ private bool TryLocateNativeReadyToRunHeader()
return false;
}

private MetadataReader GetSystemModuleMetadataReader() =>
_systemModuleReader ??= _assemblyResolver.FindAssembly(SystemModuleName, Filename);
private MetadataReader GetSystemModuleMetadataReader()
{
if (_systemModuleReader == null)
{
if (_assemblyResolver != null)
{
_systemModuleReader = _assemblyResolver.FindAssembly(SystemModuleName, Filename);
}
}
return _systemModuleReader;
}

public MetadataReader GetGlobalMetadataReader()
{
Expand Down Expand Up @@ -630,7 +639,7 @@ private void ParseInstanceMethodEntrypoints(bool[] isEntryPoint)
if (_composite)
{
// The only types that don't have module overrides on them in composite images are primitive types within the system module
mdReader ??= GetSystemModuleMetadataReader();
mdReader = GetSystemModuleMetadataReader();
}
owningType = decoder.ReadTypeSignatureNoEmit();
}
Expand Down

0 comments on commit 2d6b77f

Please sign in to comment.