xref: /freebsd/contrib/llvm-project/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldELFMips.h (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
1*0b57cec5SDimitry Andric //===-- RuntimeDyldELFMips.h ---- ELF/Mips specific code. -------*- C++ -*-===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric 
9*0b57cec5SDimitry Andric #ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDELFMIPS_H
10*0b57cec5SDimitry Andric #define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDELFMIPS_H
11*0b57cec5SDimitry Andric 
12*0b57cec5SDimitry Andric #include "../RuntimeDyldELF.h"
13*0b57cec5SDimitry Andric 
14*0b57cec5SDimitry Andric #define DEBUG_TYPE "dyld"
15*0b57cec5SDimitry Andric 
16*0b57cec5SDimitry Andric namespace llvm {
17*0b57cec5SDimitry Andric 
18*0b57cec5SDimitry Andric class RuntimeDyldELFMips : public RuntimeDyldELF {
19*0b57cec5SDimitry Andric public:
20*0b57cec5SDimitry Andric 
21*0b57cec5SDimitry Andric   typedef uint64_t TargetPtrT;
22*0b57cec5SDimitry Andric 
RuntimeDyldELFMips(RuntimeDyld::MemoryManager & MM,JITSymbolResolver & Resolver)23*0b57cec5SDimitry Andric   RuntimeDyldELFMips(RuntimeDyld::MemoryManager &MM,
24*0b57cec5SDimitry Andric                      JITSymbolResolver &Resolver)
25*0b57cec5SDimitry Andric       : RuntimeDyldELF(MM, Resolver) {}
26*0b57cec5SDimitry Andric 
27*0b57cec5SDimitry Andric   void resolveRelocation(const RelocationEntry &RE, uint64_t Value) override;
28*0b57cec5SDimitry Andric 
29*0b57cec5SDimitry Andric protected:
30*0b57cec5SDimitry Andric   void resolveMIPSO32Relocation(const SectionEntry &Section, uint64_t Offset,
31*0b57cec5SDimitry Andric                                 uint32_t Value, uint32_t Type, int32_t Addend);
32*0b57cec5SDimitry Andric   void resolveMIPSN32Relocation(const SectionEntry &Section, uint64_t Offset,
33*0b57cec5SDimitry Andric                                 uint64_t Value, uint32_t Type, int64_t Addend,
34*0b57cec5SDimitry Andric                                 uint64_t SymOffset, SID SectionID);
35*0b57cec5SDimitry Andric   void resolveMIPSN64Relocation(const SectionEntry &Section, uint64_t Offset,
36*0b57cec5SDimitry Andric                                 uint64_t Value, uint32_t Type, int64_t Addend,
37*0b57cec5SDimitry Andric                                 uint64_t SymOffset, SID SectionID);
38*0b57cec5SDimitry Andric 
39*0b57cec5SDimitry Andric private:
40*0b57cec5SDimitry Andric   /// A object file specific relocation resolver
41*0b57cec5SDimitry Andric   /// \param RE The relocation to be resolved
42*0b57cec5SDimitry Andric   /// \param Value Target symbol address to apply the relocation action
43*0b57cec5SDimitry Andric   uint64_t evaluateRelocation(const RelocationEntry &RE, uint64_t Value,
44*0b57cec5SDimitry Andric                               uint64_t Addend);
45*0b57cec5SDimitry Andric 
46*0b57cec5SDimitry Andric   /// A object file specific relocation resolver
47*0b57cec5SDimitry Andric   /// \param RE The relocation to be resolved
48*0b57cec5SDimitry Andric   /// \param Value Target symbol address to apply the relocation action
49*0b57cec5SDimitry Andric   void applyRelocation(const RelocationEntry &RE, uint64_t Value);
50*0b57cec5SDimitry Andric 
51*0b57cec5SDimitry Andric   int64_t evaluateMIPS32Relocation(const SectionEntry &Section, uint64_t Offset,
52*0b57cec5SDimitry Andric                                    uint64_t Value, uint32_t Type);
53*0b57cec5SDimitry Andric   int64_t evaluateMIPS64Relocation(const SectionEntry &Section,
54*0b57cec5SDimitry Andric                                    uint64_t Offset, uint64_t Value,
55*0b57cec5SDimitry Andric                                    uint32_t Type,  int64_t Addend,
56*0b57cec5SDimitry Andric                                    uint64_t SymOffset, SID SectionID);
57*0b57cec5SDimitry Andric 
58*0b57cec5SDimitry Andric   void applyMIPSRelocation(uint8_t *TargetPtr, int64_t CalculatedValue,
59*0b57cec5SDimitry Andric                            uint32_t Type);
60*0b57cec5SDimitry Andric 
61*0b57cec5SDimitry Andric };
62*0b57cec5SDimitry Andric }
63*0b57cec5SDimitry Andric 
64*0b57cec5SDimitry Andric #undef DEBUG_TYPE
65*0b57cec5SDimitry Andric 
66*0b57cec5SDimitry Andric #endif
67