[lld] r194757 - [PECOFF] Add /stub option.

Rui Ueyama ruiu at google.com
Thu Nov 14 16:18:41 PST 2013


Author: ruiu
Date: Thu Nov 14 18:18:41 2013
New Revision: 194757

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

Modified:
    lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
    lld/trunk/lib/Driver/WinLinkDriver.cpp
    lld/trunk/lib/Driver/WinLinkOptions.td

Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=194757&r1=194756&r2=194757&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Thu Nov 14 18:18:41 2013
@@ -230,9 +230,8 @@ public:
     return it == _sectionAttributeMask.end() ? 0 : it->second;
   }
 
-  const std::vector<uint8_t> &getDosStub() const {
-    return _dosStub;
-  }
+  void setDosStub(std::vector<uint8_t> &data) { _dosStub = std::move(data); }
+  const std::vector<uint8_t> &getDosStub() const { return _dosStub; }
 
   StringRef allocateString(StringRef ref) const {
     char *x = _allocator.Allocate<char>(ref.size() + 1);

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=194757&r1=194756&r2=194757&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Thu Nov 14 18:18:41 2013
@@ -203,6 +203,14 @@ bool parseSection(StringRef option, std:
   return true;
 }
 
+bool readFile(StringRef path, std::vector<uint8_t> &result) {
+  OwningPtr<MemoryBuffer> buf;
+  if (MemoryBuffer::getFile(path, buf))
+    return false;
+  result = std::vector<uint8_t>(buf->getBufferStart(), buf->getBufferEnd());
+  return true;
+}
+
 // Parse /manifest:EMBED[,ID=#]|NO.
 bool parseManifest(StringRef option, bool &enable, bool &embed, int &id) {
   if (option.equals_lower("no")) {
@@ -828,6 +836,17 @@ WinLinkDriver::parse(int argc, const cha
       ctx.setSwapRunFromNet(true);
       break;
 
+    case OPT_stub: {
+      std::vector<uint8_t> contents;
+      if (!readFile(inputArg->getValue(), contents)) {
+        diagnostics << "Failed to read DOS stub file "
+                    << inputArg->getValue() << "\n";
+        return false;
+      }
+      ctx.setDosStub(contents);
+      break;
+    }
+
     case OPT_incl:
       ctx.addInitialUndefinedSymbol(ctx.allocateString(inputArg->getValue()));
       break;

Modified: lld/trunk/lib/Driver/WinLinkOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkOptions.td?rev=194757&r1=194756&r2=194757&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkOptions.td (original)
+++ lld/trunk/lib/Driver/WinLinkOptions.td Thu Nov 14 18:18:41 2013
@@ -33,6 +33,7 @@ def version : P<"version", "Specify a ve
 def merge   : P<"merge", "Combine sections">;
 def section : P<"section", "Specify section attributes">;
 def subsystem : P<"subsystem", "Specify subsystem">;
+def stub    : P<"stub", "Specify DOS stub file">;
 
 def manifest : F<"manifest">;
 def manifest_colon : P<"manifest", "Create manifest file">;





More information about the llvm-commits mailing list