OutputRelocSection.h revision 5460a1f25d9ddecb5c70667267d66d51af177a99
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 OUTPUTRELOCSECTION_H 10#define OUTPUTRELOCSECTION_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 typedef llvm::DenseMap<const ResolveInfo*, Relocation*> SymRelMapType; 32 typedef SymRelMapType::iterator SymRelMapIterator; 33 34 typedef llvm::MCSectionData::iterator MCFragmentIterator; 35 36public: 37 OutputRelocSection(LDSection& pSection, 38 llvm::MCSectionData& pSectionData, 39 unsigned int pEntrySize); 40 ~OutputRelocSection(); 41 42 void reserveEntry(RelocationFactory& pRelFactory, size_t pNum=1); 43 44 Relocation* getEntry(const ResolveInfo& pSymbol, 45 bool isForGOT, 46 bool& pExist); 47 48private: 49 /// m_pSection - LDSection of this Section 50 LDSection* m_pSection; 51 52 /// m_SectionData - MCSectionData which contains the dynamic relocations 53 llvm::MCSectionData* m_pSectionData; 54 55 /// m_EntryBytes - size of a relocation entry 56 unsigned int m_EntryBytes; 57 58 /// m_isVisit - First time visit the function getEntry() or not 59 bool m_isVisit ; 60 61 /// m_ValidEntryIterator - point to the first valid entry 62 MCFragmentIterator m_ValidEntryIterator; 63 64 /// m_SymRelMap - map the resolved symbol to the Relocation entry 65 SymRelMapType m_SymRelMap; 66}; 67 68} // namespace of mcld 69 70#endif 71 72