Skip to content

Conversation

@jakobbotsch
Copy link
Member

@jakobbotsch jakobbotsch commented Jan 21, 2026

ELF/MachO do not support relocations from read-only sections into the .text section. We generate such relocations when creating async resumption info. Now that #123378 is in we can teach ilc/crossgen2 to place these pieces of data in a read-write section when necessary.

Fix #121871

@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jan 21, 2026
Copilot AI review requested due to automatic review settings January 28, 2026 17:22
@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @MichalStrehovsky (NAOT parts) @EgorBo (JIT parts)

@jakobbotsch
Copy link
Member Author

/azp run runtime-nativeaot-outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jakobbotsch jakobbotsch requested a review from EgorBo January 28, 2026 17:27
Comment on lines +1239 to 1251
if ((dataChunks[i].flags & CORJIT_ALLOCMEM_HAS_POINTERS_TO_CODE) != 0)
{
// These are always passed to the EE as separate chunks since their relocations need special treatment
dataChunks[i].block = chunks.BottomRef(curDataChunk).block;
dataChunks[i].blockRW = chunks.BottomRef(curDataChunk).blockRW;
curDataChunk++;
}
else
{
dataChunks[i].block = codeChunk.block + (size_t)dataChunks[i].block;
dataChunks[i].blockRW = codeChunk.blockRW + (size_t)dataChunks[i].blockRW;
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

BTW: it seems questionable whether we need this "put into .text" behavior at all. And if we do (due to distance constraints), then presumably we could hit problems for async resumption info too.

If we end up with the optimization to fold common read only data then we will probably want to disable this so that it also kicks in for arm64.

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 fixes issue #121871 by placing async resumption data structures containing relocations to code sections into read-write memory sections on ELF/MachO platforms (non-Windows). The PE file format used on Windows supports relocations from read-only sections to code sections, but ELF and MachO do not, causing linking errors. The fix introduces a new MethodReadWriteDataNode class and teaches both the JIT and AOT compilers to route data with the CORJIT_ALLOCMEM_HAS_POINTERS_TO_CODE flag to read-write sections when targeting non-Windows platforms.

Changes:

  • Introduces MethodReadWriteDataNode to hold data with relocations to code in read-write sections
  • Modifies JIT and AOT memory allocation logic to conditionally place async resumption info in RW sections on ELF/MachO
  • Removes platform-specific test restrictions that were workarounds for this issue
  • Reverts temporary workaround in MethodReadOnlyDataNode that placed all data in RW sections on non-Windows

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/tests/nativeaot/SmokeTests/UnitTests/UnitTests.csproj Removes x64-only condition for runtime-async feature, enabling it for all architectures
src/tests/async/Directory.Build.targets Removes arm64 nativeaot build exclusion workaround
src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj Adds MethodReadWriteDataNode to ReadyToRun compiler project
src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj Adds MethodReadWriteDataNode to AOT compiler project
src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs Adds RW data handling parallel to existing RO data handling, routes chunks with pointers to code based on platform
src/coreclr/tools/Common/Compiler/DependencyAnalysis/MethodReadWriteDataNode.cs New node class for read-write method data, mirrors MethodReadOnlyDataNode structure
src/coreclr/tools/Common/Compiler/DependencyAnalysis/MethodReadOnlyDataNode.cs Reverts workaround that placed all data in RW sections on non-Windows platforms
src/coreclr/jit/ee_il_dll.cpp Modifies JIT allocation to pass chunks with CORJIT_ALLOCMEM_HAS_POINTERS_TO_CODE as separate chunks on ARM64/LoongArch64/RISCV64

@jakobbotsch
Copy link
Member Author

/azp run runtime-nativeaot-outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codegen-emitted data blobs with relocs need to go to a RW blob

1 participant