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 <llvm/ADT/ilist_node.h> 13 14 #include <llvm/Support/DataTypes.h> 15 16 #include <cstddef> 17 #include <cassert> 18 19 namespace mcld { 20 21 class SectionData; 22 23 /** \class Fragment 24 * \brief Fragment is the minimun linking unit of MCLinker. 25 */ 26 class Fragment : public llvm::ilist_node<Fragment> 27 { 28 public: 29 enum Type { 30 Alignment, 31 Fillment, 32 Region, 33 Target, 34 Stub, 35 Null 36 }; 37 38 public: 39 Fragment(); 40 41 Fragment(Type pKind, SectionData *pParent = NULL); 42 43 virtual ~Fragment(); 44 getKind()45 Type getKind() const { return m_Kind; } 46 getParent()47 const SectionData* getParent() const { return m_pParent; } getParent()48 SectionData* getParent() { return m_pParent; } 49 setParent(SectionData * pValue)50 void setParent(SectionData *pValue) { m_pParent = pValue; } 51 52 uint64_t getOffset() const; 53 setOffset(uint64_t pOffset)54 void setOffset(uint64_t pOffset) { m_Offset = pOffset; } 55 56 bool hasOffset() const; 57 classof(const Fragment * O)58 static bool classof(const Fragment *O) { return true; } 59 size()60 virtual size_t size() const { 61 assert(false && "Can not call abstract Fragment::size()!"); 62 return 0; 63 } 64 65 private: 66 Fragment(const Fragment& ); // DO NOT IMPLEMENT 67 Fragment& operator=(const Fragment& ); // DO NOT IMPLEMENT 68 69 private: 70 Type m_Kind; 71 SectionData* m_pParent; 72 73 uint64_t m_Offset; 74 75 }; 76 77 } // namespace of mcld 78 79 #endif 80 81