[lld] r242885 - [ELF] Protect write access to the ELFLinkingContext::_cidentSections by a mutex

Simon Atanasyan simon at atanasyan.com
Wed Jul 22 03:32:19 PDT 2015


Author: atanasyan
Date: Wed Jul 22 05:32:19 2015
New Revision: 242885

URL: http://llvm.org/viewvc/llvm-project?rev=242885&view=rev
Log:
[ELF] Protect write access to the ELFLinkingContext::_cidentSections by a mutex

The _cidentSections container is filled during files parsing so we need to
serialize a concurrent access to it.

Modified:
    lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h
    lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp

Modified: lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=242885&r1=242884&r2=242885&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h Wed Jul 22 05:32:19 2015
@@ -408,6 +408,7 @@ protected:
   std::map<std::string, uint64_t> _absoluteSymbols;
   llvm::StringSet<> _dynamicallyExportedSymbols;
   std::unique_ptr<File> _resolver;
+  std::mutex _cidentMutex;
   llvm::StringSet<> _cidentSections;
 
   // The linker script semantic object, which owns all script ASTs, is stored

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=242885&r1=242884&r2=242885&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp Wed Jul 22 05:32:19 2015
@@ -254,8 +254,10 @@ void ELFLinkingContext::notifyInputSecti
   if (name.find_first_not_of("0123456789"
                              "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                              "abcdefghijklmnopqrstuvwxyz"
-                             "_") == StringRef::npos)
+                             "_") == StringRef::npos) {
+    std::lock_guard<std::mutex> lock(_cidentMutex);
     _cidentSections.insert(name);
+  }
 }
 
 } // end namespace lld





More information about the llvm-commits mailing list