Support for larger version bubbles in R2RDump (dotnet/coreclr#24277)
authorTomáš Rylek <trylek@microsoft.com>
Tue, 30 Apr 2019 21:16:46 +0000 (23:16 +0200)
committerGitHub <noreply@github.com>
Tue, 30 Apr 2019 21:16:46 +0000 (23:16 +0200)
commitf2744c685b3be4f29c39c4660a988a30c9350fd3
tree8e3990044432745c47d094423eedc19e61bc92e6
parent7caa22a78cfbab6e65a40c44cd9c0b96c5ea283b
Support for larger version bubbles in R2RDump (dotnet/coreclr#24277)

After JanV fixed basically all test failures related to larger
version bubbles originally implemented by Andon, it's high time
to fix R2RDump for its support as a prerequisite to enabling
larger version bubbles in CPAOT. This change implements this
support via the following particular changes:

1) In DumpOptions, I added a list of explicit assembly references,
another list of reference paths that are used for resolving
assembly references, a cache for repeated assembly lookups and
a new method FindAssembly for file resolution of a given simple
assembly name.

2) I have moved ECMA metadata-related logic from R2RReader to
its new base class EcmaMetadataReader. This class can represent
both R2R and MSIL binaries and adds the logic for reference
assembly lookup.

3) Large version bubble R2R PE exe's contain a special R2R header
table READYTORUN_SECTION_MANIFEST_METADATA that contains ECMA
metadata with a list of extra AssemblyRef's on top of those stored
in the original MSIL. I have added support for parsing this table
to the R2RReader constructor.

4) I have modified R2RSignature to be based off the new
EcmaMetadataReader instead of R2RReader which cannot represent
arbitrary reference assemblies. I have patched the two places
dealing with module overrides to use the new logic to temporarily
switch to a "remote module" SignatureDecoder for the purpose
of parsing an external entity.

5) I have removed temporary hacks Andon put in place to keep
R2RDump alive in some cases with larger version bubbles without
proper support for parsing module overrides.

6) I have added logic for dumping the contents of the manifest
metadata along with the standard AssemblyRef table to the
header dump as I fought with recalculation of the indices
when debugging larger version bubble code for quite some time.

7) As an extra half-forgotten bit from the past I added dumping
of unboxing and instantiation stubs.

I have noticed that the MSIL AssemblyRef count was off by one.
I have also found out that XML output has bitrotten over time.
This additional delta fixes both issues. [That forced me to
add a bunch of empty ctors even though in practice we don't
actually serialize anything into the dumper, we only use
the XML serializer to emit the XML output file.

Thanks

Tomas

Commit migrated from https://github.com/dotnet/coreclr/commit/fc05a4297c903c1456762d89913d79e1780b55b1
src/coreclr/src/tools/r2rdump/GCRefMap.cs
src/coreclr/src/tools/r2rdump/R2RDump.cs
src/coreclr/src/tools/r2rdump/R2RImportSection.cs
src/coreclr/src/tools/r2rdump/R2RReader.cs
src/coreclr/src/tools/r2rdump/R2RSection.cs
src/coreclr/src/tools/r2rdump/R2RSignature.cs
src/coreclr/src/tools/r2rdump/TextDumper.cs
src/coreclr/src/tools/r2rdump/XmlDumper.cs