[lld] r190725 - Revert "[PECOFF] Allocate storage for .drective in the reader ..."

Rui Ueyama ruiu at google.com
Fri Sep 13 14:14:18 PDT 2013


Author: ruiu
Date: Fri Sep 13 16:14:18 2013
New Revision: 190725

URL: http://llvm.org/viewvc/llvm-project?rev=190725&view=rev
Log:
Revert "[PECOFF] Allocate storage for .drective in the reader ..."

This reverts r189881 because that patch caused dangling StringRefs.

Modified:
    lld/trunk/lib/Driver/WinLinkDriver.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=190725&r1=190724&r2=190725&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Fri Sep 13 16:14:18 2013
@@ -364,12 +364,12 @@ bool WinLinkDriver::parse(int argc, cons
 
     case OPT_entry:
       // handle /entry
-      ctx.setEntrySymbolName(inputArg->getValue());
+      ctx.setEntrySymbolName(ctx.allocateString(inputArg->getValue()));
       break;
 
     case OPT_libpath:
       // handle /libpath
-      ctx.appendInputSearchPath(inputArg->getValue());
+      ctx.appendInputSearchPath(ctx.allocateString(inputArg->getValue()));
       break;
 
     case OPT_force:
@@ -424,12 +424,12 @@ bool WinLinkDriver::parse(int argc, cons
 
     case OPT_incl:
       // handle /incl
-      ctx.addInitialUndefinedSymbol(inputArg->getValue());
+      ctx.addInitialUndefinedSymbol(ctx.allocateString(inputArg->getValue()));
       break;
 
     case OPT_out:
       // handle /out
-      ctx.setOutputPath(inputArg->getValue());
+      ctx.setOutputPath(ctx.allocateString(inputArg->getValue()));
       break;
 
     case OPT_INPUT:

Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=190725&r1=190724&r2=190725&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Fri Sep 13 16:14:18 2013
@@ -126,7 +126,7 @@ private:
   SectionToAtomsT;
 
 public:
-  FileCOFF(const PECOFFLinkingContext &context,
+  FileCOFF(const LinkingContext &context,
            std::unique_ptr<llvm::MemoryBuffer> mb, error_code &ec)
       : File(mb->getBufferIdentifier(), kindObject), _context(context) {
     llvm::OwningPtr<llvm::object::Binary> bin;
@@ -666,7 +666,7 @@ private:
       ArrayRef<uint8_t> contents;
       if (error_code ec = _obj->getSectionContents(section, contents))
         return ec;
-      _directives = _context.allocateString(ArrayRefToString(contents));
+      _directives = std::move(ArrayRefToString(contents));
     }
     return error_code::success();
   }
@@ -678,7 +678,7 @@ private:
   atom_collection_vector<AbsoluteAtom> _absoluteAtoms;
 
   // The contents of .drectve section.
-  StringRef _directives;
+  std::string _directives;
 
   // A map from symbol to its name. All symbols should be in this map except
   // unnamed ones.
@@ -703,7 +703,7 @@ private:
   _definedAtomLocations;
 
   mutable llvm::BumpPtrAllocator _alloc;
-  const PECOFFLinkingContext &_context;
+  const LinkingContext &_context;
 };
 
 class BumpPtrStringSaver : public llvm::cl::StringSaver {
@@ -781,8 +781,7 @@ private:
                            std::vector<std::unique_ptr<File> > &result) const {
     // Parse the memory buffer as PECOFF file.
     error_code ec;
-    std::unique_ptr<FileCOFF> file(
-        new FileCOFF(_PECOFFLinkingContext, std::move(mb), ec));
+    std::unique_ptr<FileCOFF> file(new FileCOFF(_context, std::move(mb), ec));
     if (ec)
       return ec;
 





More information about the llvm-commits mailing list