1 //===- Fragment.h ---------------------------------------------------------===// 2 // 3 // The MCLinker Project 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 #ifndef MCLD_FRAGMENT_FRAGMENT_H_ 10 #define MCLD_FRAGMENT_FRAGMENT_H_ 11 12 #include "mcld/Support/Compiler.h" 13 14 #include <llvm/ADT/ilist_node.h> 15 #include <llvm/Support/DataTypes.h> 16 17 #include <cassert> 18 #include <cstddef> 19 20 namespace mcld { 21 22 class SectionData; 23 24 /** \class Fragment 25 * \brief Fragment is the minimun linking unit of MCLinker. 26 */ 27 class Fragment : public llvm::ilist_node_with_parent<Fragment, SectionData> { 28 public: 29 enum Type { Alignment, Fillment, Region, Target, Stub, Null }; 30 31 public: 32 Fragment(); 33 34 explicit Fragment(Type pKind, SectionData* pParent = NULL); 35 36 virtual ~Fragment(); 37 getKind()38 Type getKind() const { return m_Kind; } 39 getParent()40 const SectionData* getParent() const { return m_pParent; } getParent()41 SectionData* getParent() { return m_pParent; } 42 setParent(SectionData * pValue)43 void setParent(SectionData* pValue) { m_pParent = pValue; } 44 45 uint64_t getOffset() const; 46 setOffset(uint64_t pOffset)47 void setOffset(uint64_t pOffset) { m_Offset = pOffset; } 48 49 bool hasOffset() const; 50 classof(const Fragment * O)51 static bool classof(const Fragment* O) { return true; } 52 size()53 virtual size_t size() const { 54 assert(false && "Can not call abstract Fragment::size()!"); 55 return 0; 56 } 57 58 private: 59 Type m_Kind; 60 61 SectionData* m_pParent; 62 63 uint64_t m_Offset; 64 65 private: 66 DISALLOW_COPY_AND_ASSIGN(Fragment); 67 }; 68 69 } // namespace mcld 70 71 #endif // MCLD_FRAGMENT_FRAGMENT_H_ 72