[lld] r234863 - ELF: Move function definitions from .h to .cpp.
Rui Ueyama
ruiu at google.com
Mon Apr 13 23:47:06 PDT 2015
Author: ruiu
Date: Tue Apr 14 01:47:06 2015
New Revision: 234863
URL: http://llvm.org/viewvc/llvm-project?rev=234863&view=rev
Log:
ELF: Move function definitions from .h to .cpp.
Modified:
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.h
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp?rev=234863&r1=234862&r2=234863&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp Tue Apr 14 01:47:06 2015
@@ -10,11 +10,11 @@
#include "HexagonLinkingContext.h"
#include "HexagonTargetHandler.h"
-using namespace lld;
-using namespace lld::elf;
+namespace lld {
+namespace elf {
std::unique_ptr<lld::ELFLinkingContext>
-elf::createHexagonLinkingContext(llvm::Triple triple) {
+createHexagonLinkingContext(llvm::Triple triple) {
if (triple.getArch() == llvm::Triple::hexagon)
return llvm::make_unique<HexagonLinkingContext>(triple);
return nullptr;
@@ -35,3 +35,13 @@ void HexagonLinkingContext::registerRelo
registry.addKindTable(Reference::KindNamespace::ELF,
Reference::KindArch::Hexagon, kindStrings);
}
+
+void setHexagonELFHeader(ELFHeader<ELF32LE> &elfHeader) {
+ elfHeader.e_ident(llvm::ELF::EI_VERSION, 1);
+ elfHeader.e_ident(llvm::ELF::EI_OSABI, 0);
+ elfHeader.e_version(1);
+ elfHeader.e_flags(0x3);
+}
+
+} // namespace elf
+} // namespace lld
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.h?rev=234863&r1=234862&r2=234863&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.h Tue Apr 14 01:47:06 2015
@@ -63,12 +63,7 @@ public:
}
};
-inline void setHexagonELFHeader(ELFHeader<ELF32LE> &elfHeader) {
- elfHeader.e_ident(llvm::ELF::EI_VERSION, 1);
- elfHeader.e_ident(llvm::ELF::EI_OSABI, 0);
- elfHeader.e_version(1);
- elfHeader.e_flags(0x3);
-}
+void setHexagonELFHeader(ELFHeader<ELF32LE> &elfHeader);
} // elf
} // lld
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp?rev=234863&r1=234862&r2=234863&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp Tue Apr 14 01:47:06 2015
@@ -12,12 +12,13 @@
#include "HexagonLinkingContext.h"
#include "HexagonTargetHandler.h"
-using namespace lld;
-using namespace elf;
using namespace llvm::ELF;
using llvm::makeArrayRef;
+namespace lld {
+namespace elf {
+
HexagonTargetHandler::HexagonTargetHandler(HexagonLinkingContext &ctx)
: _ctx(ctx), _targetLayout(new HexagonTargetLayout(ctx)),
_relocationHandler(new HexagonTargetRelocationHandler(*_targetLayout)) {}
@@ -225,7 +226,7 @@ protected:
class DynamicGOTPLTPass final : public GOTPLTPass<DynamicGOTPLTPass> {
public:
- DynamicGOTPLTPass(const elf::HexagonLinkingContext &ctx) : GOTPLTPass(ctx) {
+ DynamicGOTPLTPass(const HexagonLinkingContext &ctx) : GOTPLTPass(ctx) {
_got0 = new (_file._alloc) HexagonGOTPLT0Atom(_file);
#ifndef NDEBUG
_got0->_name = "__got0";
@@ -305,8 +306,75 @@ public:
}
};
-void elf::HexagonLinkingContext::addPasses(PassManager &pm) {
+void HexagonLinkingContext::addPasses(PassManager &pm) {
if (isDynamic())
pm.add(llvm::make_unique<DynamicGOTPLTPass>(*this));
ELFLinkingContext::addPasses(pm);
}
+
+void SDataSection::doPreFlight() {
+ // sort the atoms on the alignments they have been set
+ std::stable_sort(_atoms.begin(), _atoms.end(), [](const lld::AtomLayout *A,
+ const lld::AtomLayout *B) {
+ const DefinedAtom *definedAtomA = cast<DefinedAtom>(A->_atom);
+ const DefinedAtom *definedAtomB = cast<DefinedAtom>(B->_atom);
+ int64_t alignmentA = definedAtomA->alignment().value;
+ int64_t alignmentB = definedAtomB->alignment().value;
+ if (alignmentA == alignmentB) {
+ if (definedAtomA->merge() == DefinedAtom::mergeAsTentative)
+ return false;
+ if (definedAtomB->merge() == DefinedAtom::mergeAsTentative)
+ return true;
+ }
+ return alignmentA < alignmentB;
+ });
+
+ // Set the fileOffset, and the appropriate size of the section
+ for (auto &ai : _atoms) {
+ const DefinedAtom *definedAtom = cast<DefinedAtom>(ai->_atom);
+ DefinedAtom::Alignment atomAlign = definedAtom->alignment();
+ uint64_t fOffset = alignOffset(fileSize(), atomAlign);
+ uint64_t mOffset = alignOffset(memSize(), atomAlign);
+ ai->_fileOffset = fOffset;
+ _fsize = fOffset + definedAtom->size();
+ _msize = mOffset + definedAtom->size();
+ }
+} // finalize
+
+SDataSection::SDataSection(const HexagonLinkingContext &ctx)
+ : AtomSection<ELF32LE>(ctx, ".sdata", DefinedAtom::typeDataFast, 0,
+ HexagonTargetLayout::ORDER_SDATA) {
+ _type = SHT_PROGBITS;
+ _flags = SHF_ALLOC | SHF_WRITE;
+ _alignment = 4096;
+}
+
+const AtomLayout *SDataSection::appendAtom(const Atom *atom) {
+ const DefinedAtom *definedAtom = cast<DefinedAtom>(atom);
+ DefinedAtom::Alignment atomAlign = definedAtom->alignment();
+ uint64_t alignment = atomAlign.value;
+ _atoms.push_back(new (_alloc) lld::AtomLayout(atom, 0, 0));
+ // Set the section alignment to the largest alignment
+ // std::max doesn't support uint64_t
+ if (_alignment < alignment)
+ _alignment = alignment;
+ return _atoms.back();
+}
+
+void finalizeHexagonRuntimeAtomValues(HexagonTargetLayout &layout) {
+ AtomLayout *gotAtom = layout.findAbsoluteAtom("_GLOBAL_OFFSET_TABLE_");
+ OutputSection<ELF32LE> *gotpltSection = layout.findOutputSection(".got.plt");
+ if (gotpltSection)
+ gotAtom->_virtualAddr = gotpltSection->virtualAddr();
+ else
+ gotAtom->_virtualAddr = 0;
+ AtomLayout *dynamicAtom = layout.findAbsoluteAtom("_DYNAMIC");
+ OutputSection<ELF32LE> *dynamicSection = layout.findOutputSection(".dynamic");
+ if (dynamicSection)
+ dynamicAtom->_virtualAddr = dynamicSection->virtualAddr();
+ else
+ dynamicAtom->_virtualAddr = 0;
+}
+
+} // namespace elf
+} // namespace lld
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h?rev=234863&r1=234862&r2=234863&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h Tue Apr 14 01:47:06 2015
@@ -132,69 +132,7 @@ private:
std::unique_ptr<HexagonTargetRelocationHandler> _relocationHandler;
};
-inline void SDataSection::doPreFlight() {
- // sort the atoms on the alignments they have been set
- std::stable_sort(_atoms.begin(), _atoms.end(), [](const lld::AtomLayout *A,
- const lld::AtomLayout *B) {
- const DefinedAtom *definedAtomA = cast<DefinedAtom>(A->_atom);
- const DefinedAtom *definedAtomB = cast<DefinedAtom>(B->_atom);
- int64_t alignmentA = definedAtomA->alignment().value;
- int64_t alignmentB = definedAtomB->alignment().value;
- if (alignmentA == alignmentB) {
- if (definedAtomA->merge() == DefinedAtom::mergeAsTentative)
- return false;
- if (definedAtomB->merge() == DefinedAtom::mergeAsTentative)
- return true;
- }
- return alignmentA < alignmentB;
- });
-
- // Set the fileOffset, and the appropriate size of the section
- for (auto &ai : _atoms) {
- const DefinedAtom *definedAtom = cast<DefinedAtom>(ai->_atom);
- DefinedAtom::Alignment atomAlign = definedAtom->alignment();
- uint64_t fOffset = alignOffset(fileSize(), atomAlign);
- uint64_t mOffset = alignOffset(memSize(), atomAlign);
- ai->_fileOffset = fOffset;
- _fsize = fOffset + definedAtom->size();
- _msize = mOffset + definedAtom->size();
- }
-} // finalize
-
-inline SDataSection::SDataSection(const HexagonLinkingContext &ctx)
- : AtomSection<ELF32LE>(ctx, ".sdata", DefinedAtom::typeDataFast, 0,
- HexagonTargetLayout::ORDER_SDATA) {
- _type = SHT_PROGBITS;
- _flags = SHF_ALLOC | SHF_WRITE;
- _alignment = 4096;
-}
-
-inline const lld::AtomLayout *SDataSection::appendAtom(const Atom *atom) {
- const DefinedAtom *definedAtom = cast<DefinedAtom>(atom);
- DefinedAtom::Alignment atomAlign = definedAtom->alignment();
- uint64_t alignment = atomAlign.value;
- _atoms.push_back(new (_alloc) lld::AtomLayout(atom, 0, 0));
- // Set the section alignment to the largest alignment
- // std::max doesn't support uint64_t
- if (_alignment < alignment)
- _alignment = alignment;
- return _atoms.back();
-}
-
-inline void finalizeHexagonRuntimeAtomValues(HexagonTargetLayout &layout) {
- AtomLayout *gotAtom = layout.findAbsoluteAtom("_GLOBAL_OFFSET_TABLE_");
- OutputSection<ELF32LE> *gotpltSection = layout.findOutputSection(".got.plt");
- if (gotpltSection)
- gotAtom->_virtualAddr = gotpltSection->virtualAddr();
- else
- gotAtom->_virtualAddr = 0;
- AtomLayout *dynamicAtom = layout.findAbsoluteAtom("_DYNAMIC");
- OutputSection<ELF32LE> *dynamicSection = layout.findOutputSection(".dynamic");
- if (dynamicSection)
- dynamicAtom->_virtualAddr = dynamicSection->virtualAddr();
- else
- dynamicAtom->_virtualAddr = 0;
-}
+void finalizeHexagonRuntimeAtomValues(HexagonTargetLayout &layout);
} // end namespace elf
} // end namespace lld
More information about the llvm-commits
mailing list