• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- AArch64LongBranchStub.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 //===----------------------------------------------------------------------===//
9 #ifndef TARGET_AARCH64_AARCH64LONGBRANCHSTUB_H_
10 #define TARGET_AARCH64_AARCH64LONGBRANCHSTUB_H_
11 
12 #include "mcld/Fragment/Stub.h"
13 #include "mcld/Support/Compiler.h"
14 #include <llvm/Support/DataTypes.h>
15 #include <string>
16 #include <vector>
17 
18 namespace mcld {
19 
20 class BranchIsland;
21 class IRBuilder;
22 class Relocation;
23 
24 class AArch64LongBranchStub : public Stub {
25  public:
26   explicit AArch64LongBranchStub(bool pIsOutputPIC);
27 
28   ~AArch64LongBranchStub();
29 
30   bool isMyDuty(const Relocation& pReloc,
31                 uint64_t pSource,
32                 uint64_t pTargetSymValue) const;
33 
34   void applyFixup(Relocation& pSrcReloc,
35                   IRBuilder& pBuilder,
36                   BranchIsland& pIsland);
37 
38   const std::string& name() const;
39 
40   const uint8_t* getContent() const;
41 
42   size_t size() const;
43 
44   size_t alignment() const;
45 
46  private:
47   /// for doClone
48   AArch64LongBranchStub(const uint32_t* pData,
49                         size_t pSize,
50                         const_fixup_iterator pBegin,
51                         const_fixup_iterator pEnd);
52 
53   /// doClone
54   Stub* doClone();
55 
56  private:
57   static const uint32_t PIC_TEMPLATE[];
58   static const uint32_t TEMPLATE[];
59   static const uint32_t ADRP_TEMPLATE[];
60   const uint32_t* m_pData;
61   std::string m_Name;
62   size_t m_Size;
63 
64  private:
65   DISALLOW_IMPLICIT_CONSTRUCTORS(AArch64LongBranchStub);
66 };
67 
68 }  // namespace mcld
69 
70 #endif  // TARGET_AARCH64_AARCH64LONGBRANCHSTUB_H_
71