Skip to content

Commit 46b853a

Browse files
authored
[MC][COFF][AArch64] Treat ARM64EC/X as ARM64 for relocations (#86019)
Since ARM64EC/X objects use regular ARM64 relocations, any special handling must be done for them too.
1 parent e54af60 commit 46b853a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

llvm/lib/MC/WinCOFFObjectWriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ WinCOFFWriter::WinCOFFWriter(WinCOFFObjectWriter &OWriter,
266266
// limited range for the immediate offset (+/- 1 MB); create extra offset
267267
// label symbols with regular intervals to allow referencing a
268268
// non-temporary symbol that is close enough.
269-
UseOffsetLabels = Header.Machine == COFF::IMAGE_FILE_MACHINE_ARM64;
269+
UseOffsetLabels = COFF::isAnyArm64(Header.Machine);
270270
}
271271

272272
COFFSymbol *WinCOFFWriter::createSymbol(StringRef Name) {
@@ -954,7 +954,7 @@ void WinCOFFWriter::recordRelocation(MCAssembler &Asm,
954954
Reloc.Data.Type == COFF::IMAGE_REL_I386_REL32) ||
955955
(Header.Machine == COFF::IMAGE_FILE_MACHINE_ARMNT &&
956956
Reloc.Data.Type == COFF::IMAGE_REL_ARM_REL32) ||
957-
(Header.Machine == COFF::IMAGE_FILE_MACHINE_ARM64 &&
957+
(COFF::isAnyArm64(Header.Machine) &&
958958
Reloc.Data.Type == COFF::IMAGE_REL_ARM64_REL32))
959959
FixedValue += 4;
960960

llvm/test/MC/AArch64/coff-relocations.s

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// RUN: llvm-mc -triple aarch64-windows -filetype obj -o %t.obj %s
2-
// RUN: llvm-readobj -r %t.obj | FileCheck %s
2+
// RUN: llvm-mc -triple arm64ec-windows -filetype obj -o %t-ec.obj %s
3+
// RUN: llvm-readobj -r %t.obj | FileCheck %s --check-prefixes=CHECK,CHECK-ARM64
4+
// RUN: llvm-readobj -r %t-ec.obj | FileCheck %s --check-prefixes=CHECK,CHECK-ARM64EC
35
// RUN: llvm-objdump --no-print-imm-hex -d %t.obj | FileCheck %s --check-prefix=DISASM
6+
// RUN: llvm-objdump --no-print-imm-hex -d %t-ec.obj | FileCheck %s --check-prefix=DISASM
47
// RUN: llvm-objdump -s %t.obj | FileCheck %s --check-prefix=DATA
8+
// RUN: llvm-objdump -s %t-ec.obj | FileCheck %s --check-prefix=DATA
59

610
// IMAGE_REL_ARM64_ADDR32
711
.Linfo_foo:
@@ -71,8 +75,10 @@ tbz x0, #0, target
7175
// IMAGE_REL_ARM64_REL32 because IMAGE_REL_ARM64_REL64 does not exist.
7276
.xword .Linfo_foo - .Ltable
7377

74-
// CHECK: Format: COFF-ARM64
75-
// CHECK: Arch: aarch64
78+
// CHECK-ARM64: Format: COFF-ARM64
79+
// CHECK-ARM64EC: Format: COFF-ARM64EC
80+
// CHECK-ARM64: Arch: aarch64
81+
// CHECK-ARM64EC: Arch: aarch64
7682
// CHECK: AddressSize: 64bit
7783
// CHECK: Relocations [
7884
// CHECK: Section (1) .text {

0 commit comments

Comments
 (0)