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
This commit is contained in:
Rui Ueyama 2015-04-10 19:55:35 +00:00
parent aa7a5a3a0f
commit ee0c60679a
1 changed files with 7 additions and 6 deletions

View File

@ -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