1 //===- GOT.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/LDSection.h"
10 #include "mcld/IRBuilder.h"
11 #include "mcld/Support/MsgHandling.h"
12 #include "mcld/Target/GOT.h"
13 
14 #include <llvm/Support/Casting.h>
15 
16 #include <cstring>
17 #include <cstdlib>
18 
19 namespace mcld {
20 
21 //===----------------------------------------------------------------------===//
22 // GOT
23 //===----------------------------------------------------------------------===//
GOT(LDSection & pSection)24 GOT::GOT(LDSection& pSection) : m_Section(pSection) {
25   m_SectionData = IRBuilder::CreateSectionData(pSection);
26 }
27 
~GOT()28 GOT::~GOT() {
29 }
30 
finalizeSectionSize()31 void GOT::finalizeSectionSize() {
32   uint32_t offset = 0;
33   SectionData::iterator frag, fragEnd = m_SectionData->end();
34   for (frag = m_SectionData->begin(); frag != fragEnd; ++frag) {
35     frag->setOffset(offset);
36     offset += frag->size();
37   }
38 
39   m_Section.setSize(offset);
40 }
41 
42 }  // namespace mcld
43