[lld] r191224 - [PECOFF] Add /allowbind command line option.

Rui Ueyama ruiu at google.com
Mon Sep 23 13:44:21 PDT 2013


Author: ruiu
Date: Mon Sep 23 15:44:20 2013
New Revision: 191224

URL: http://llvm.org/viewvc/llvm-project?rev=191224&view=rev
Log:
[PECOFF] Add /allowbind command line option.

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/unittests/DriverTests/WinLinkDriverTest.cpp

Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=191224&r1=191223&r2=191224&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Mon Sep 23 15:44:20 2013
@@ -33,8 +33,9 @@ public:
         _subsystem(llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN),
         _machineType(llvm::COFF::IMAGE_FILE_MACHINE_I386), _imageVersion(0, 0),
         _minOSVersion(6, 0), _nxCompat(true), _largeAddressAware(false),
-        _baseRelocationEnabled(true), _terminalServerAware(true),
-        _dynamicBaseEnabled(true), _imageType(ImageType::IMAGE_EXE) {
+        _allowBind(true), _baseRelocationEnabled(true),
+        _terminalServerAware(true), _dynamicBaseEnabled(true),
+        _imageType(ImageType::IMAGE_EXE) {
     setDeadStripping(true);
   }
 
@@ -123,6 +124,9 @@ public:
   void setLargeAddressAware(bool val) { _largeAddressAware = val; }
   bool getLargeAddressAware() const { return _largeAddressAware; }
 
+  void setAllowBind(bool val) { _allowBind = val; }
+  bool getAllowBind() const { return _allowBind; }
+
   void setBaseRelocationEnabled(bool val) { _baseRelocationEnabled = val; }
   bool getBaseRelocationEnabled() const { return _baseRelocationEnabled; }
 
@@ -174,6 +178,7 @@ private:
   Version _minOSVersion;
   bool _nxCompat;
   bool _largeAddressAware;
+  bool _allowBind;
   bool _baseRelocationEnabled;
   bool _terminalServerAware;
   bool _dynamicBaseEnabled;

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=191224&r1=191223&r2=191224&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Mon Sep 23 15:44:20 2013
@@ -419,6 +419,16 @@ bool WinLinkDriver::parse(int argc, cons
       ctx.setLargeAddressAware(true);
       break;
 
+    case OPT_allowbind:
+      // handle /allowbind
+      ctx.setAllowBind(true);
+      break;
+
+    case OPT_allowbind_no:
+      // handle /allowbind:no
+      ctx.setAllowBind(false);
+      break;
+
     case OPT_fixed:
       // handle /fixed
 

Modified: lld/trunk/lib/Driver/WinLinkOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkOptions.td?rev=191224&r1=191223&r2=191224&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkOptions.td (original)
+++ lld/trunk/lib/Driver/WinLinkOptions.td Mon Sep 23 15:44:20 2013
@@ -49,6 +49,7 @@ def no_ref : F<"opt:noref">,
 
 defm nxcompat : B<"nxcompat", "Disable data execution provention">;
 defm largeaddressaware : B<"largeaddressaware", "Disable large addresses">;
+defm allowbind: B<"allowbind", "Disable DLL binding">;
 defm fixed    : B<"fixed", "Enable base relocations">;
 defm tsaware  : B<"tsaware", "Create non-Terminal Server aware executable">;
 defm dynamicbase : B<"dynamicbase",

Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=191224&r1=191223&r2=191224&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Mon Sep 23 15:44:20 2013
@@ -210,6 +210,8 @@ public:
       dllCharacteristics |= llvm::COFF::IMAGE_DLL_CHARACTERISTICS_NX_COMPAT;
     if (context.getDynamicBaseEnabled())
       dllCharacteristics |= llvm::COFF::IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE;
+    if (!context.getAllowBind())
+      dllCharacteristics |= llvm::COFF::IMAGE_DLL_CHARACTERISTICS_NO_BIND;
     _peHeader.DLLCharacteristics = dllCharacteristics;
 
     _peHeader.SizeOfStackReserve = context.getStackReserve();

Modified: lld/trunk/test/pecoff/options.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/options.test?rev=191224&r1=191223&r2=191224&view=diff
==============================================================================
--- lld/trunk/test/pecoff/options.test (original)
+++ lld/trunk/test/pecoff/options.test Mon Sep 23 15:44:20 2013
@@ -2,6 +2,11 @@
 #
 # RUN: yaml2obj %p/Inputs/nop.obj.yaml > %t.obj
 
-# RUN: lld -flavor link /out:%t.exe /align:8192 /entry:start -- %t.obj \
+# RUN: lld -flavor link /align:8192 /out:%t.exe /entry:start -- %t.obj \
 # RUN:   && llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=ALIGN %s
 ALIGN: SectionAlignment: 8192
+
+# RUN: lld -flavor link /allowbind:no /out:%t.exe /entry:start -- %t.obj \
+# RUN:   && llvm-readobj -file-headers %t.exe \
+# RUN:   | FileCheck -check-prefix=ALLOWBIND %s
+ALLOWBIND: IMAGE_DLL_CHARACTERISTICS_NO_BIND

Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=191224&r1=191223&r2=191224&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Mon Sep 23 15:44:20 2013
@@ -53,6 +53,7 @@ TEST_F(WinLinkParserTest, Basic) {
   EXPECT_FALSE(_context.allowRemainingUndefines());
   EXPECT_TRUE(_context.isNxCompat());
   EXPECT_FALSE(_context.getLargeAddressAware());
+  EXPECT_TRUE(_context.getAllowBind());
   EXPECT_TRUE(_context.getBaseRelocationEnabled());
   EXPECT_TRUE(_context.isTerminalServerAware());
   EXPECT_TRUE(_context.getDynamicBaseEnabled());
@@ -206,6 +207,16 @@ TEST_F(WinLinkParserTest, NoLargeAddress
   EXPECT_FALSE(_context.getLargeAddressAware());
 }
 
+TEST_F(WinLinkParserTest, AllowBind) {
+  EXPECT_FALSE(parse("link.exe", "/allowbind", "a.obj", nullptr));
+  EXPECT_TRUE(_context.getAllowBind());
+}
+
+TEST_F(WinLinkParserTest, NoAllowBind) {
+  EXPECT_FALSE(parse("link.exe", "/allowbind:no", "a.obj", nullptr));
+  EXPECT_FALSE(_context.getAllowBind());
+}
+
 TEST_F(WinLinkParserTest, Fixed) {
   EXPECT_FALSE(parse("link.exe", "/fixed", "a.out", nullptr));
   EXPECT_FALSE(_context.getBaseRelocationEnabled());





More information about the llvm-commits mailing list