blob: 01f16b1e7fe0b300f0abc9be76b6896d8f9c165d [file] [log] [blame]
Stephen Hines6f757552013-03-04 19:51:03 -08001//===- HexagonPLT.h -------------------------------------------------------===//
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//===----------------------------------------------------------------------===//
Stephen Hines37b74a32014-11-26 18:48:20 -08009#ifndef TARGET_HEXAGON_HEXAGONPLT_H_
10#define TARGET_HEXAGON_HEXAGONPLT_H_
Stephen Hines6f757552013-03-04 19:51:03 -080011
12#include "HexagonGOT.h"
Stephen Hinesf7ac0f12013-05-03 19:09:24 -070013#include "HexagonGOTPLT.h"
Stephen Hines37b74a32014-11-26 18:48:20 -080014#include "mcld/Target/GOT.h"
15#include "mcld/Target/PLT.h"
16#include "mcld/Support/MemoryRegion.h"
Stephen Hines6f757552013-03-04 19:51:03 -080017
Stephen Hinesf7ac0f12013-05-03 19:09:24 -070018const uint8_t hexagon_plt0[] = {
Stephen Hines37b74a32014-11-26 18:48:20 -080019 0x00, 0x40, 0x00, 0x00, // { immext (#0)
20 0x1c, 0xc0, 0x49, 0x6a, // r28 = add (pc, ##GOT0@PCREL) } # address of GOT0 // NOLINT
21 0x0e, 0x42, 0x9c, 0xe2, // { r14 -= add (r28, #16) # offset of GOTn from GOTa // NOLINT
22 0x4f, 0x40, 0x9c, 0x91, // r15 = memw (r28 + #8) # object ID at GOT2
23 0x3c, 0xc0, 0x9c, 0x91, // r28 = memw (r28 + #4) } # dynamic link at GOT1
24 0x0e, 0x42, 0x0e, 0x8c, // { r14 = asr (r14, #2) # index of PLTn
25 0x00, 0xc0, 0x9c, 0x52, // jumpr r28 } # call dynamic linker
26 0x00, 0x00, 0x00, 0x00,
27 0x00, 0x00, 0x00, 0x00,
28 0x00, 0x00, 0x00, 0x00,
29 0x00, 0x00, 0x00, 0x00,
30 0x00, 0x00, 0x00, 0x00
Stephen Hines6f757552013-03-04 19:51:03 -080031};
32
Stephen Hinesf7ac0f12013-05-03 19:09:24 -070033const uint8_t hexagon_plt1[] = {
Stephen Hines37b74a32014-11-26 18:48:20 -080034 0x00, 0x40, 0x00, 0x00, // { immext (#0)
35 0x0e, 0xc0, 0x49, 0x6a, // r14 = add (pc, ##GOTn@PCREL) } # address of GOTn // NOLINT
36 0x1c, 0xc0, 0x8e, 0x91, // r28 = memw (r14) # contents of GOTn // NOLINT
37 0x00, 0xc0, 0x9c, 0x52 // jumpr r28 # call it
Stephen Hines6f757552013-03-04 19:51:03 -080038};
39
Stephen Hines6f757552013-03-04 19:51:03 -080040namespace mcld {
41
42class GOTEntry;
Stephen Hinesf7ac0f12013-05-03 19:09:24 -070043class HexagonPLT1;
Stephen Hines37b74a32014-11-26 18:48:20 -080044class LinkerConfig;
Stephen Hines6f757552013-03-04 19:51:03 -080045
46//===----------------------------------------------------------------------===//
47// HexagonPLT Entry
48//===----------------------------------------------------------------------===//
Stephen Hines37b74a32014-11-26 18:48:20 -080049class HexagonPLT0 : public PLT::Entry<sizeof(hexagon_plt0)> {
50 public:
Stephen Hinesf7ac0f12013-05-03 19:09:24 -070051 HexagonPLT0(SectionData& pParent);
Stephen Hines6f757552013-03-04 19:51:03 -080052};
53
54//===----------------------------------------------------------------------===//
55// HexagonPLT
56//===----------------------------------------------------------------------===//
57/** \class HexagonPLT
58 * \brief Hexagon Procedure Linkage Table
59 */
Stephen Hines37b74a32014-11-26 18:48:20 -080060class HexagonPLT : public PLT {
61 public:
Stephen Hines6f757552013-03-04 19:51:03 -080062 HexagonPLT(LDSection& pSection,
Stephen Hinesf7ac0f12013-05-03 19:09:24 -070063 HexagonGOTPLT& pGOTPLT,
Stephen Hines6f757552013-03-04 19:51:03 -080064 const LinkerConfig& pConfig);
65 ~HexagonPLT();
66
67 // finalizeSectionSize - set LDSection size
68 void finalizeSectionSize();
69
Stephen Hinesf7ac0f12013-05-03 19:09:24 -070070 // hasPLT1 - return if this PLT has any PLT1 entry
71 bool hasPLT1() const;
72
Stephen Hines87f34652014-02-14 18:00:16 -080073 HexagonPLT1* create();
Stephen Hinesf7ac0f12013-05-03 19:09:24 -070074
75 void applyPLT0();
76
77 void applyPLT1();
78
79 uint64_t emit(MemoryRegion& pRegion);
80
Stephen Hines6f757552013-03-04 19:51:03 -080081 PLTEntryBase* getPLT0() const;
82
Stephen Hines37b74a32014-11-26 18:48:20 -080083 private:
Stephen Hinesf7ac0f12013-05-03 19:09:24 -070084 HexagonGOTPLT& m_GOTPLT;
Stephen Hines6f757552013-03-04 19:51:03 -080085
Stephen Hines37b74a32014-11-26 18:48:20 -080086 const uint8_t* m_PLT0;
Stephen Hines6f757552013-03-04 19:51:03 -080087 unsigned int m_PLT0Size;
Stephen Hines6f757552013-03-04 19:51:03 -080088};
89
Stephen Hines37b74a32014-11-26 18:48:20 -080090class HexagonPLT1 : public PLT::Entry<sizeof(hexagon_plt1)> {
91 public:
Stephen Hinesf7ac0f12013-05-03 19:09:24 -070092 HexagonPLT1(SectionData& pParent);
93};
94
Stephen Hines37b74a32014-11-26 18:48:20 -080095} // namespace mcld
Stephen Hines6f757552013-03-04 19:51:03 -080096
Stephen Hines37b74a32014-11-26 18:48:20 -080097#endif // TARGET_HEXAGON_HEXAGONPLT_H_