1//===- SectionData.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/SectionData.h" 10 11#include "mcld/LD/LDSection.h" 12#include "mcld/Support/GCFactory.h" 13 14#include <llvm/Support/ManagedStatic.h> 15 16namespace mcld { 17 18typedef GCFactory<SectionData, MCLD_SECTIONS_PER_INPUT> SectDataFactory; 19 20static llvm::ManagedStatic<SectDataFactory> g_SectDataFactory; 21 22//===----------------------------------------------------------------------===// 23// SectionData 24//===----------------------------------------------------------------------===// 25SectionData::SectionData() : m_pSection(NULL) { 26} 27 28SectionData::SectionData(LDSection& pSection) : m_pSection(&pSection) { 29} 30 31SectionData* SectionData::Create(LDSection& pSection) { 32 SectionData* result = g_SectDataFactory->allocate(); 33 new (result) SectionData(pSection); 34 return result; 35} 36 37void SectionData::Destroy(SectionData*& pSection) { 38 pSection->~SectionData(); 39 g_SectDataFactory->deallocate(pSection); 40 pSection = NULL; 41} 42 43void SectionData::Clear() { 44 g_SectDataFactory->clear(); 45} 46 47} // namespace mcld 48