[lld] r234817 - ELF: Fix headers including each other.
Rui Ueyama
ruiu at google.com
Mon Apr 13 16:47:54 PDT 2015
Author: ruiu
Date: Mon Apr 13 18:47:53 2015
New Revision: 234817
URL: http://llvm.org/viewvc/llvm-project?rev=234817&view=rev
Log:
ELF: Fix headers including each other.
HexagonSectionChunks.h and HexagonTargetHandler.h include each other.
This patch removes the former and merge it with the latter.
Removed:
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h
Modified:
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
Removed: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h?rev=234816&view=auto
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h (removed)
@@ -1,83 +0,0 @@
-//===- lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h-----------------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#ifndef HEXAGON_SECTION_CHUNKS_H
-#define HEXAGON_SECTION_CHUNKS_H
-
-#include "HexagonTargetHandler.h"
-
-namespace lld {
-namespace elf {
-template <typename ELFT> class HexagonTargetLayout;
-class HexagonLinkingContext;
-
-/// \brief Handle Hexagon SData section
-template <class ELFT> class SDataSection : public AtomSection<ELFT> {
-public:
- SDataSection(const HexagonLinkingContext &ctx)
- : AtomSection<ELFT>(ctx, ".sdata", DefinedAtom::typeDataFast, 0,
- HexagonTargetLayout<ELFT>::ORDER_SDATA) {
- this->_type = SHT_PROGBITS;
- this->_flags = SHF_ALLOC | SHF_WRITE;
- this->_alignment = 4096;
- }
-
- /// \brief Finalize the section contents before writing
- void doPreFlight() override;
-
- /// \brief Does this section have an output segment.
- bool hasOutputSegment() const override { return true; }
-
- const lld::AtomLayout *appendAtom(const Atom *atom) override {
- const DefinedAtom *definedAtom = cast<DefinedAtom>(atom);
- DefinedAtom::Alignment atomAlign = definedAtom->alignment();
- uint64_t alignment = atomAlign.value;
- this->_atoms.push_back(new (this->_alloc) lld::AtomLayout(atom, 0, 0));
- // Set the section alignment to the largest alignment
- // std::max doesn't support uint64_t
- if (this->_alignment < alignment)
- this->_alignment = alignment;
- return (this->_atoms.back());
- }
-
-}; // SDataSection
-
-template <class ELFT> void SDataSection<ELFT>::doPreFlight() {
- // sort the atoms on the alignments they have been set
- std::stable_sort(this->_atoms.begin(), this->_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 : this->_atoms) {
- const DefinedAtom *definedAtom = cast<DefinedAtom>(ai->_atom);
- DefinedAtom::Alignment atomAlign = definedAtom->alignment();
- uint64_t fOffset = this->alignOffset(this->fileSize(), atomAlign);
- uint64_t mOffset = this->alignOffset(this->memSize(), atomAlign);
- ai->_fileOffset = fOffset;
- this->_fsize = fOffset + definedAtom->size();
- this->_msize = mOffset + definedAtom->size();
- }
-} // finalize
-
-} // elf
-} // lld
-
-#endif // LLD_READER_WRITER_ELF_HEXAGON_HEXAGON_SECTION_CHUNKS_H
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=234817&r1=234816&r2=234817&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h Mon Apr 13 18:47:53 2015
@@ -14,13 +14,28 @@
#include "HexagonELFFile.h"
#include "HexagonExecutableAtoms.h"
#include "HexagonRelocationHandler.h"
-#include "HexagonSectionChunks.h"
#include "TargetLayout.h"
namespace lld {
namespace elf {
class HexagonLinkingContext;
+typedef llvm::object::ELFType<llvm::support::little, 2, false> ELFT;
+
+/// \brief Handle Hexagon SData section
+template <class ELFT> class SDataSection : public AtomSection<ELFT> {
+public:
+ SDataSection(const HexagonLinkingContext &ctx);
+
+ /// \brief Finalize the section contents before writing
+ void doPreFlight() override;
+
+ /// \brief Does this section have an output segment.
+ bool hasOutputSegment() const override { return true; }
+
+ const lld::AtomLayout *appendAtom(const Atom *atom) override;
+};
+
/// \brief TargetLayout for Hexagon
template <class ELFT>
class HexagonTargetLayout final : public TargetLayout<ELFT> {
@@ -126,6 +141,58 @@ private:
std::unique_ptr<HexagonTargetRelocationHandler> _relocationHandler;
};
+template <class ELFT> void SDataSection<ELFT>::doPreFlight() {
+ // sort the atoms on the alignments they have been set
+ std::stable_sort(this->_atoms.begin(), this->_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 : this->_atoms) {
+ const DefinedAtom *definedAtom = cast<DefinedAtom>(ai->_atom);
+ DefinedAtom::Alignment atomAlign = definedAtom->alignment();
+ uint64_t fOffset = this->alignOffset(this->fileSize(), atomAlign);
+ uint64_t mOffset = this->alignOffset(this->memSize(), atomAlign);
+ ai->_fileOffset = fOffset;
+ this->_fsize = fOffset + definedAtom->size();
+ this->_msize = mOffset + definedAtom->size();
+ }
+} // finalize
+
+template <class ELFT>
+SDataSection<ELFT>::SDataSection(const HexagonLinkingContext &ctx)
+ : AtomSection<ELFT>(ctx, ".sdata", DefinedAtom::typeDataFast, 0,
+ HexagonTargetLayout<ELFT>::ORDER_SDATA) {
+ this->_type = SHT_PROGBITS;
+ this->_flags = SHF_ALLOC | SHF_WRITE;
+ this->_alignment = 4096;
+}
+
+template <class ELFT>
+const lld::AtomLayout *SDataSection<ELFT>::appendAtom(const Atom *atom) {
+ const DefinedAtom *definedAtom = cast<DefinedAtom>(atom);
+ DefinedAtom::Alignment atomAlign = definedAtom->alignment();
+ uint64_t alignment = atomAlign.value;
+ this->_atoms.push_back(new (this->_alloc) lld::AtomLayout(atom, 0, 0));
+ // Set the section alignment to the largest alignment
+ // std::max doesn't support uint64_t
+ if (this->_alignment < alignment)
+ this->_alignment = alignment;
+ return (this->_atoms.back());
+}
+
template <class ELFT>
void finalizeHexagonRuntimeAtomValues(HexagonTargetLayout<ELFT> &layout) {
AtomLayout *gotAtom = layout.findAbsoluteAtom("_GLOBAL_OFFSET_TABLE_");
More information about the llvm-commits
mailing list