diff --git a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/PEReaderExtensions.cs b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/PEReaderExtensions.cs index 97fce016e68bd..aed29174fbb15 100644 --- a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/PEReaderExtensions.cs +++ b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/PEReaderExtensions.cs @@ -110,7 +110,10 @@ public static int GetOffset(this PEReader reader, int rva) int index = reader.PEHeaders.GetContainingSectionIndex(rva); if (index == -1) { - throw new BadImageFormatException("Failed to convert invalid RVA to offset: " + rva); + var sectionInfo = new StringBuilder(); + foreach (var sh in reader.PEHeaders.SectionHeaders) + sectionInfo.AppendLine($" {sh.Name} PTRD={sh.PointerToRawData} SORD={sh.SizeOfRawData} VA={sh.VirtualAddress} VS={sh.VirtualSize}"); + throw new BadImageFormatException($"Failed to convert invalid RVA to offset: {rva}.\nSections:\n{sectionInfo}"); } SectionHeader containingSection = reader.PEHeaders.SectionHeaders[index]; return rva - containingSection.VirtualAddress + containingSection.PointerToRawData; diff --git a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunReader.cs b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunReader.cs index 5c7dc7fe177fd..518dbee710d44 100644 --- a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunReader.cs +++ b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunReader.cs @@ -1380,7 +1380,7 @@ private void FindOwnerCompositeExecutable() } /// - /// based on ZapImportSectionsTable::Save + /// originally based on ZapImportSectionsTable::Save /// private void EnsureImportSections() {