• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- Fragment.cpp -------------------------------------------------------===//
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 
10 #include <mcld/Fragment/Fragment.h>
11 
12 #include <llvm/Support/DataTypes.h>
13 
14 #include <mcld/LD/SectionData.h>
15 
16 using namespace mcld;
17 
18 //===----------------------------------------------------------------------===//
19 // Fragment
20 //===----------------------------------------------------------------------===//
Fragment()21 Fragment::Fragment()
22   : m_Kind(Type(~0)), m_pParent(NULL), m_Offset(~uint64_t(0)) {
23 }
24 
Fragment(Type pKind,SectionData * pParent)25 Fragment::Fragment(Type pKind, SectionData *pParent)
26   : m_Kind(pKind), m_pParent(pParent), m_Offset(~uint64_t(0)) {
27   if (NULL != m_pParent)
28     m_pParent->getFragmentList().push_back(this);
29 }
30 
~Fragment()31 Fragment::~Fragment()
32 {
33 }
34 
getOffset() const35 uint64_t Fragment::getOffset() const
36 {
37   assert(hasOffset() && "Cannot getOffset() before setting it up.");
38   return m_Offset;
39 }
40 
hasOffset() const41 bool Fragment::hasOffset() const
42 {
43   return (m_Offset != ~uint64_t(0));
44 }
45 
46