[lld] r216414 - [PECOFF] Add /HighEntropyVA.

Rui Ueyama ruiu at google.com
Mon Aug 25 15:23:34 PDT 2014


Author: ruiu
Date: Mon Aug 25 17:23:34 2014
New Revision: 216414

URL: http://llvm.org/viewvc/llvm-project?rev=216414&view=rev
Log:
[PECOFF] Add /HighEntropyVA.

This is yet another command line flag to set a bit in
DLLCharacteristics. Default on Win64 is "on".

Modified:
    lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
    lld/trunk/lib/Driver/WinLinkDriver.cpp
    lld/trunk/lib/Driver/WinLinkOptions.td
    lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
    lld/trunk/test/pecoff/options.test
    lld/trunk/test/pecoff/pe32plus.test

Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=216414&r1=216413&r2=216414&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Mon Aug 25 17:23:34 2014
@@ -36,10 +36,10 @@ class Group;
 class PECOFFLinkingContext : public LinkingContext {
 public:
   PECOFFLinkingContext()
-      : _mutex(), _allocMutex(), _hasEntry(true), _baseAddress(invalidBaseAddress),
-        _stackReserve(1024 * 1024), _stackCommit(4096),
-        _heapReserve(1024 * 1024), _heapCommit(4096), _noDefaultLibAll(false),
-        _sectionDefaultAlignment(4096),
+      : _mutex(), _allocMutex(), _hasEntry(true),
+        _baseAddress(invalidBaseAddress), _stackReserve(1024 * 1024),
+        _stackCommit(4096), _heapReserve(1024 * 1024), _heapCommit(4096),
+        _noDefaultLibAll(false), _sectionDefaultAlignment(4096),
         _subsystem(llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN),
         _machineType(llvm::COFF::IMAGE_FILE_MACHINE_I386), _imageVersion(0, 0),
         _minOSVersion(6, 0), _nxCompat(true), _largeAddressAware(false),
@@ -48,8 +48,8 @@ public:
         _terminalServerAware(true), _dynamicBaseEnabled(true),
         _createManifest(true), _embedManifest(false), _manifestId(1),
         _manifestUAC(true), _manifestLevel("'asInvoker'"),
-        _manifestUiAccess("'false'"), _isDll(false), _requireSEH(false),
-        _noSEH(false), _implib(""),
+        _manifestUiAccess("'false'"), _isDll(false), _highEntropyVA(true),
+        _requireSEH(false), _noSEH(false), _implib(""),
         _dosStub(llvm::makeArrayRef(DEFAULT_DOS_STUB)) {
     setDeadStripping(true);
   }
@@ -218,6 +218,9 @@ public:
   bool requireSEH() const { return _requireSEH; }
   bool noSEH() const { return _noSEH; }
 
+  void setHighEntropyVA(bool val) { _highEntropyVA = val; }
+  bool getHighEntropyVA() const { return _highEntropyVA; }
+
   void setOutputImportLibraryPath(const std::string &val) { _implib = val; }
   std::string getOutputImportLibraryPath() const;
 
@@ -346,6 +349,7 @@ private:
   std::string _manifestUiAccess;
   std::string _manifestDependency;
   bool _isDll;
+  bool _highEntropyVA;
 
   // True if /SAFESEH option is specified. Valid only for x86. If true, LLD will
   // produce an image with SEH table. If any modules were not compatible with

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=216414&r1=216413&r2=216414&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Mon Aug 25 17:23:34 2014
@@ -1227,6 +1227,7 @@ bool WinLinkDriver::parse(int argc, cons
     DEFINE_BOOLEAN_FLAG(allowisolation, setAllowIsolation);
     DEFINE_BOOLEAN_FLAG(dynamicbase, setDynamicBaseEnabled);
     DEFINE_BOOLEAN_FLAG(tsaware, setTerminalServerAware);
+    DEFINE_BOOLEAN_FLAG(highentropyva, setHighEntropyVA);
     DEFINE_BOOLEAN_FLAG(safeseh, setSafeSEH);
 
 #undef DEFINE_BOOLEAN_FLAG

Modified: lld/trunk/lib/Driver/WinLinkOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkOptions.td?rev=216414&r1=216413&r2=216414&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkOptions.td (original)
+++ lld/trunk/lib/Driver/WinLinkOptions.td Mon Aug 25 17:23:34 2014
@@ -78,6 +78,7 @@ defm allowisolation : B<"allowisolation"
 defm dynamicbase : B<"dynamicbase",
      "Disable address space layout randomization">;
 defm safeseh : B<"safeseh", "Produce an image with Safe Exception Handler">;
+defm highentropyva : B<"highentropyva", "Set HIGH_ENTROPY_VA bit">;
 
 def help : F<"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=216414&r1=216413&r2=216414&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Mon Aug 25 17:23:34 2014
@@ -406,6 +406,8 @@ PEHeaderChunk<PEHeader>::PEHeaderChunk(c
     dllCharacteristics |= llvm::COFF::IMAGE_DLL_CHARACTERISTICS_NO_BIND;
   if (!ctx.getAllowIsolation())
     dllCharacteristics |= llvm::COFF::IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION;
+  if (ctx.getHighEntropyVA() && ctx.is64Bit())
+    dllCharacteristics |= llvm::COFF::IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA;
   _peHeader.DLLCharacteristics = dllCharacteristics;
 
   _peHeader.SizeOfStackReserve = ctx.getStackReserve();

Modified: lld/trunk/test/pecoff/options.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/options.test?rev=216414&r1=216413&r2=216414&view=diff
==============================================================================
--- lld/trunk/test/pecoff/options.test (original)
+++ lld/trunk/test/pecoff/options.test Mon Aug 25 17:23:34 2014
@@ -26,3 +26,13 @@ RUNCD: IMAGE_FILE_REMOVABLE_RUN_FROM_SWA
 # RUN:   /subsystem:console -- %t.obj
 # RUN: llvm-readobj -file-headers %t5.exe | FileCheck -check-prefix=RUNNET %s
 RUNNET: IMAGE_FILE_NET_RUN_FROM_SWAP
+
+# RUN: lld -flavor link /machine:x64 /force /highentropyva /out:%t6.exe \
+# RUN:   /entry:start /subsystem:console -- %t.obj
+# RUN: llvm-readobj -file-headers %t6.exe | FileCheck -check-prefix=ENT %s
+ENT: IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA
+
+# RUN: lld -flavor link /machine:x64 /force /highentropyva:no /out:%t7.exe \
+# RUN:   /entry:start /subsystem:console -- %t.obj
+# RUN: llvm-readobj -file-headers %t7.exe | FileCheck -check-prefix=NOENT %s
+NOENT-NOT: IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA

Modified: lld/trunk/test/pecoff/pe32plus.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/pe32plus.test?rev=216414&r1=216413&r2=216414&view=diff
==============================================================================
--- lld/trunk/test/pecoff/pe32plus.test (original)
+++ lld/trunk/test/pecoff/pe32plus.test Mon Aug 25 17:23:34 2014
@@ -39,8 +39,9 @@ CHECK-NEXT:   MinorSubsystemVersion: 0
 CHECK-NEXT:   SizeOfImage: 24576
 CHECK-NEXT:   SizeOfHeaders: 1024
 CHECK-NEXT:   Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI (0x3)
-CHECK-NEXT:   Subsystem [ (0x8140)
+CHECK-NEXT:   Subsystem [ (0x8160)
 CHECK-NEXT:     IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE (0x40)
+CHECK-NEXT:     IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA (0x20)
 CHECK-NEXT:     IMAGE_DLL_CHARACTERISTICS_NX_COMPAT (0x100)
 CHECK-NEXT:     IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE (0x8000)
 CHECK-NEXT:   ]





More information about the llvm-commits mailing list