[lld] r243373 - COFF: Add /LargeAddressAware command line option.

Rui Ueyama ruiu at google.com
Mon Jul 27 20:12:01 PDT 2015


Author: ruiu
Date: Mon Jul 27 22:12:00 2015
New Revision: 243373

URL: http://llvm.org/viewvc/llvm-project?rev=243373&view=rev
Log:
COFF: Add /LargeAddressAware command line option.

Added:
    lld/trunk/test/COFF/largeaddressaware.test
Modified:
    lld/trunk/COFF/Config.h
    lld/trunk/COFF/Driver.cpp
    lld/trunk/COFF/Writer.cpp

Modified: lld/trunk/COFF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Config.h?rev=243373&r1=243372&r2=243373&view=diff
==============================================================================
--- lld/trunk/COFF/Config.h (original)
+++ lld/trunk/COFF/Config.h Mon Jul 27 22:12:00 2015
@@ -118,6 +118,7 @@ struct Configuration {
   bool NxCompat = true;
   bool AllowIsolation = true;
   bool TerminalServerAware = true;
+  bool LargeAddressAware = false;
 };
 
 extern Configuration *Config;

Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=243373&r1=243372&r2=243373&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Mon Jul 27 22:12:00 2015
@@ -555,6 +555,10 @@ bool LinkerDriver::link(llvm::ArrayRef<c
     OwningMBs.push_back(std::move(MB)); // take ownership
   }
 
+  // Handle /largeaddressaware
+  if (Config->is64() || Args.hasArg(OPT_largeaddressaware))
+    Config->LargeAddressAware = true;
+
   // Handle /entry and /dll
   if (auto *Arg = Args.getLastArg(OPT_entry)) {
     Config->Entry = addUndefined(mangle(Arg->getValue()));

Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=243373&r1=243372&r2=243373&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Mon Jul 27 22:12:00 2015
@@ -435,11 +435,10 @@ template <typename PEHeaderTy> void Writ
   COFF->Machine = Config->Machine;
   COFF->NumberOfSections = OutputSections.size();
   COFF->Characteristics = IMAGE_FILE_EXECUTABLE_IMAGE;
-  if (Config->is64()) {
+  if (Config->LargeAddressAware)
     COFF->Characteristics |= IMAGE_FILE_LARGE_ADDRESS_AWARE;
-  } else {
+  if (!Config->is64())
     COFF->Characteristics |= IMAGE_FILE_32BIT_MACHINE;
-  }
   if (Config->DLL)
     COFF->Characteristics |= IMAGE_FILE_DLL;
   if (!Config->Relocatable)

Added: lld/trunk/test/COFF/largeaddressaware.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/largeaddressaware.test?rev=243373&view=auto
==============================================================================
--- lld/trunk/test/COFF/largeaddressaware.test (added)
+++ lld/trunk/test/COFF/largeaddressaware.test Mon Jul 27 22:12:00 2015
@@ -0,0 +1,21 @@
+# RUN: yaml2obj < %p/Inputs/hello32.yaml > %t.obj
+# RUN: lld -flavor link2 %t.obj %p/Inputs/std32.lib /subsystem:console \
+# RUN:   /entry:main at 0 /out:%t.exe /largeaddressaware
+# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=HEADER %s
+
+HEADER:      Format: COFF-i386
+HEADER-NEXT: Arch: i386
+HEADER-NEXT: AddressSize: 32bit
+HEADER-NEXT: ImageFileHeader {
+HEADER-NEXT:   Machine: IMAGE_FILE_MACHINE_I386 (0x14C)
+HEADER-NEXT:   SectionCount: 4
+HEADER-NEXT:   TimeDateStamp: 1970-01-01 00:00:00 (0x0)
+HEADER-NEXT:   PointerToSymbolTable: 0x0
+HEADER-NEXT:   SymbolCount: 0
+HEADER-NEXT:   OptionalHeaderSize: 224
+HEADER-NEXT:   Characteristics [ (0x122)
+HEADER-NEXT:     IMAGE_FILE_32BIT_MACHINE (0x100)
+HEADER-NEXT:     IMAGE_FILE_EXECUTABLE_IMAGE (0x2)
+HEADER-NEXT:     IMAGE_FILE_LARGE_ADDRESS_AWARE (0x20)
+HEADER-NEXT:   ]
+HEADER-NEXT: }





More information about the llvm-commits mailing list