[lld] r186428 - [WinLink] Add /LargeAddressAware command line option.
Rui Ueyama
ruiu at google.com
Tue Jul 16 10:20:38 PDT 2013
Author: ruiu
Date: Tue Jul 16 12:20:38 2013
New Revision: 186428
URL: http://llvm.org/viewvc/llvm-project?rev=186428&view=rev
Log:
[WinLink] Add /LargeAddressAware command line option.
Modified:
lld/trunk/include/lld/ReaderWriter/PECOFFTargetInfo.h
lld/trunk/lib/Driver/WinLinkDriver.cpp
lld/trunk/lib/Driver/WinLinkOptions.td
lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
Modified: lld/trunk/include/lld/ReaderWriter/PECOFFTargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFTargetInfo.h?rev=186428&r1=186427&r2=186428&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/PECOFFTargetInfo.h (original)
+++ lld/trunk/include/lld/ReaderWriter/PECOFFTargetInfo.h Tue Jul 16 12:20:38 2013
@@ -26,7 +26,7 @@ public:
: _stackReserve(1024 * 1024), _stackCommit(4096),
_heapReserve(1024 * 1024), _heapCommit(4096),
_subsystem(llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN), _minOSVersion(6, 0),
- _nxCompat(true) {}
+ _nxCompat(true), _largeAddressAware(false) {}
struct OSVersion {
OSVersion(int v1, int v2) : majorVersion(v1), minorVersion(v2) {}
@@ -62,6 +62,9 @@ public:
void setNxCompat(bool nxCompat) { _nxCompat = nxCompat; }
bool getNxCompat() const { return _nxCompat; }
+ void setLargeAddressAware(bool option) { _largeAddressAware = option; }
+ bool getLargeAddressAware() const { return _largeAddressAware; }
+
virtual ErrorOr<Reference::Kind> relocKindFromString(StringRef str) const;
virtual ErrorOr<std::string> stringFromRelocKind(Reference::Kind kind) const;
@@ -80,6 +83,7 @@ private:
llvm::COFF::WindowsSubsystem _subsystem;
OSVersion _minOSVersion;
bool _nxCompat;
+ bool _largeAddressAware;
mutable std::unique_ptr<Reader> _reader;
mutable std::unique_ptr<Writer> _writer;
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=186428&r1=186427&r2=186428&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Tue Jul 16 12:20:38 2013
@@ -262,6 +262,10 @@ bool WinLinkDriver::parse(int argc, cons
if (parsedArgs->getLastArg(OPT_no_nxcompat))
info.setNxCompat(false);
+ // Hanlde -largeaddressaware
+ if (parsedArgs->getLastArg(OPT_largeaddressaware))
+ info.setLargeAddressAware(true);
+
// Hanlde -out
if (llvm::opt::Arg *outpath = parsedArgs->getLastArg(OPT_out))
info.setOutputPath(outpath->getValue());
Modified: lld/trunk/lib/Driver/WinLinkOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkOptions.td?rev=186428&r1=186427&r2=186428&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkOptions.td (original)
+++ lld/trunk/lib/Driver/WinLinkOptions.td Tue Jul 16 12:20:38 2013
@@ -33,5 +33,10 @@ def nxcompat : Flag<["-", "/"], "nxcompa
def no_nxcompat : Flag<["-", "/"], "nxcompat:no">,
HelpText<"Disable data execution provention">;
+def largeaddressaware : Flag<["-", "/"], "largeaddressaware">,
+ HelpText<"Enable large addresses">;
+def no_largeaddressaware : Flag<["-", "/"], "largeaddressaware:no">,
+ HelpText<"Disable large addresses">;
+
def help : Flag<["-", "/"], "help">;
def help_q : Flag<["-", "/"], "?">, Alias<help>;
Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=186428&r1=186427&r2=186428&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Tue Jul 16 12:20:38 2013
@@ -151,8 +151,11 @@ public:
_coffHeader.SizeOfOptionalHeader = 224;
// Attributes of the executable.
- _coffHeader.Characteristics = llvm::COFF::IMAGE_FILE_32BIT_MACHINE |
- llvm::COFF::IMAGE_FILE_EXECUTABLE_IMAGE;
+ uint16_t characteristics = llvm::COFF::IMAGE_FILE_32BIT_MACHINE |
+ llvm::COFF::IMAGE_FILE_EXECUTABLE_IMAGE;
+ if (targetInfo.getLargeAddressAware())
+ characteristics |= llvm::COFF::IMAGE_FILE_LARGE_ADDRESS_AWARE;
+ _coffHeader.Characteristics = characteristics;
// 0x10b indicates a normal PE32 executable. For PE32+ it should be 0x20b.
_peHeader.Magic = 0x10b;
Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=186428&r1=186427&r2=186428&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Tue Jul 16 12:20:38 2013
@@ -48,6 +48,7 @@ TEST_F(WinLinkParserTest, Basic) {
EXPECT_EQ(4096, info->getStackCommit());
EXPECT_FALSE(info->allowRemainingUndefines());
EXPECT_TRUE(info->getNxCompat());
+ EXPECT_FALSE(info->getLargeAddressAware());
}
TEST_F(WinLinkParserTest, WindowsStyleOption) {
@@ -121,4 +122,14 @@ TEST_F(WinLinkParserTest, NoNxCompat) {
EXPECT_FALSE(info->getNxCompat());
}
+TEST_F(WinLinkParserTest, LargeAddressAware) {
+ parse("link.exe", "-largeaddressaware", nullptr);
+ EXPECT_TRUE(info->getLargeAddressAware());
+}
+
+TEST_F(WinLinkParserTest, NoLargeAddressAware) {
+ parse("link.exe", "-largeaddressaware:no", nullptr);
+ EXPECT_FALSE(info->getLargeAddressAware());
+}
+
} // end anonymous namespace
More information about the llvm-commits
mailing list