diff options
| author | Rui Ueyama <ruiu@google.com> | 2014-05-20 23:05:09 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2014-05-20 23:05:09 +0000 |
| commit | 9b0a69d6dc741d960d739f4e660a820a868fb2b0 (patch) | |
| tree | 9f42bd04012f9ccabe91572f78640c261785cb28 | |
| parent | 1b985af0ba97dcc51adfd384611a329c8d86954b (diff) | |
| download | bcm5719-llvm-9b0a69d6dc741d960d739f4e660a820a868fb2b0.tar.gz bcm5719-llvm-9b0a69d6dc741d960d739f4e660a820a868fb2b0.zip | |
[PECOFF] Acquire mutex before accessing shared objects.
addResolvableSymbols() queues input files, and readAllSymbols() reads
from them. In practice it's currently safe because they are called from
a single thread. But it's not guaranteed.
Also, acquiring the same mutex is needed not to see inconsistent memory
contents that is allowed in the C++ memory model.
llvm-svn: 209254
| -rw-r--r-- | lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h b/lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h index 29faa3950c5..68b696ee822 100644 --- a/lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h +++ b/lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h @@ -219,6 +219,7 @@ private: // Files are read lazily, so that it has no runtime overhead if // there's no dllexported stdcall functions. void readAllSymbols() const { + std::lock_guard<std::mutex> lock(_mutex); for (File *file : _queue) { if (auto *archive = dyn_cast<ArchiveLibraryFile>(file)) { for (const std::string &sym : archive->getDefinedSymbols()) |

