[lld] r306963 - [COFF] Add initial support for linking ARM64 binaries
Martin Storsjo via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 1 13:29:27 PDT 2017
Author: mstorsjo
Date: Sat Jul 1 13:29:27 2017
New Revision: 306963
URL: http://llvm.org/viewvc/llvm-project?rev=306963&view=rev
Log:
[COFF] Add initial support for linking ARM64 binaries
A plain empty entry point function that returns 0 seems to produce
a binary that loads and runs fine in wine.
Differential Revision: https://reviews.llvm.org/D34833
Added:
lld/trunk/test/COFF/arm64-magic.yaml
Modified:
lld/trunk/COFF/Config.h
lld/trunk/COFF/DriverUtils.cpp
lld/trunk/COFF/InputFiles.cpp
Modified: lld/trunk/COFF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Config.h?rev=306963&r1=306962&r2=306963&view=diff
==============================================================================
--- lld/trunk/COFF/Config.h (original)
+++ lld/trunk/COFF/Config.h Sat Jul 1 13:29:27 2017
@@ -31,6 +31,7 @@ class SymbolBody;
// 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 ARMNT = llvm::COFF::IMAGE_FILE_MACHINE_ARMNT;
static const auto I386 = llvm::COFF::IMAGE_FILE_MACHINE_I386;
@@ -73,7 +74,7 @@ enum class DebugType {
// Global configuration.
struct Configuration {
enum ManifestKind { SideBySide, Embed, No };
- bool is64() { return Machine == AMD64; }
+ bool is64() { return Machine == AMD64 || Machine == ARM64; }
llvm::COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN;
bool Verbose = false;
Modified: lld/trunk/COFF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DriverUtils.cpp?rev=306963&r1=306962&r2=306963&view=diff
==============================================================================
--- lld/trunk/COFF/DriverUtils.cpp (original)
+++ lld/trunk/COFF/DriverUtils.cpp Sat Jul 1 13:29:27 2017
@@ -85,6 +85,7 @@ MachineTypes getMachineType(StringRef S)
.Cases("x64", "amd64", AMD64)
.Cases("x86", "i386", I386)
.Case("arm", ARMNT)
+ .Case("arm64", ARM64)
.Default(IMAGE_FILE_MACHINE_UNKNOWN);
if (MT != IMAGE_FILE_MACHINE_UNKNOWN)
return MT;
@@ -95,6 +96,8 @@ StringRef machineToStr(MachineTypes MT)
switch (MT) {
case ARMNT:
return "arm";
+ case ARM64:
+ return "arm64";
case AMD64:
return "x64";
case I386:
Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=306963&r1=306962&r2=306963&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Sat Jul 1 13:29:27 2017
@@ -380,6 +380,8 @@ MachineTypes BitcodeFile::getMachineType
return I386;
case Triple::arm:
return ARMNT;
+ case Triple::aarch64:
+ return ARM64;
default:
return IMAGE_FILE_MACHINE_UNKNOWN;
}
Added: lld/trunk/test/COFF/arm64-magic.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/arm64-magic.yaml?rev=306963&view=auto
==============================================================================
--- lld/trunk/test/COFF/arm64-magic.yaml (added)
+++ lld/trunk/test/COFF/arm64-magic.yaml Sat Jul 1 13:29:27 2017
@@ -0,0 +1,46 @@
+# RUN: yaml2obj < %s > %t.obj
+# RUN: lld-link /out:%t.exe /entry:mainCRTStartup /subsystem:console %t.obj
+# RUN: llvm-readobj -file-headers %t.exe | FileCheck %s
+
+# CHECK: Format: COFF-ARM64
+# CHECK: Arch: aarch64
+# CHECK: AddressSize: 64bit
+# CHECK: ImageFileHeader {
+# CHECK: Machine: IMAGE_FILE_MACHINE_ARM64 (0xAA64)
+# CHECK: Characteristics [ (0x22)
+# CHECK: IMAGE_FILE_EXECUTABLE_IMAGE (0x2)
+# CHECK: IMAGE_FILE_LARGE_ADDRESS_AWARE (0x20)
+# CHECK: ]
+# CHECK: }
+# CHECK: ImageOptionalHeader {
+# CHECK: Magic: 0x20B
+
+--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_ARM64
+ Characteristics: []
+sections:
+ - Name: .text
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_PURGEABLE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ Alignment: 4
+ SectionData: 'e0031f2ac0035fd6'
+symbols:
+ - Name: .text
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 8
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 1
+ - Name: mainCRTStartup
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+...
More information about the llvm-commits
mailing list