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

[MC][COFF][AArch64] Treat ARM64EC/X as ARM64 for relocations #86019

Merged
merged 1 commit into from
Mar 22, 2024

Conversation

bylaws
Copy link
Contributor

@bylaws bylaws commented Mar 20, 2024

Since ARM64EC/X objects use regular ARM64 relocations, any special handling must be done for them too.

@llvmbot llvmbot added the mc Machine (object) code label Mar 20, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 20, 2024

@llvm/pr-subscribers-backend-aarch64

@llvm/pr-subscribers-mc

Author: Billy Laws (bylaws)

Changes

Since ARM64EC/X objects use regular ARM64 relocations, any special handling must be done for them too.


Full diff: https://github.com/llvm/llvm-project/pull/86019.diff

1 Files Affected:

  • (modified) llvm/lib/MC/WinCOFFObjectWriter.cpp (+2-2)
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp
index f265fafa59e744..3c9ff71b6b0622 100644
--- a/llvm/lib/MC/WinCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp
@@ -266,7 +266,7 @@ WinCOFFWriter::WinCOFFWriter(WinCOFFObjectWriter &OWriter,
   // limited range for the immediate offset (+/- 1 MB); create extra offset
   // label symbols with regular intervals to allow referencing a
   // non-temporary symbol that is close enough.
-  UseOffsetLabels = Header.Machine == COFF::IMAGE_FILE_MACHINE_ARM64;
+  UseOffsetLabels = COFF::isAnyArm64(Header.Machine);
 }
 
 COFFSymbol *WinCOFFWriter::createSymbol(StringRef Name) {
@@ -954,7 +954,7 @@ void WinCOFFWriter::recordRelocation(MCAssembler &Asm,
        Reloc.Data.Type == COFF::IMAGE_REL_I386_REL32) ||
       (Header.Machine == COFF::IMAGE_FILE_MACHINE_ARMNT &&
        Reloc.Data.Type == COFF::IMAGE_REL_ARM_REL32) ||
-      (Header.Machine == COFF::IMAGE_FILE_MACHINE_ARM64 &&
+      (COFF::isAnyArm64(Header.Machine) &&
        Reloc.Data.Type == COFF::IMAGE_REL_ARM64_REL32))
     FixedValue += 4;
 

@mstorsjo
Copy link
Member

Can you add a testcase?

Since ARM64EC/X objects use regular ARM64 relocations, any special
handling must be done for them too.
@bylaws
Copy link
Contributor Author

bylaws commented Mar 21, 2024

Can you add a testcase?

done, the existing arm64 reloc tests already test this

Copy link
Collaborator

@efriedma-quic efriedma-quic left a comment

Choose a reason for hiding this comment

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

LGTM

@cjacek cjacek merged commit 46b853a into llvm:main Mar 22, 2024
5 checks passed
chencha3 pushed a commit to chencha3/llvm-project that referenced this pull request Mar 23, 2024
)

Since ARM64EC/X objects use regular ARM64 relocations, any special
handling must be done for them too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AArch64 mc Machine (object) code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants