summaryrefslogtreecommitdiff
path: root/lib/LD/SectionData.cpp
blob: bb7372409b8b985c2564e57653d6a1a063b3b228 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//===- SectionData.cpp ----------------------------------------------------===//
//
//                     The MCLinker Project
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <mcld/LD/SectionData.h>

#include <mcld/LD/LDSection.h>
#include <mcld/Support/GCFactory.h>

#include <llvm/Support/ManagedStatic.h>

using namespace mcld;

typedef GCFactory<SectionData, MCLD_SECTIONS_PER_INPUT> SectDataFactory;

static llvm::ManagedStatic<SectDataFactory> g_SectDataFactory;

//===----------------------------------------------------------------------===//
// SectionData
//===----------------------------------------------------------------------===//
SectionData::SectionData()
  : m_pSection(NULL) {
}

SectionData::SectionData(LDSection &pSection)
  : m_pSection(&pSection) {
}

SectionData* SectionData::Create(LDSection& pSection)
{
  SectionData* result = g_SectDataFactory->allocate();
  new (result) SectionData(pSection);
  return result;
}

void SectionData::Destroy(SectionData*& pSection)
{
  pSection->~SectionData();
  g_SectDataFactory->deallocate(pSection);
  pSection = NULL;
}

void SectionData::Clear()
{
  g_SectDataFactory->clear();
}