summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-04-10 19:55:35 +0000
committerRui Ueyama <ruiu@google.com>2015-04-10 19:55:35 +0000
commitee0c60679a18f2bb27e35516a68da37012823e49 (patch)
treef4bb9e8913eb79962c019cf9a22ec624a9be4909
parentaa7a5a3a0f7a6d4af7c772251b524098964d3c30 (diff)
downloadbcm5719-llvm-ee0c60679a18f2bb27e35516a68da37012823e49.tar.gz
bcm5719-llvm-ee0c60679a18f2bb27e35516a68da37012823e49.zip
Fix minor threading issue.
Because calls of applyRelocation is parallelized, all functions called from that need to be thread-safe. This piece of code didn't use any synchronization mechanism, so it was not safe. llvm-svn: 234628
-rw-r--r--lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
index c7ca4077f2a..93c918398f1 100644
--- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
+++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
@@ -82,17 +82,18 @@ public:
Section<ELFT> *getSDataSection() const { return _sdataSection; }
uint64_t getGOTSymAddr() {
- if (!_gotSymAtom.hasValue())
- _gotSymAtom = this->findAbsoluteAtom("_GLOBAL_OFFSET_TABLE_");
- if (*_gotSymAtom)
- return (*_gotSymAtom)->_virtualAddr;
- return 0;
+ std::call_once(_gotOnce, [this]() {
+ if (AtomLayout *got = this->findAbsoluteAtom("_GLOBAL_OFFSET_TABLE_"))
+ _gotAddr = got->_virtualAddr;
+ });
+ return _gotAddr;
}
private:
llvm::BumpPtrAllocator _alloc;
SDataSection<ELFT> *_sdataSection = nullptr;
- llvm::Optional<AtomLayout *> _gotSymAtom;
+ uint64_t _gotAddr = 0;
+ std::once_flag _gotOnce;
};
/// \brief TargetHandler for Hexagon
OpenPOWER on IntegriCloud