[lld] r234632 - [Mips] Replace MipsTargetHandler member function getGP() by getGPAddr()
Simon Atanasyan
simon at atanasyan.com
Fri Apr 10 13:55:10 PDT 2015
Author: atanasyan
Date: Fri Apr 10 15:55:10 2015
New Revision: 234632
URL: http://llvm.org/viewvc/llvm-project?rev=234632&view=rev
Log:
[Mips] Replace MipsTargetHandler member function getGP() by getGPAddr()
When we call getGP() we need in fact _gp symbol address. Let's cache its
value and return it directly from the new getGPAddr() function.
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp?rev=234632&r1=234631&r2=234632&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp Fri Apr 10 15:55:10 2015
@@ -528,8 +528,7 @@ std::error_code RelocationHandler<ELFT>:
return std::error_code();
assert(ref.kindArch() == Reference::KindArch::Mips);
- AtomLayout *gpAtom = _targetLayout.getGP();
- uint64_t gpAddr = gpAtom ? gpAtom->_virtualAddr : 0;
+ uint64_t gpAddr = _targetLayout.getGPAddr();
AtomLayout *gpDispAtom = _targetLayout.getGPDisp();
bool isGpDisp = gpDispAtom && ref.target() == gpDispAtom->_atom;
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h?rev=234632&r1=234631&r2=234632&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h Fri Apr 10 15:55:10 2015
@@ -48,8 +48,7 @@ public:
}
void finalize() override {
- const AtomLayout *gpAtom = _targetLayout.getGP();
- _reginfo.ri_gp_value = gpAtom ? gpAtom->_virtualAddr : 0;;
+ _reginfo.ri_gp_value = _targetLayout.getGPAddr();
if (this->_outputSection)
this->_outputSection->setType(this->_type);
@@ -103,8 +102,7 @@ public:
}
void finalize() override {
- const AtomLayout *gpAtom = _targetLayout.getGP();
- _reginfo.ri_gp_value = gpAtom ? gpAtom->_virtualAddr : 0;;
+ _reginfo.ri_gp_value = _targetLayout.getGPAddr();
if (this->_outputSection)
this->_outputSection->setType(this->_type);
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h?rev=234632&r1=234631&r2=234632&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h Fri Apr 10 15:55:10 2015
@@ -47,11 +47,13 @@ public:
/// \brief GP offset relative to .got section.
uint64_t getGPOffset() const { return 0x7FF0; }
- /// \brief Get '_gp' symbol atom layout.
- AtomLayout *getGP() {
- std::call_once(_gpOnce,
- [this]() { _gpAtom = this->findAbsoluteAtom("_gp"); });
- return _gpAtom;
+ /// \brief Get '_gp' symbol address.
+ uint64_t getGPAddr() {
+ std::call_once(_gpOnce, [this]() {
+ if (AtomLayout *a = this->findAbsoluteAtom("_gp"))
+ _gpAddr = a->_virtualAddr;
+ });
+ return _gpAddr;
}
/// \brief Get '_gp_disp' symbol atom layout.
@@ -83,7 +85,7 @@ protected:
private:
MipsGOTSection<ELFT> *_gotSection;
MipsPLTSection<ELFT> *_pltSection;
- AtomLayout *_gpAtom = nullptr;
+ uint64_t _gpAddr = 0;
AtomLayout *_gpDispAtom = nullptr;
std::once_flag _gpOnce;
std::once_flag _gpDispOnce;
More information about the llvm-commits
mailing list