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