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