Skip to content
Merged
18 changes: 14 additions & 4 deletions src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,23 @@ private EcmaModule AddModule(string filePath, string expectedSimpleName, bool us
filePath = Path.GetFullPath(filePath);
peReader = OpenPEFile(filePath, out mappedViewAccessor);

try
{
Comment thread
jkotas marked this conversation as resolved.
// Ensure the PEHeaders can be read
_ = peReader.PEHeaders;
Comment thread
jkotas marked this conversation as resolved.

#if !READYTORUN
if (peReader.HasMetadata && (peReader.PEHeaders.CorHeader.Flags & (CorFlags.ILLibrary | CorFlags.ILOnly)) == 0)
throw new NotSupportedException($"Error: C++/CLI is not supported: '{filePath}'");
if (peReader.HasMetadata && (peReader.PEHeaders.CorHeader.Flags & (CorFlags.ILLibrary | CorFlags.ILOnly)) == 0)
throw new NotSupportedException($"Error: C++/CLI is not supported: '{filePath}'");
#endif

pdbReader = PortablePdbSymbolReader.TryOpenEmbedded(peReader, GetMetadataStringDecoder())
?? OpenAssociatedSymbolFile(filePath, peReader);
pdbReader = PortablePdbSymbolReader.TryOpenEmbedded(peReader, GetMetadataStringDecoder())
?? OpenAssociatedSymbolFile(filePath, peReader);
}
catch (BadImageFormatException ex)
{
throw new BadImageFormatException(ex.Message, filePath);
}
Comment thread
MichalStrehovsky marked this conversation as resolved.
}
else
{
Expand Down
Loading