[PATCH] D149086: [lld] Use correct machine type in ARM64EC COFF headers.
Jacek Caban via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 29 10:49:34 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG482ee33a637d: [lld] Use correct machine type in ARM64EC COFF headers. (authored by jacek).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149086/new/
https://reviews.llvm.org/D149086
Files:
lld/COFF/Chunks.cpp
lld/COFF/Config.h
lld/COFF/Writer.cpp
lld/test/COFF/arm64ec.test
Index: lld/test/COFF/arm64ec.test
===================================================================
--- /dev/null
+++ lld/test/COFF/arm64ec.test
@@ -0,0 +1,23 @@
+REQUIRES: aarch64
+RUN: split-file %s %t.dir && cd %t.dir
+
+RUN: llvm-mc -filetype=obj -triple=arm64ec-windows arm64ec-data-sym.s -o arm64ec-data-sym.obj
+RUN: llvm-cvtres -machine:arm64x -out:arm64x-resource.obj %S/Inputs/resource.res
+
+RUN: lld-link -out:test.dll -machine:arm64ec arm64ec-data-sym.obj -dll -noentry
+RUN: llvm-readobj --file-headers test.dll | FileCheck -check-prefix=ARM64EC-HEADER %s
+ARM64EC-HEADER: Format: COFF-x86-64
+ARM64EC-HEADER-NEXT: Arch: x86_64
+ARM64EC-HEADER-NEXT: AddressSize: 64bit
+ARM64EC-HEADER: Machine: IMAGE_FILE_MACHINE_AMD64 (0x8664)
+
+RUN: lld-link -out:test.dll -machine:arm64x arm64x-resource.obj -dll -noentry
+RUN: llvm-readobj --file-headers test.dll | FileCheck -check-prefix=ARM64X-HEADER %s
+ARM64X-HEADER: Machine: IMAGE_FILE_MACHINE_ARM64 (0xAA64)
+
+#--- arm64ec-data-sym.s
+ .data
+ .globl arm64ec_data_sym
+ .p2align 2, 0x0
+arm64ec_data_sym:
+ .word 0x02020202
Index: lld/COFF/Writer.cpp
===================================================================
--- lld/COFF/Writer.cpp
+++ lld/COFF/Writer.cpp
@@ -1436,7 +1436,16 @@
// Write COFF header
auto *coff = reinterpret_cast<coff_file_header *>(buf);
buf += sizeof(*coff);
- coff->Machine = config->machine;
+ switch (config->machine) {
+ case ARM64EC:
+ coff->Machine = AMD64;
+ break;
+ case ARM64X:
+ coff->Machine = ARM64;
+ break;
+ default:
+ coff->Machine = config->machine;
+ }
coff->NumberOfSections = ctx.outputSections.size();
coff->Characteristics = IMAGE_FILE_EXECUTABLE_IMAGE;
if (config->largeAddressAware)
Index: lld/COFF/Config.h
===================================================================
--- lld/COFF/Config.h
+++ lld/COFF/Config.h
@@ -37,6 +37,8 @@
// Short aliases.
static const auto AMD64 = llvm::COFF::IMAGE_FILE_MACHINE_AMD64;
static const auto ARM64 = llvm::COFF::IMAGE_FILE_MACHINE_ARM64;
+static const auto ARM64EC = llvm::COFF::IMAGE_FILE_MACHINE_ARM64EC;
+static const auto ARM64X = llvm::COFF::IMAGE_FILE_MACHINE_ARM64X;
static const auto ARMNT = llvm::COFF::IMAGE_FILE_MACHINE_ARMNT;
static const auto I386 = llvm::COFF::IMAGE_FILE_MACHINE_I386;
@@ -96,7 +98,9 @@
// Global configuration.
struct Configuration {
enum ManifestKind { Default, SideBySide, Embed, No };
- bool is64() const { return machine == AMD64 || machine == ARM64; }
+ bool is64() const {
+ return machine == AMD64 || llvm::COFF::isAnyArm64(machine);
+ }
llvm::COFF::MachineTypes machine = IMAGE_FILE_MACHINE_UNKNOWN;
size_t wordsize;
Index: lld/COFF/Chunks.cpp
===================================================================
--- lld/COFF/Chunks.cpp
+++ lld/COFF/Chunks.cpp
@@ -447,6 +447,8 @@
applyRelARM(off, rel.Type, os, s, p, imageBase);
break;
case ARM64:
+ case ARM64EC:
+ case ARM64X:
applyRelARM64(off, rel.Type, os, s, p, imageBase);
break;
default:
@@ -532,6 +534,8 @@
return IMAGE_REL_BASED_ARM_MOV32T;
return IMAGE_REL_BASED_ABSOLUTE;
case ARM64:
+ case ARM64EC:
+ case ARM64X:
if (rel.Type == IMAGE_REL_ARM64_ADDR64)
return IMAGE_REL_BASED_DIR64;
return IMAGE_REL_BASED_ABSOLUTE;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149086.526458.patch
Type: text/x-patch
Size: 3339 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230529/820e2acd/attachment.bin>
More information about the llvm-commits
mailing list