Home | History | Annotate | Download | only in Hexagon
      1 //===- HexagonPLT.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 "HexagonPLT.h"
     10 
     11 #include <llvm/Support/ELF.h>
     12 #include <llvm/Support/Casting.h>
     13 
     14 #include <mcld/LD/LDSection.h>
     15 #include <mcld/LinkerConfig.h>
     16 #include <mcld/Support/MsgHandling.h>
     17 
     18 using namespace mcld;
     19 
     20 //===----------------------------------------------------------------------===//
     21 // PLT entry data
     22 //===----------------------------------------------------------------------===//
     23 HexagonDynPLT0::HexagonDynPLT0(SectionData& pParent)
     24   : PLT::Entry<sizeof(hexagon_dyn_plt0)>(pParent)
     25 {
     26 }
     27 
     28 HexagonExecPLT0::HexagonExecPLT0(SectionData& pParent)
     29   : PLT::Entry<sizeof(hexagon_exec_plt0)>(pParent)
     30 {
     31 }
     32 
     33 //===----------------------------------------------------------------------===//
     34 // HexagonPLT
     35 //===----------------------------------------------------------------------===//
     36 HexagonPLT::HexagonPLT(LDSection& pSection,
     37                HexagonGOT &pGOTPLT,
     38                const LinkerConfig& pConfig)
     39   : PLT(pSection),
     40     m_GOT(pGOTPLT),
     41     m_Config(pConfig)
     42 {
     43   assert(LinkerConfig::DynObj == m_Config.codeGenType() ||
     44          LinkerConfig::Exec   == m_Config.codeGenType() ||
     45          LinkerConfig::Binary == m_Config.codeGenType());
     46 
     47   if (LinkerConfig::DynObj == m_Config.codeGenType()) {
     48     m_PLT0 = hexagon_dyn_plt0;
     49     m_PLT0Size = sizeof (hexagon_dyn_plt0);
     50     // create PLT0
     51     new HexagonDynPLT0(*m_SectionData);
     52   }
     53   else {
     54     m_PLT0 = hexagon_exec_plt0;
     55     m_PLT0Size = sizeof (hexagon_exec_plt0);
     56     // create PLT0
     57     new HexagonExecPLT0(*m_SectionData);
     58   }
     59   m_Last = m_SectionData->begin();
     60 }
     61 
     62 HexagonPLT::~HexagonPLT()
     63 {
     64 }
     65 
     66 PLTEntryBase* HexagonPLT::getPLT0() const
     67 {
     68   iterator first = m_SectionData->getFragmentList().begin();
     69 
     70   assert(first != m_SectionData->getFragmentList().end() &&
     71          "FragmentList is empty, getPLT0 failed!");
     72 
     73   PLTEntryBase* plt0 = &(llvm::cast<PLTEntryBase>(*first));
     74 
     75   return plt0;
     76 }
     77 
     78 void HexagonPLT::finalizeSectionSize()
     79 {
     80   uint64_t size = 0;
     81   // plt0 size
     82   size = getPLT0()->size();
     83 
     84   m_Section.setSize(size);
     85 
     86   uint32_t offset = 0;
     87   SectionData::iterator frag, fragEnd = m_SectionData->end();
     88   for (frag = m_SectionData->begin(); frag != fragEnd; ++frag) {
     89     frag->setOffset(offset);
     90     offset += frag->size();
     91   }
     92 }
     93 
     94 void HexagonPLT::reserveEntry(size_t pNum)
     95 {
     96 }
     97 
     98