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