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