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
20namespace mcld
21{
22
23class SectionData;
24
25/** \class Fragment
26 *  \brief Fragment is the minimun linking unit of MCLinker.
27 */
28class Fragment : public llvm::ilist_node<Fragment>
29{
30public:
31  enum Type {
32    Alignment,
33    Fillment,
34    Region,
35    Relocation,
36    Target
37  };
38
39public:
40  Fragment();
41
42  Fragment(Type pKind, SectionData *pParent = NULL);
43
44  virtual ~Fragment();
45
46  Type getKind() const { return m_Kind; }
47
48  SectionData *getParent() const { return m_pParent; }
49
50  void setParent(SectionData *pValue) { m_pParent = pValue; }
51
52  uint64_t getOffset() const { return m_Offset; }
53
54  void setOffset(uint64_t pOffset) { m_Offset = pOffset; }
55
56  unsigned int getLayoutOrder() const { return m_LayoutOrder; }
57
58  void setLayoutOrder(unsigned int pValue) { m_LayoutOrder = pValue; }
59
60  static bool classof(const Fragment *O) { return true; }
61
62private:
63  Fragment(const Fragment& );            // DO NOT IMPLEMENT
64  Fragment& operator=(const Fragment& ); // DO NOT IMPLEMENT
65
66private:
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