[lld] r228379 - [Cleanup] Remove member functions added to support nostdlib

Shankar Easwaran shankare at codeaurora.org
Thu Feb 5 21:01:38 PST 2015


Author: shankare
Date: Thu Feb  5 23:01:38 2015
New Revision: 228379

URL: http://llvm.org/viewvc/llvm-project?rev=228379&view=rev
Log:
[Cleanup] Remove member functions added to support nostdlib

No change in functionality.

Modified:
    lld/trunk/include/lld/Driver/Driver.h
    lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h
    lld/trunk/lib/Driver/GnuLdDriver.cpp
    lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
    lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp

Modified: lld/trunk/include/lld/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/Driver.h?rev=228379&r1=228378&r2=228379&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/Driver.h (original)
+++ lld/trunk/include/lld/Driver/Driver.h Thu Feb  5 23:01:38 2015
@@ -80,7 +80,7 @@ public:
   /// Public function for testing.
   static std::error_code evalLinkerScript(ELFLinkingContext &ctx,
                                           std::unique_ptr<MemoryBuffer> mb,
-                                          raw_ostream &diag);
+                                          raw_ostream &diag, bool nostdlib);
 
   /// A factory method to create an instance of ELFLinkingContext.
   static std::unique_ptr<ELFLinkingContext>

Modified: lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=228379&r1=228378&r2=228379&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h Thu Feb  5 23:01:38 2015
@@ -303,10 +303,6 @@ public:
     _scripts.push_back(std::move(script));
   }
 
-  /// \brief nostdlib support.
-  bool nostdlib() const { return _nostdlib; }
-  void setNoStdLib(bool nostdlib) { _nostdlib = nostdlib; }
-
 private:
   ELFLinkingContext() LLVM_DELETED_FUNCTION;
 

Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=228379&r1=228378&r2=228379&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Thu Feb  5 23:01:38 2015
@@ -265,10 +265,10 @@ addFilesFromLinkerScript(ELFLinkingConte
   return std::error_code();
 }
 
-std::error_code
-GnuLdDriver::evalLinkerScript(ELFLinkingContext &ctx,
-                              std::unique_ptr<MemoryBuffer> mb,
-                              raw_ostream &diag) {
+std::error_code GnuLdDriver::evalLinkerScript(ELFLinkingContext &ctx,
+                                              std::unique_ptr<MemoryBuffer> mb,
+                                              raw_ostream &diag,
+                                              bool nostdlib) {
   // Read the script file from disk and parse.
   StringRef path = mb->getBufferIdentifier();
   auto parser = llvm::make_unique<script::Parser>(std::move(mb));
@@ -293,7 +293,7 @@ GnuLdDriver::evalLinkerScript(ELFLinking
       ctx.getNodes().push_back(llvm::make_unique<GroupEnd>(groupSize));
     }
     if (auto *searchDir = dyn_cast<script::SearchDir>(c))
-      if (!ctx.nostdlib())
+      if (!nostdlib)
         ctx.addSearchPath(searchDir->getSearchPath());
     if (auto *entry = dyn_cast<script::Entry>(c))
       ctx.setEntrySymbolName(entry->getEntryName());
@@ -406,9 +406,6 @@ bool GnuLdDriver::parse(int argc, const
   if (!(hasNoStdLib = parsedArgs->hasArg(OPT_nostdlib)))
     ctx->addDefaultSearchDirs(baseTriple);
 
-  // -nostdlib support.
-  ctx->setNoStdLib(hasNoStdLib);
-
   // Handle --demangle option(For compatibility)
   if (parsedArgs->getLastArg(OPT_demangle))
     ctx->setDemangleSymbols(true);
@@ -638,7 +635,8 @@ bool GnuLdDriver::parse(int argc, const
           diag << "Cannot open " << path << ": " << ec.message() << "\n";
           return false;
         }
-        std::error_code ec = evalLinkerScript(*ctx, std::move(mb.get()), diag);
+        std::error_code ec =
+            evalLinkerScript(*ctx, std::move(mb.get()), diag, hasNoStdLib);
         if (ec) {
           diag << path << ": Error parsing linker script: "
                << ec.message() << "\n";

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=228379&r1=228378&r2=228379&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp Thu Feb  5 23:01:38 2015
@@ -61,8 +61,8 @@ ELFLinkingContext::ELFLinkingContext(
       _mergeCommonStrings(false), _useShlibUndefines(true),
       _dynamicLinkerArg(false), _noAllowDynamicLibraries(false),
       _mergeRODataToTextSegment(true), _demangle(true), _alignSegments(true),
-      _nostdlib(false), _outputMagic(OutputMagic::DEFAULT),
-      _initFunction("_init"), _finiFunction("_fini"), _sysrootPath("") {}
+      _outputMagic(OutputMagic::DEFAULT), _initFunction("_init"),
+      _finiFunction("_fini"), _sysrootPath("") {}
 
 void ELFLinkingContext::addPasses(PassManager &pm) {
   pm.add(std::unique_ptr<Pass>(new elf::OrderPass()));

Modified: lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp?rev=228379&r1=228378&r2=228379&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp Thu Feb  5 23:01:38 2015
@@ -34,13 +34,13 @@ protected:
     _ctx = std::move(GnuLdDriver::createELFLinkingContext(triple));
   }
 
-  void parse(StringRef script) {
+  void parse(StringRef script, bool nostdlib = false) {
     std::unique_ptr<MemoryBuffer> mb = MemoryBuffer::getMemBuffer(
       script, "foo.so");
     std::string s;
     raw_string_ostream out(s);
-    std::error_code ec = GnuLdDriver::evalLinkerScript(
-      *_ctx, std::move(mb), out);
+    std::error_code ec =
+        GnuLdDriver::evalLinkerScript(*_ctx, std::move(mb), out, nostdlib);
     EXPECT_FALSE(ec);
   };
 
@@ -220,8 +220,7 @@ TEST_F(LinkerScriptTest, Output) {
 
 // Test that search paths are ignored when nostdlib is set.
 TEST_F(LinkerScriptTest, IgnoreSearchDirNoStdLib) {
-  _ctx->setNoStdLib(true);
-  parse("SEARCH_DIR(\"/foo/bar\")");
+  parse("SEARCH_DIR(\"/foo/bar\")", true /*nostdlib*/);
   std::vector<StringRef> paths = _ctx->getSearchPaths();
   EXPECT_EQ((size_t)0, paths.size());
 }





More information about the llvm-commits mailing list