Skip to content

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

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

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions llvm/lib/MC/WinCOFFObjectWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand Down
12 changes: 9 additions & 3 deletions llvm/test/MC/AArch64/coff-relocations.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// RUN: llvm-mc -triple aarch64-windows -filetype obj -o %t.obj %s
// RUN: llvm-readobj -r %t.obj | FileCheck %s
// RUN: llvm-mc -triple arm64ec-windows -filetype obj -o %t-ec.obj %s
// RUN: llvm-readobj -r %t.obj | FileCheck %s --check-prefixes=CHECK,CHECK-ARM64
// RUN: llvm-readobj -r %t-ec.obj | FileCheck %s --check-prefixes=CHECK,CHECK-ARM64EC
// RUN: llvm-objdump --no-print-imm-hex -d %t.obj | FileCheck %s --check-prefix=DISASM
// RUN: llvm-objdump --no-print-imm-hex -d %t-ec.obj | FileCheck %s --check-prefix=DISASM
// RUN: llvm-objdump -s %t.obj | FileCheck %s --check-prefix=DATA
// RUN: llvm-objdump -s %t-ec.obj | FileCheck %s --check-prefix=DATA

// IMAGE_REL_ARM64_ADDR32
.Linfo_foo:
Expand Down Expand Up @@ -71,8 +75,10 @@ tbz x0, #0, target
// IMAGE_REL_ARM64_REL32 because IMAGE_REL_ARM64_REL64 does not exist.
.xword .Linfo_foo - .Ltable

// CHECK: Format: COFF-ARM64
// CHECK: Arch: aarch64
// CHECK-ARM64: Format: COFF-ARM64
// CHECK-ARM64EC: Format: COFF-ARM64EC
// CHECK-ARM64: Arch: aarch64
// CHECK-ARM64EC: Arch: aarch64
// CHECK: AddressSize: 64bit
// CHECK: Relocations [
// CHECK: Section (1) .text {
Expand Down