Skip to content

Conversation

@max-charlamb
Copy link
Member

@max-charlamb max-charlamb commented Jul 8, 2025

Using NativeReader instead of a raw byte[] will allow cDAC to utilize existing R2R parsing tools in this package. This change also adds some support for reading both LE/BE images. However this isn't fully implemented.

Modifies package to target netcore rather than netstandard.

@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jul 8, 2025
@max-charlamb max-charlamb marked this pull request as ready for review July 9, 2025 01:01
@max-charlamb max-charlamb requested review from Copilot, davidwrighton and jkoritzinsky and removed request for Copilot July 9, 2025 01:01
@max-charlamb max-charlamb added area-R2RDump-coreclr Ready-to-run image dump tool and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jul 9, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces raw byte[] access with a NativeReader stream-based reader across the ReadyToRun reflection and dumping tools, and updates project targets to use $(NetCoreAppMinimum) instead of netstandard2.0. Key changes include:

  • Introduction of NativeReader for all binary reads and replacement of static NativeReader.ReadX calls.
  • Initialization of ImageReader in ReadyToRunReader and propagation through all parsing classes.
  • Update of project files (.csproj and .pkgproj) to use $(NetCoreAppMinimum) target framework.

Reviewed Changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated no comments.

Show a summary per file
File Description
TextDumper.cs Swapped raw byte[] calls to ImageReader calls.
UnwindInfo.cs (x86, Arm, Arm64, Amd64, LoongArch64, RiscV64) Replaced constructor and read methods to use NativeReader.
ReadyToRunReader.cs Introduced ImageReader property and updated initializers.
ReadyToRunHeader.cs Updated header parsing to use NativeReader, but contains an incorrect copy/reset sequence.
NativeReader.cs Defined NativeReader class with instance methods, but class declaration syntax is invalid.
NativeHashtable.cs / NativeParser.cs / NativeArray.cs / NibbleReader.cs Converted all binary reads to instance-based NativeReader.
csproj & pkgproj Changed target frameworks from hardcoded netstandard2.0 to $(NetCoreAppMinimum).
Comments suppressed due to low confidence (2)

src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/NativeReader.cs:13

  • The class declaration syntax is invalid—constructor parameters belong on a constructor, not on the class itself. Change this line to public class NativeReader and add a matching constructor signature inside the class body: public NativeReader(Stream backingStream, bool littleEndian = true) { ... }.
    public class NativeReader(Stream backingStream, bool littleEndian = true)

src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunHeader.cs:135

  • This call resets curOffset and overwrites the signature buffer from an empty int array, discarding the bytes just read. Remove the curOffset = startOffset; and Array.Copy(...) lines—use the data populated by ReadSpanAt directly.
            Array.Copy(Array.Empty<int>(), curOffset, signature, 0, sizeof(uint) - 1);

@risc-vv
Copy link

risc-vv commented Jul 9, 2025

@dotnet/samsung Could you please take a look? These changes may be related to riscv64.

@risc-vv
Copy link

risc-vv commented Jul 9, 2025

bad6c75 is being scheduled for building and testing

GIT: bad6c7589369843e732ba874dde1a6b9879b8eea
REPO: dotnet/runtime
BRANCH: main

@risc-vv
Copy link

risc-vv commented Jul 9, 2025

RISC-V Release-CLR-QEMU: 9082 / 9112 (99.67%)
=======================
      passed: 9082
      failed: 2
     skipped: 597
      killed: 28
------------------------
 TOTAL tests: 9709
VIRTUAL time: 37h 20min 23s 520ms
   REAL time: 38min 11s 88ms
=======================

report.xml, report.md, failures.xml, testclr_details.tar.zst

Build information and commands

GIT: 0b54cd6897cfb852f43f76a3bebe10dd26ca0060
CI: d6c9c1ab3a7411819463edc05ded301e89ba586a
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

@risc-vv
Copy link

risc-vv commented Jul 9, 2025

0b54cd6 is being scheduled for building and testing

GIT: 0b54cd6897cfb852f43f76a3bebe10dd26ca0060
REPO: dotnet/runtime
BRANCH: main

@max-charlamb max-charlamb changed the title ILCompilter.Reflection.ReadyToRun encapsulate image state ILCompiler.Reflection.ReadyToRun encapsulate image state Jul 10, 2025
@max-charlamb max-charlamb merged commit 56ae94c into dotnet:main Jul 10, 2025
94 of 96 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Aug 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-R2RDump-coreclr Ready-to-run image dump tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants