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