Read the image earlier (#33576)
authorAndrew Au <andrewau@microsoft.com>
Sat, 14 Mar 2020 03:23:53 +0000 (20:23 -0700)
committerGitHub <noreply@github.com>
Sat, 14 Mar 2020 03:23:53 +0000 (20:23 -0700)
src/coreclr/src/tools/crossgen2/ILCompiler.Reflection.ReadyToRun/ReadyToRunReader.cs

index e05ffc1..4f7c0dc 100644 (file)
@@ -368,6 +368,11 @@ namespace ILCompiler.Reflection.ReadyToRun
 
                 PEReader = new PEReader(Unsafe.As<byte[], ImmutableArray<byte>>(ref image));
             }
+            else
+            {
+                ImmutableArray<byte> content = PEReader.GetEntireImage().GetContent();
+                Image = Unsafe.As<ImmutableArray<byte>, byte[]>(ref content);
+            }
 
             if (metadata == null && PEReader.HasMetadata)
             {
@@ -392,9 +397,6 @@ namespace ILCompiler.Reflection.ReadyToRun
             {
                 throw new BadImageFormatException($"ECMA metadata / RTR_HEADER not found in file '{Filename}'");
             }
-
-            ImmutableArray<byte> content = PEReader.GetEntireImage().GetContent();
-            Image = Unsafe.As<ImmutableArray<byte>, byte[]>(ref content);
         }
 
         private void EnsureMethods()