1 //===- HexagonGOTPLT.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 "HexagonGOTPLT.h" 10 #include "HexagonPLT.h" 11 12 #include "mcld/LD/LDSection.h" 13 #include "mcld/LD/LDFileFormat.h" 14 #include "mcld/Support/MsgHandling.h" 15 16 #include <llvm/Support/Casting.h> 17 18 namespace mcld { 19 20 //===----------------------------------------------------------------------===// 21 // HexagonGOTPLT 22 //===----------------------------------------------------------------------===// HexagonGOTPLT(LDSection & pSection)23HexagonGOTPLT::HexagonGOTPLT(LDSection& pSection) : HexagonGOT(pSection) { 24 // Skip GOT0 entries 25 for (size_t i = 0; i < HexagonGOTPLT0Num; ++i) { 26 create(); 27 } 28 pSection.setAlign(8); 29 } 30 ~HexagonGOTPLT()31HexagonGOTPLT::~HexagonGOTPLT() { 32 } 33 34 // Check if we really have GOT PLT entries ? hasGOT1() const35bool HexagonGOTPLT::hasGOT1() const { 36 return (m_SectionData->size() > HexagonGOTPLT0Num); 37 } 38 applyGOT0(uint64_t pAddress)39void HexagonGOTPLT::applyGOT0(uint64_t pAddress) { 40 llvm::cast<HexagonGOTEntry>(*(m_SectionData->getFragmentList().begin())) 41 .setValue(pAddress); 42 } 43 applyAllGOTPLT(const HexagonPLT & pPLT)44void HexagonGOTPLT::applyAllGOTPLT(const HexagonPLT& pPLT) { 45 iterator it = begin(); 46 // skip GOT0 47 for (size_t i = 0; i < HexagonGOTPLT0Num; ++i) 48 ++it; 49 // Set the initial value of the GOT entry to the address 50 // of PLT0, the stub calculates the index of the caller directly from 51 // the address where the call arised 52 for (; it != end(); ++it) { 53 llvm::cast<HexagonGOTEntry>(*it).setValue(pPLT.addr()); 54 } 55 } 56 57 } // namespace mcld 58