1//===- LDSectionFactory.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/LDSectionFactory.h> 10 11using namespace mcld; 12 13//========================== 14// LDSectionFactory 15LDSectionFactory::LDSectionFactory(size_t pNum) 16 : GCFactory<LDSection, 0>(pNum) { 17} 18 19LDSectionFactory::~LDSectionFactory() 20{ 21} 22 23LDSection* LDSectionFactory::produce(const std::string& pName, 24 LDFileFormat::Kind pKind, 25 uint32_t pType, 26 uint32_t pFlag) 27{ 28 // create a LDSection 29 LDSection* result = allocate(); 30 new (result) LDSection(pName, pKind, pType, pFlag); 31 return result; 32} 33 34void LDSectionFactory::destroy(LDSection*& pSection) 35{ 36 // do not recycle LDSection. HeaderFactory will do that job. 37 deallocate(pSection); 38} 39 40LDSection* LDSectionFactory::find(const std::string& pName) 41{ 42 iterator sect_iter, sect_end = end(); 43 for (sect_iter = begin(); sect_iter != sect_end; ++sect_iter) 44 if ((*sect_iter).name() == pName) 45 break; 46 if (sect_iter == sect_end) 47 return NULL; 48 return &(*sect_iter); 49} 50