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, LDSection& pSection);
32
33  ~OutputRelocSection();
34
35  void reserveEntry(size_t pNum=1);
36
37  Relocation* consumeEntry();
38
39  /// addSymbolToDynSym - add local symbol to TLS category so that it'll be
40  /// emitted into .dynsym
41  bool addSymbolToDynSym(LDSymbol& pSymbol);
42
43  // ----- observers ----- //
44  bool empty()
45  { return m_pRelocData->empty(); }
46
47  size_t numOfRelocs();
48
49private:
50  typedef RelocData::iterator RelocIterator;
51
52private:
53  Module& m_Module;
54
55  /// m_RelocData - the output RelocData which contains the dynamic
56  /// relocations
57  RelocData* m_pRelocData;
58
59  /// m_isVisit - First time visit the function getEntry() or not
60  bool m_isVisit;
61
62  /// m_ValidEntryIterator - point to the first valid entry
63  RelocIterator m_ValidEntryIterator;
64};
65
66} // namespace of mcld
67
68#endif
69
70