OutputRelocSection.h revision 22add6ff3426df1a85089fe6a6e1597ee3b6f300
1//===- OutputRelocSection.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_OUTPUT_RELOCATION_SECTION_H
10#define MCLD_OUTPUT_RELOCATION_SECTION_H
11#ifdef ENABLE_UNITTEST
12#include <gtest.h>
13#endif
14
15#include <mcld/LD/RelocData.h>
16
17namespace mcld
18{
19
20class LDSymbol;
21class Module;
22class Relocation;
23class RelocationFactory;
24
25/** \class OutputRelocSection
26 *  \brief Dynamic relocation section for ARM .rel.dyn and .rel.plt
27 */
28class OutputRelocSection
29{
30public:
31  OutputRelocSection(Module& pModule,
32                     LDSection& pSection,
33                     unsigned int pEntrySize);
34
35  ~OutputRelocSection();
36
37  void reserveEntry(RelocationFactory& pRelFactory, size_t pNum=1);
38
39  Relocation* consumeEntry();
40
41  void finalizeSectionSize();
42
43  /// addSymbolToDynSym - add local symbol to TLS category so that it'll be
44  /// emitted into .dynsym
45  bool addSymbolToDynSym(LDSymbol& pSymbol);
46
47  // ----- observers ----- //
48  bool empty()
49  { return m_pRelocData->empty(); }
50
51private:
52  typedef RelocData::iterator FragmentIterator;
53
54private:
55  Module& m_Module;
56
57  /// m_pSection - LDSection of this Section
58  LDSection* m_pSection;
59
60  /// m_RelocData - the output RelocData which contains the dynamic
61  /// relocations
62  RelocData* m_pRelocData;
63
64  /// m_EntryBytes - size of a relocation entry
65  unsigned int m_EntryBytes;
66
67  /// m_isVisit - First time visit the function getEntry() or not
68  bool m_isVisit;
69
70  /// m_ValidEntryIterator - point to the first valid entry
71  FragmentIterator m_ValidEntryIterator;
72};
73
74} // namespace of mcld
75
76#endif
77
78