OutputRelocSection.h revision affc150dc44fab1911775a49636d0ce85333b634
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 <llvm/MC/MCAssembler.h>
16#include <llvm/ADT/DenseMap.h>
17#include <mcld/LD/RelocationFactory.h>
18
19namespace mcld
20{
21
22class ResolveInfo;
23class Relocation;
24
25/** \class OutputRelocSection
26 *  \brief Dynamic relocation section for ARM .rel.dyn and .rel.plt
27 */
28class OutputRelocSection
29{
30public:
31  OutputRelocSection(LDSection& pSection,
32                   llvm::MCSectionData& pSectionData,
33                   unsigned int pEntrySize);
34
35  ~OutputRelocSection();
36
37  void reserveEntry(RelocationFactory& pRelFactory, size_t pNum=1);
38
39  Relocation* getEntry(const ResolveInfo& pSymbol,
40                       bool isForGOT,
41                       bool& pExist);
42
43private:
44  typedef llvm::DenseMap<const ResolveInfo*, Relocation*> SymRelMapType;
45
46  typedef SymRelMapType::iterator SymRelMapIterator;
47
48  typedef llvm::MCSectionData::iterator MCFragmentIterator;
49
50private:
51  /// m_pSection - LDSection of this Section
52  LDSection* m_pSection;
53
54  /// m_SectionData - MCSectionData which contains the dynamic relocations
55  llvm::MCSectionData* m_pSectionData;
56
57  /// m_EntryBytes - size of a relocation entry
58  unsigned int m_EntryBytes;
59
60  /// m_isVisit - First time visit the function getEntry() or not
61  bool m_isVisit;
62
63  /// m_ValidEntryIterator - point to the first valid entry
64  MCFragmentIterator m_ValidEntryIterator;
65
66  /// m_SymRelMap - map the resolved symbol to the Relocation entry
67  SymRelMapType m_SymRelMap;
68};
69
70} // namespace of mcld
71
72#endif
73
74