diff options
author | Simon Atanasyan <simon@atanasyan.com> | 2015-05-31 20:37:22 +0000 |
---|---|---|
committer | Simon Atanasyan <simon@atanasyan.com> | 2015-05-31 20:37:22 +0000 |
commit | faa8bfdd1aa8bbaa02bd6e2adb8324180539af58 (patch) | |
tree | 5d5118f44d407950313ef11f2ce271714423ed66 /lld/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp | |
parent | 2944e4a43d7c8cc403d01b7f6c33e11c8481bd3a (diff) | |
download | bcm5719-llvm-faa8bfdd1aa8bbaa02bd6e2adb8324180539af58.tar.gz bcm5719-llvm-faa8bfdd1aa8bbaa02bd6e2adb8324180539af58.zip |
[Mips] Add a couple of MipsAbiInfoHandler functions to check linked code type
No functional changes.
llvm-svn: 238689
Diffstat (limited to 'lld/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp')
-rw-r--r-- | lld/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp index 0b54a8922cf..31dc15f3ba5 100644 --- a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp +++ b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp @@ -311,12 +311,6 @@ private: /// \brief Owner of all the Atoms created by this pass. RelocationPassFile _file; - /// \brief Linked files contain MIPS R6 code. - bool _isMipsR6 = false; - - /// \brief Linked files contain microMIPS code. - bool _isMicroMips = false; - /// \brief Map Atoms and addend to local GOT entries. typedef std::pair<const Atom *, int64_t> LocalGotMapKeyT; llvm::DenseMap<LocalGotMapKeyT, GOTAtom *> _gotLocalMap; @@ -418,6 +412,11 @@ private: bool mightBeDynamic(const MipsELFDefinedAtom<ELFT> &atom, Reference::KindValue refKind) const; bool hasPLTEntry(const Atom *atom) const; + + /// \brief Linked files contain microMIPS code. + bool isMicroMips(); + /// \brief Linked files contain MIPS R6 code. + bool isMipsR6(); }; template <typename ELFT> @@ -430,14 +429,6 @@ RelocationPass<ELFT>::RelocationPass(MipsLinkingContext &ctx) template <typename ELFT> void RelocationPass<ELFT>::perform(std::unique_ptr<SimpleFile> &mf) { - auto &handler = - static_cast<MipsTargetHandler<ELFT> &>(this->_ctx.getTargetHandler()); - - uint32_t elfFlags = handler.getAbiInfoHandler().getFlags(); - _isMicroMips = elfFlags & EF_MIPS_MICROMIPS; - _isMipsR6 = (elfFlags & EF_MIPS_ARCH) == EF_MIPS_ARCH_32R6 || - (elfFlags & EF_MIPS_ARCH) == EF_MIPS_ARCH_64R6; - for (const auto &atom : mf->defined()) for (const auto &ref : *atom) collectReferenceInfo(*cast<MipsELFDefinedAtom<ELFT>>(atom), @@ -709,6 +700,20 @@ bool RelocationPass<ELFT>::hasPLTEntry(const Atom *atom) const { return _pltRegMap.count(atom) || _pltMicroMap.count(atom); } +template <typename ELFT> bool RelocationPass<ELFT>::isMicroMips() { + TargetHandler &handler = this->_ctx.getTargetHandler(); + return static_cast<MipsTargetHandler<ELFT> &>(handler) + .getAbiInfoHandler() + .isMicroMips(); +} + +template <typename ELFT> bool RelocationPass<ELFT>::isMipsR6() { + TargetHandler &handler = this->_ctx.getTargetHandler(); + return static_cast<MipsTargetHandler<ELFT> &>(handler) + .getAbiInfoHandler() + .isMipsR6(); +} + template <typename ELFT> bool RelocationPass<ELFT>::requirePLTEntry(const Atom *a) const { if (!_hasStaticRelocations.count(a)) @@ -761,7 +766,7 @@ const LA25Atom *RelocationPass<ELFT>::getLA25Entry(const Atom *target, template <typename ELFT> const PLTAtom *RelocationPass<ELFT>::getPLTEntry(const Atom *a) { // If file contains microMIPS code try to reuse compressed PLT entry... - if (_isMicroMips) { + if (isMicroMips()) { auto microPLT = _pltMicroMap.find(a); if (microPLT != _pltMicroMap.end()) return microPLT->second; @@ -773,7 +778,7 @@ const PLTAtom *RelocationPass<ELFT>::getPLTEntry(const Atom *a) { return regPLT->second; // ... and finally prefer to create new compressed PLT entry. - return _isMicroMips ? getPLTMicroEntry(a) : getPLTRegEntry(a); + return isMicroMips() ? getPLTMicroEntry(a) : getPLTRegEntry(a); } template <typename ELFT> @@ -1010,7 +1015,7 @@ const PLTAtom *RelocationPass<ELFT>::getPLTRegEntry(const Atom *a) { if (plt != _pltRegMap.end()) return plt->second; - PLTAAtom *pa = _isMipsR6 + PLTAAtom *pa = isMipsR6() ? new (_file._alloc) PLTR6Atom(getGOTPLTEntry(a), _file) : new (_file._alloc) PLTAAtom(getGOTPLTEntry(a), _file); _pltRegMap[a] = pa; |