RelocData.cpp revision d0fbbb227051be16931a1aa9b4a7722ac039c698
1//===- RelocData.cpp ------------------------------------------------------===// 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#include <mcld/LD/RelocData.h> 10#include <mcld/Support/GCFactory.h> 11 12#include <llvm/Support/ManagedStatic.h> 13 14using namespace mcld; 15 16typedef GCFactory<RelocData, MCLD_SECTIONS_PER_INPUT> RelocDataFactory; 17 18static llvm::ManagedStatic<RelocDataFactory> g_RelocDataFactory; 19 20//===----------------------------------------------------------------------===// 21// RelocData 22//===----------------------------------------------------------------------===// 23RelocData::RelocData() 24 : m_pSection(NULL) { 25} 26 27RelocData::RelocData(LDSection &pSection) 28 : m_pSection(&pSection) { 29} 30 31RelocData* RelocData::Create(LDSection& pSection) 32{ 33 RelocData* result = g_RelocDataFactory->allocate(); 34 new (result) RelocData(pSection); 35 return result; 36} 37 38void RelocData::Destroy(RelocData*& pSection) 39{ 40 pSection->~RelocData(); 41 g_RelocDataFactory->deallocate(pSection); 42 pSection = NULL; 43} 44 45void RelocData::Clear() 46{ 47 g_RelocDataFactory->clear(); 48} 49 50RelocData& RelocData::append(Relocation& pRelocation) 51{ 52 m_Relocations.push_back(&pRelocation); 53 return *this; 54} 55 56