From: Tomáš Rylek Date: Thu, 23 Aug 2018 19:23:42 +0000 (+0200) Subject: Two R2RDump fixes for Crossgen output (dotnet/coreclr#19585) X-Git-Tag: submit/tizen/20210909.063632~11030^2~4072 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=341a8d2122ab39ec6d0f8f78d83a6c1f9c212cbb;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Two R2RDump fixes for Crossgen output (dotnet/coreclr#19585) 1) In some situations, Crossgen emits a section with EntrySize = 0. Apparently the engine defaults to size_t in such case. 2) Similarly, Crossgen sometimes emits a section with the UNKNOWN kind. I have relaxed the section kind check to just treat all non-eager section kinds the same. Thanks Tomas Commit migrated from https://github.com/dotnet/coreclr/commit/d22330a146dd3be30690b72be44f25e6b4bebe14 --- diff --git a/src/coreclr/src/tools/r2rdump/R2RReader.cs b/src/coreclr/src/tools/r2rdump/R2RReader.cs index 417b0c8..80664fc 100644 --- a/src/coreclr/src/tools/r2rdump/R2RReader.cs +++ b/src/coreclr/src/tools/r2rdump/R2RReader.cs @@ -401,6 +401,25 @@ namespace R2RDump R2RImportSection.CorCompileImportFlags flags = (R2RImportSection.CorCompileImportFlags)NativeReader.ReadUInt16(Image, ref offset); byte type = NativeReader.ReadByte(Image, ref offset); byte entrySize = NativeReader.ReadByte(Image, ref offset); + if (entrySize == 0) + { + switch (Machine) + { + case Machine.I386: + case Machine.ArmThumb2: + entrySize = 4; + break; + + case Machine.Amd64: + case Machine.IA64: + case Machine.Arm64: + entrySize = 8; + break; + + default: + throw new NotImplementedException(Machine.ToString()); + } + } int entryCount = 0; if (entrySize != 0) { @@ -434,8 +453,7 @@ namespace R2RDump } } break; - case R2RImportSection.CorCompileImportFlags.CORCOMPILE_IMPORT_FLAGS_CODE: - case R2RImportSection.CorCompileImportFlags.CORCOMPILE_IMPORT_FLAGS_PCODE: + default: for (int i = 0; i < entryCount; i++) { int entryOffset = sectionOffset - startOffset;