OutputRelocSection.h revision cedee4b38f4786845183be7f5916dd520a170ae0
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/ADT/DenseMap.h> 16#include <mcld/LD/SectionData.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 SectionData& 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 SectionData::iterator FragmentIterator; 49 50private: 51 /// m_pSection - LDSection of this Section 52 LDSection* m_pSection; 53 54 /// m_SectionData - SectionData which contains the dynamic relocations 55 SectionData* 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 FragmentIterator 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