X86GOT.cpp revision d0fbbb227051be16931a1aa9b4a7722ac039c698
1//===- impl.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 "X86GOT.h"
10
11#include <mcld/LD/LDFileFormat.h>
12#include <mcld/LD/SectionData.h>
13
14#include <llvm/Support/Casting.h>
15
16using namespace mcld;
17
18//===----------------------------------------------------------------------===//
19// X86GOT
20//===----------------------------------------------------------------------===//
21X86GOT::X86GOT(LDSection& pSection)
22  : GOT(pSection), m_pLast(NULL)
23{
24}
25
26X86GOT::~X86GOT()
27{
28}
29
30void X86GOT::reserve(size_t pNum)
31{
32  for (size_t i = 0; i < pNum; i++) {
33    new X86GOTEntry(0, m_SectionData);
34  }
35}
36
37X86GOTEntry* X86GOT::consume()
38{
39  if (NULL == m_pLast) {
40    assert(!empty() && "Consume empty GOT entry!");
41    m_pLast = llvm::cast<X86GOTEntry>(&m_SectionData->front());
42    return m_pLast;
43  }
44
45  m_pLast = llvm::cast<X86GOTEntry>(m_pLast->getNextNode());
46  return m_pLast;
47}
48
49