diff options
author | Rui Ueyama <ruiu@google.com> | 2014-08-05 01:44:43 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2014-08-05 01:44:43 +0000 |
commit | 83095b5e8f69ccf4e521eabf3f3505eab734e24b (patch) | |
tree | 5e59889c382ca367d9b366d83b1ade6868daba9b | |
parent | 28d65da6181d94660d52f9bcf59f6ebf5d21ca33 (diff) | |
download | bcm5719-llvm-83095b5e8f69ccf4e521eabf3f3505eab734e24b.tar.gz bcm5719-llvm-83095b5e8f69ccf4e521eabf3f3505eab734e24b.zip |
[PECOFF] addDeadStripRoot is not thread-safe.
llvm-svn: 214835
-rw-r--r-- | lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp b/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp index 84d3f5fc2ef..1836a099ec6 100644 --- a/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp +++ b/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp @@ -979,21 +979,27 @@ public: return llvm::object::object_error::parse_failed; } - // In order to emit SEH table, all input files need to be compatible with - // SEH. Disable SEH if the file being read is not compatible. - if (!file->isCompatibleWithSEH()) - _ctx.setSafeSEH(false); + // Add /INCLUDE'ed symbols to the file as if they existed in the + // file as undefined symbols. + for (StringRef sym : undefinedSymbols) + file->addUndefinedSymbol(sym); // One can define alias symbols using /alternatename:<sym>=<sym> option. // The mapping for /alternatename is in the context object. This helper // function iterate over defined atoms and create alias atoms if needed. createAlternateNameAtoms(*file); - for (StringRef sym : undefinedSymbols) { - file->addUndefinedSymbol(sym); - if (_ctx.deadStrip()) + // Acquire the mutex to mutate _ctx. + std::lock_guard<std::recursive_mutex> lock(_ctx.getMutex()); + + // In order to emit SEH table, all input files need to be compatible with + // SEH. Disable SEH if the file being read is not compatible. + if (!file->isCompatibleWithSEH()) + _ctx.setSafeSEH(false); + + if (_ctx.deadStrip()) + for (StringRef sym : undefinedSymbols) _ctx.addDeadStripRoot(sym); - } result.push_back(std::move(file)); return std::error_code(); |