Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert pointer relocs are aligned #113069

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MichalStrehovsky
Copy link
Member

No description provided.

@Copilot Copilot bot review requested due to automatic review settings March 3, 2025 11:06

Choose a reason for hiding this comment

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

PR Overview

This pull request introduces debug assertions to ensure pointer relocations are properly aligned during object emission.

  • Adds a DEBUG-only block to iterate over relocations and check for pointer relocation alignment
  • Verifies the node content's alignment against the target pointer size

Reviewed Changes

File Description
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs Introduces debug assertions ensuring pointer relocs and node alignment are verified

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

Comment on lines +457 to +462
if ((reloc.RelocType is RelocType.IMAGE_REL_BASED_DIR64 && _nodeFactory.Target.PointerSize == 8) ||
(reloc.RelocType is RelocType.IMAGE_REL_BASED_HIGHLOW && _nodeFactory.Target.PointerSize == 4))
{
hasPointerRelocs = true;
Debug.Assert(reloc.Offset % _nodeFactory.Target.PointerSize == 0);
}
Copy link
Contributor

@SingleAccretion SingleAccretion Mar 3, 2025

Choose a reason for hiding this comment

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

The stack trace metadata node uses unaligned pointer relocs. Everything else is (AFAIK) aligned.

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

Successfully merging this pull request may close these issues.

3 participants