diff options
author | Simon Atanasyan <simon@atanasyan.com> | 2014-05-25 09:05:06 +0000 |
---|---|---|
committer | Simon Atanasyan <simon@atanasyan.com> | 2014-05-25 09:05:06 +0000 |
commit | 6c68ffe3efcda9ac09248bef4de967110e39681a (patch) | |
tree | eb7e7d9307578e29fa0deb4e1646210efedbc218 | |
parent | 23fe15a62d75733433ae924ca4ba41dadaba81d5 (diff) | |
download | bcm5719-llvm-6c68ffe3efcda9ac09248bef4de967110e39681a.tar.gz bcm5719-llvm-6c68ffe3efcda9ac09248bef4de967110e39681a.zip |
[Mips] Factor out the code assign a value to the absolute atom into the
separate function.
llvm-svn: 209593
-rw-r--r-- | lld/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lld/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h b/lld/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h index 51734c97109..7c417d1c756 100644 --- a/lld/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h +++ b/lld/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h @@ -49,17 +49,9 @@ public: auto got = gotSection ? gotSection->virtualAddr() : 0; auto gp = gotSection ? got + _targetLayout.getGPOffset() : 0; - auto gotAtomIter = _targetLayout.findAbsoluteAtom("_GLOBAL_OFFSET_TABLE_"); - assert(gotAtomIter != _targetLayout.absoluteAtoms().end()); - (*gotAtomIter)->_virtualAddr = got; - - auto gpAtomIter = _targetLayout.findAbsoluteAtom("_gp"); - assert(gpAtomIter != _targetLayout.absoluteAtoms().end()); - (*gpAtomIter)->_virtualAddr = gp; - - AtomLayout *gpAtom = _targetLayout.getGP(); - assert(gpAtom != nullptr); - gpAtom->_virtualAddr = gp; + setAtomValue("_GLOBAL_OFFSET_TABLE_", got); + setAtomValue("_gp", gp); + setAtomValue("_gp_disp", gp); } bool hasGlobalGOTEntry(const Atom *a) const { @@ -79,6 +71,12 @@ public: private: MipsLinkingContext &_context; MipsTargetLayout<ELFT> &_targetLayout; + + void setAtomValue(StringRef name, uint64_t value) { + auto atom = _targetLayout.findAbsoluteAtom(name); + assert(atom != _targetLayout.absoluteAtoms().end()); + (*atom)->_virtualAddr = value; + } }; } // elf |