[lld] r234727 - [Mips] Move `MipsTargetLayout` class to the separate header
Simon Atanasyan
simon at atanasyan.com
Mon Apr 13 01:34:47 PDT 2015
Author: atanasyan
Date: Mon Apr 13 03:34:46 2015
New Revision: 234727
URL: http://llvm.org/viewvc/llvm-project?rev=234727&view=rev
Log:
[Mips] Move `MipsTargetLayout` class to the separate header
Added:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetLayout.h
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
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=234727&r1=234726&r2=234727&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp Mon Apr 13 03:34:46 2015
@@ -7,9 +7,9 @@
//
//===----------------------------------------------------------------------===//
-#include "MipsTargetHandler.h"
#include "MipsLinkingContext.h"
#include "MipsRelocationHandler.h"
+#include "MipsTargetLayout.h"
using namespace lld;
using namespace elf;
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp?rev=234727&r1=234726&r2=234727&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp Mon Apr 13 03:34:46 2015
@@ -10,7 +10,6 @@
#include "MipsELFFile.h"
#include "MipsLinkingContext.h"
#include "MipsRelocationPass.h"
-#include "MipsTargetHandler.h"
#include "llvm/ADT/DenseSet.h"
using namespace lld;
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=234727&r1=234726&r2=234727&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h Mon Apr 13 03:34:46 2015
@@ -14,83 +14,12 @@
#include "MipsELFFile.h"
#include "MipsExecutableWriter.h"
#include "MipsLinkingContext.h"
-#include "MipsRelocationHandler.h"
-#include "MipsSectionChunks.h"
-#include "TargetLayout.h"
-#include "llvm/ADT/DenseSet.h"
+#include "MipsTargetLayout.h"
+#include "TargetHandler.h"
namespace lld {
namespace elf {
-/// \brief TargetLayout for Mips
-template <class ELFT> class MipsTargetLayout final : public TargetLayout<ELFT> {
-public:
- MipsTargetLayout(MipsLinkingContext &ctx)
- : TargetLayout<ELFT>(ctx),
- _gotSection(new (this->_allocator) MipsGOTSection<ELFT>(ctx)),
- _pltSection(new (this->_allocator) MipsPLTSection<ELFT>(ctx)) {}
-
- const MipsGOTSection<ELFT> &getGOTSection() const { return *_gotSection; }
- const MipsPLTSection<ELFT> &getPLTSection() const { return *_pltSection; }
-
- AtomSection<ELFT> *
- createSection(StringRef name, int32_t type,
- DefinedAtom::ContentPermissions permissions,
- typename TargetLayout<ELFT>::SectionOrder order) override {
- if (type == DefinedAtom::typeGOT && name == ".got")
- return _gotSection;
- if (type == DefinedAtom::typeStub && name == ".plt")
- return _pltSection;
- return TargetLayout<ELFT>::createSection(name, type, permissions, order);
- }
-
- /// \brief GP offset relative to .got section.
- uint64_t getGPOffset() const { return 0x7FF0; }
-
- /// \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.
- AtomLayout *getGPDisp() {
- std::call_once(_gpDispOnce, [this]() {
- _gpDispAtom = this->findAbsoluteAtom("_gp_disp");
- });
- return _gpDispAtom;
- }
-
- /// \brief Return the section order for a input section
- typename TargetLayout<ELFT>::SectionOrder
- getSectionOrder(StringRef name, int32_t contentType,
- int32_t contentPermissions) override {
- if ((contentType == DefinedAtom::typeStub) && (name.startswith(".text")))
- return TargetLayout<ELFT>::ORDER_TEXT;
-
- return TargetLayout<ELFT>::getSectionOrder(name, contentType,
- contentPermissions);
- }
-
-protected:
- unique_bump_ptr<RelocationTable<ELFT>>
- createRelocationTable(StringRef name, int32_t order) override {
- return unique_bump_ptr<RelocationTable<ELFT>>(new (
- this->_allocator) MipsRelocationTable<ELFT>(this->_ctx, name, order));
- }
-
-private:
- MipsGOTSection<ELFT> *_gotSection;
- MipsPLTSection<ELFT> *_pltSection;
- uint64_t _gpAddr = 0;
- AtomLayout *_gpDispAtom = nullptr;
- std::once_flag _gpOnce;
- std::once_flag _gpDispOnce;
-};
-
/// \brief TargetHandler for Mips
template <class ELFT> class MipsTargetHandler final : public TargetHandler {
typedef ELFReader<ELFT, MipsLinkingContext, MipsELFFile> ObjReader;
Added: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetLayout.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetLayout.h?rev=234727&view=auto
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetLayout.h (added)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetLayout.h Mon Apr 13 03:34:46 2015
@@ -0,0 +1,94 @@
+//===- lib/ReaderWriter/ELF/Mips/MipsTargetLayout.h -----------------------===//
+//
+// The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLD_READER_WRITER_ELF_MIPS_MIPS_TARGET_LAYOUT_H
+#define LLD_READER_WRITER_ELF_MIPS_MIPS_TARGET_LAYOUT_H
+
+#include "TargetLayout.h"
+
+namespace lld {
+namespace elf {
+
+template <typename ELFT> class MipsGOTSection;
+template <typename ELFT> class MipsPLTSection;
+template <typename ELFT> class MipsRelocationTable;
+class MipsLinkingContext;
+
+/// \brief TargetLayout for Mips
+template <class ELFT> class MipsTargetLayout final : public TargetLayout<ELFT> {
+public:
+ MipsTargetLayout(MipsLinkingContext &ctx)
+ : TargetLayout<ELFT>(ctx),
+ _gotSection(new (this->_allocator) MipsGOTSection<ELFT>(ctx)),
+ _pltSection(new (this->_allocator) MipsPLTSection<ELFT>(ctx)) {}
+
+ const MipsGOTSection<ELFT> &getGOTSection() const { return *_gotSection; }
+ const MipsPLTSection<ELFT> &getPLTSection() const { return *_pltSection; }
+
+ AtomSection<ELFT> *
+ createSection(StringRef name, int32_t type,
+ DefinedAtom::ContentPermissions permissions,
+ typename TargetLayout<ELFT>::SectionOrder order) override {
+ if (type == DefinedAtom::typeGOT && name == ".got")
+ return _gotSection;
+ if (type == DefinedAtom::typeStub && name == ".plt")
+ return _pltSection;
+ return TargetLayout<ELFT>::createSection(name, type, permissions, order);
+ }
+
+ /// \brief GP offset relative to .got section.
+ uint64_t getGPOffset() const { return 0x7FF0; }
+
+ /// \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.
+ AtomLayout *getGPDisp() {
+ std::call_once(_gpDispOnce, [this]() {
+ _gpDispAtom = this->findAbsoluteAtom("_gp_disp");
+ });
+ return _gpDispAtom;
+ }
+
+ /// \brief Return the section order for a input section
+ typename TargetLayout<ELFT>::SectionOrder
+ getSectionOrder(StringRef name, int32_t contentType,
+ int32_t contentPermissions) override {
+ if ((contentType == DefinedAtom::typeStub) && (name.startswith(".text")))
+ return TargetLayout<ELFT>::ORDER_TEXT;
+
+ return TargetLayout<ELFT>::getSectionOrder(name, contentType,
+ contentPermissions);
+ }
+
+protected:
+ unique_bump_ptr<RelocationTable<ELFT>>
+ createRelocationTable(StringRef name, int32_t order) override {
+ return unique_bump_ptr<RelocationTable<ELFT>>(new (
+ this->_allocator) MipsRelocationTable<ELFT>(this->_ctx, name, order));
+ }
+
+private:
+ MipsGOTSection<ELFT> *_gotSection;
+ MipsPLTSection<ELFT> *_pltSection;
+ uint64_t _gpAddr = 0;
+ AtomLayout *_gpDispAtom = nullptr;
+ std::once_flag _gpOnce;
+ std::once_flag _gpDispOnce;
+};
+
+} // end namespace elf
+} // end namespace lld
+
+#endif
More information about the llvm-commits
mailing list