[lld] r197123 - [PECOFF] Parse /dll command line option.

Rui Ueyama ruiu at google.com
Wed Dec 11 19:21:46 PST 2013


Author: ruiu
Date: Wed Dec 11 21:21:45 2013
New Revision: 197123

URL: http://llvm.org/viewvc/llvm-project?rev=197123&view=rev
Log:
[PECOFF] Parse /dll command line option.

Modified:
    lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
    lld/trunk/lib/Driver/WinLinkDriver.cpp
    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=197123&r1=197122&r2=197123&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Wed Dec 11 21:21:45 2013
@@ -250,7 +250,7 @@ protected:
 
 private:
   // The start address for the program. The default value for the executable is
-  // 0x400000, but can be altered using -base command line option.
+  // 0x400000, but can be altered using /base command line option.
   uint64_t _baseAddress;
 
   uint64_t _stackReserve;

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=197123&r1=197122&r2=197123&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Wed Dec 11 21:21:45 2013
@@ -679,6 +679,14 @@ WinLinkDriver::parse(int argc, const cha
       ctx.setBaseAddress(addr);
       break;
 
+    case OPT_dll:
+      // Parse /dll command line option
+      ctx.setImageType(PECOFFLinkingContext::IMAGE_DLL);
+      // Default base address of a DLL is 0x10000000.
+      if (!parsedArgs->getLastArg(OPT_base))
+        ctx.setBaseAddress(0x10000000);
+      break;
+
     case OPT_stack: {
       // Parse /stack command line option
       uint64_t reserve;

Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=197123&r1=197122&r2=197123&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Wed Dec 11 21:21:45 2013
@@ -45,6 +45,7 @@ TEST_F(WinLinkParserTest, Basic) {
   EXPECT_TRUE(_context.getInputSearchPaths().empty());
 
   // Unspecified flags will have default values.
+  EXPECT_EQ(PECOFFLinkingContext::IMAGE_EXE, _context.getImageType());
   EXPECT_EQ(6, _context.getMinOSVersion().majorVersion);
   EXPECT_EQ(0, _context.getMinOSVersion().minorVersion);
   EXPECT_EQ(0x400000U, _context.getBaseAddress());
@@ -377,6 +378,8 @@ TEST_F(WinLinkParserTest, DisallowLib) {
 
 TEST_F(WinLinkParserTest, NoEntry) {
   EXPECT_TRUE(parse("link.exe", "/noentry", "/dll", "a.obj", nullptr));
+  EXPECT_EQ(PECOFFLinkingContext::IMAGE_DLL, _context.getImageType());
+  EXPECT_EQ(0x10000000U, _context.getBaseAddress());
   EXPECT_EQ("", _context.entrySymbolName());
 }
 





More information about the llvm-commits mailing list