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 using 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()
     26   : m_pSection(NULL) {
     27 }
     28 
     29 SectionData::SectionData(LDSection &pSection)
     30   : m_pSection(&pSection) {
     31 }
     32 
     33 SectionData* SectionData::Create(LDSection& pSection)
     34 {
     35   SectionData* result = g_SectDataFactory->allocate();
     36   new (result) SectionData(pSection);
     37   return result;
     38 }
     39 
     40 void SectionData::Destroy(SectionData*& pSection)
     41 {
     42   pSection->~SectionData();
     43   g_SectDataFactory->deallocate(pSection);
     44   pSection = NULL;
     45 }
     46 
     47 void SectionData::Clear()
     48 {
     49   g_SectDataFactory->clear();
     50 }
     51 
     52