summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2014-01-24 19:17:05 +0000
committerRui Ueyama <ruiu@google.com>2014-01-24 19:17:05 +0000
commit49bfd5032d9247c1cdf95b838d4cdc53a53a7bc7 (patch)
tree826027cfb99e7c4f85c404ae38e5ba18518be7d4
parent09b0f88a7fc96e994bc0db4f6b69019fad65409b (diff)
downloadbcm5719-llvm-49bfd5032d9247c1cdf95b838d4cdc53a53a7bc7.tar.gz
bcm5719-llvm-49bfd5032d9247c1cdf95b838d4cdc53a53a7bc7.zip
[PECOFF] Accept /machine:x64 option.
This is the first patch to support PE32+ format, which is the image format to use 64 bit address space on Windows/x86-64. llvm-svn: 200029
-rw-r--r--lld/include/lld/ReaderWriter/PECOFFLinkingContext.h4
-rw-r--r--lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp7
-rw-r--r--lld/unittests/DriverTests/WinLinkDriverTest.cpp11
3 files changed, 16 insertions, 6 deletions
diff --git a/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h b/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h
index fd2734343af..7c9879c38e6 100644
--- a/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h
+++ b/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h
@@ -79,6 +79,10 @@ public:
virtual bool
createImplicitFiles(std::vector<std::unique_ptr<File> > &result) const;
+ bool is64Bit() const {
+ return _machineType == llvm::COFF::IMAGE_FILE_MACHINE_AMD64;
+ }
+
void appendInputSearchPath(StringRef dirPath) {
_inputSearchPaths.push_back(dirPath);
}
diff --git a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
index d1db7cd7f97..9c929db6d3b 100644
--- a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
@@ -73,9 +73,10 @@ bool PECOFFLinkingContext::validateImpl(raw_ostream &diagnostics) {
return false;
}
- // Architectures other than i386 is not supported yet.
- if (_machineType != llvm::COFF::IMAGE_FILE_MACHINE_I386) {
- diagnostics << "Machine type other than x86 is not supported.\n";
+ // Architectures other than x86/x64 is not supported yet.
+ if (_machineType != llvm::COFF::IMAGE_FILE_MACHINE_I386 &&
+ _machineType != llvm::COFF::IMAGE_FILE_MACHINE_AMD64) {
+ diagnostics << "Machine type other than x86/x64 is not supported.\n";
return false;
}
diff --git a/lld/unittests/DriverTests/WinLinkDriverTest.cpp b/lld/unittests/DriverTests/WinLinkDriverTest.cpp
index 679c567badc..9b06a5aa5c7 100644
--- a/lld/unittests/DriverTests/WinLinkDriverTest.cpp
+++ b/lld/unittests/DriverTests/WinLinkDriverTest.cpp
@@ -217,9 +217,14 @@ TEST_F(WinLinkParserTest, MachineX86) {
}
TEST_F(WinLinkParserTest, MachineX64) {
- EXPECT_FALSE(parse("link.exe", "/machine:x64", "a.obj", nullptr));
- EXPECT_TRUE(StringRef(errorMessage())
- .startswith("Machine type other than x86 is not supported"));
+ EXPECT_TRUE(parse("link.exe", "/machine:x64", "a.obj", nullptr));
+ EXPECT_EQ(llvm::COFF::IMAGE_FILE_MACHINE_AMD64, _context.getMachineType());
+}
+
+TEST_F(WinLinkParserTest, MachineArm) {
+ EXPECT_FALSE(parse("link.exe", "/machine:arm", "a.obj", nullptr));
+ EXPECT_TRUE(StringRef(errorMessage()).startswith(
+ "Machine type other than x86/x64 is not supported"));
}
TEST_F(WinLinkParserTest, MajorImageVersion) {
OpenPOWER on IntegriCloud