HexagonGOT.cpp revision 6f75755c9204b1d8817ae5a65a2f7e5af0ec3f70
1//===- HexagonGOT.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 "HexagonGOT.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// HexagonGOT
20//===----------------------------------------------------------------------===//
21HexagonGOT::HexagonGOT(LDSection& pSection)
22  : GOT(pSection), m_pLast(NULL)
23{
24}
25
26HexagonGOT::~HexagonGOT()
27{
28}
29
30void HexagonGOT::reserve(size_t pNum)
31{
32  for (size_t i = 0; i < pNum; i++) {
33    new HexagonGOTEntry(0, m_SectionData);
34  }
35}
36
37HexagonGOTEntry* HexagonGOT::consume()
38{
39  if (NULL == m_pLast) {
40    assert(!empty() && "Consume empty GOT entry!");
41    m_pLast = llvm::cast<HexagonGOTEntry>(&m_SectionData->front());
42    return m_pLast;
43  }
44
45  m_pLast = llvm::cast<HexagonGOTEntry>(m_pLast->getNextNode());
46  return m_pLast;
47}
48
49