1 //===- ELFSegmentFactory.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/ELFSegmentFactory.h> 10 11 using namespace mcld; 12 13 //========================== 14 // ELFSegmentFactory 15 16 ELFSegmentFactory::ELFSegmentFactory(size_t pNum) 17 : GCFactory<ELFSegment, 0>(pNum) 18 { 19 } 20 21 ELFSegmentFactory::~ELFSegmentFactory() 22 { 23 } 24 25 /// produce - produce an empty ELF segment information. 26 /// this function will create an ELF segment 27 /// @param pType - p_type in ELF program header 28 ELFSegment* ELFSegmentFactory::produce(uint32_t pType) 29 { 30 ELFSegment* segment = allocate(); 31 new (segment) ELFSegment(pType); 32 return segment; 33 } 34 35 /// destroy - destruct the ELF segment 36 void ELFSegmentFactory::destroy(ELFSegment*& pSegment) 37 { 38 deallocate(pSegment); 39 } 40 41