SPMI: Fix relocs into new RO data section#124383
Conversation
- Add arm64 handling similar to existing handling for relative relocs pointing into RO data section - Teach the relocation handling that on arm64 there are multiple RO data blocks (one at the end of code, one separate one for async functions)
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
This PR updates SuperPMI’s near-diff relocation normalization to better handle ARM64 relocations that reference a second RO-data block (not the constant pool appended to hot code), addressing spurious diffs seen for async-related data on linux-arm64.
Changes:
- Extend
RelocContextto track two RO-data ranges (primary + secondary) and thread that through near-diff relocation application. - Add ARM64-specific relocation handling intended to remap targets that land in the secondary RO-data block.
- Minor assignment reordering in
Compiler::impResolveToken.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/coreclr/tools/superpmi/superpmi/neardiffer.cpp | Tracks two RO-data regions on ARM64 and populates the expanded RelocContext accordingly. |
| src/coreclr/tools/superpmi/superpmi-shared/compileresult.h | Expands RelocContext with roDataSize1/2 and originalRoDataAddress1/2. |
| src/coreclr/tools/superpmi/superpmi-shared/compileresult.cpp | Adds ARM64 relocation remapping logic for targets that fall into the secondary RO-data range; updates uses to new context fields. |
| src/coreclr/jit/importer.cpp | Reorders token field assignments in impResolveToken. |
Comments suppressed due to low confidence (1)
src/coreclr/tools/superpmi/superpmi-shared/compileresult.cpp:890
- In the ARM64_PAGEBASE_REL21 relocation handling,
pageDeltais computed astargetPage - targetPage, which is always 0 and leavesfixupLocationPageunused. This should be computed relative to the fixup location page (e.g.,targetPage - fixupLocationPage) so ADRP immediates are patched correctly and reflect the recorded relocation target.
INT64 targetPage = (INT64)target & 0xFFFFFFFFFFFFF000LL;
INT64 fixupLocationPage = (INT64)fixupLocation & 0xFFFFFFFFFFFFF000LL;
INT64 pageDelta = (INT64)(targetPage - targetPage);
INT32 imm21 = (INT32)(pageDelta >> 12) & 0x1FFFFF;
PutArm64Rel21((UINT32*)address, imm21);
|
/azp run runtime-coreclr superpmi-diffs |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
PTAL @dotnet/jit-contrib. Fixes some spurious diffs. |
Fix #124371
This is quite hacky. I opened #124382 to clean this up in the future.