#include "llvm/ExecutionEngine/JITLink/aarch32.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/ExecutionEngine/JITLink/JITLink.h"
#include "llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MathExtras.h"
#define DEBUG_TYPE …
namespace llvm {
namespace jitlink {
namespace aarch32 {
bool hasTargetFlags(Symbol &Sym, TargetFlagsType Flags) { … }
HalfWords encodeImmBT4BlT1BlxT2(int64_t Value) { … }
int64_t decodeImmBT4BlT1BlxT2(uint32_t Hi, uint32_t Lo) { … }
HalfWords encodeImmBT4BlT1BlxT2_J1J2(int64_t Value) { … }
int64_t decodeImmBT4BlT1BlxT2_J1J2(uint32_t Hi, uint32_t Lo) { … }
uint32_t encodeImmBA1BlA1BlxA2(int64_t Value) { … }
int64_t decodeImmBA1BlA1BlxA2(int64_t Value) { … }
HalfWords encodeImmMovtT1MovwT3(uint16_t Value) { … }
uint16_t decodeImmMovtT1MovwT3(uint32_t Hi, uint32_t Lo) { … }
HalfWords encodeRegMovtT1MovwT3(int64_t Value) { … }
int64_t decodeRegMovtT1MovwT3(uint32_t Hi, uint32_t Lo) { … }
uint32_t encodeImmMovtA1MovwA2(uint16_t Value) { … }
uint16_t decodeImmMovtA1MovwA2(uint64_t Value) { … }
uint32_t encodeRegMovtA1MovwA2(int64_t Value) { … }
int64_t decodeRegMovtA1MovwA2(uint64_t Value) { … }
namespace {
struct WritableThumbRelocation { … };
struct ThumbRelocation { … };
struct WritableArmRelocation { … };
struct ArmRelocation { … };
Error makeUnexpectedOpcodeError(const LinkGraph &G, const ThumbRelocation &R,
Edge::Kind Kind) { … }
Error makeUnexpectedOpcodeError(const LinkGraph &G, const ArmRelocation &R,
Edge::Kind Kind) { … }
template <EdgeKind_aarch32 K> constexpr bool isArm() { … }
template <EdgeKind_aarch32 K> constexpr bool isThumb() { … }
template <EdgeKind_aarch32 K> static bool checkOpcodeArm(uint32_t Wd) { … }
template <EdgeKind_aarch32 K>
static bool checkOpcodeThumb(uint16_t Hi, uint16_t Lo) { … }
class FixupInfoTable { … };
ManagedStatic<FixupInfoTable> DynFixupInfos;
}
static Error checkOpcode(LinkGraph &G, const ArmRelocation &R,
Edge::Kind Kind) { … }
static Error checkOpcode(LinkGraph &G, const ThumbRelocation &R,
Edge::Kind Kind) { … }
const FixupInfoBase *FixupInfoBase::getDynFixupInfo(Edge::Kind K) { … }
template <EdgeKind_aarch32 Kind>
bool checkRegister(const ThumbRelocation &R, HalfWords Reg) { … }
template <EdgeKind_aarch32 Kind>
bool checkRegister(const ArmRelocation &R, uint32_t Reg) { … }
template <EdgeKind_aarch32 Kind>
void writeRegister(WritableThumbRelocation &R, HalfWords Reg) { … }
template <EdgeKind_aarch32 Kind>
void writeRegister(WritableArmRelocation &R, uint32_t Reg) { … }
template <EdgeKind_aarch32 Kind>
void writeImmediate(WritableThumbRelocation &R, HalfWords Imm) { … }
template <EdgeKind_aarch32 Kind>
void writeImmediate(WritableArmRelocation &R, uint32_t Imm) { … }
Expected<int64_t> readAddendData(LinkGraph &G, Block &B, Edge::OffsetT Offset,
Edge::Kind Kind) { … }
Expected<int64_t> readAddendArm(LinkGraph &G, Block &B, Edge::OffsetT Offset,
Edge::Kind Kind) { … }
Expected<int64_t> readAddendThumb(LinkGraph &G, Block &B, Edge::OffsetT Offset,
Edge::Kind Kind, const ArmConfig &ArmCfg) { … }
Error applyFixupData(LinkGraph &G, Block &B, const Edge &E) { … }
Error applyFixupArm(LinkGraph &G, Block &B, const Edge &E) { … }
Error applyFixupThumb(LinkGraph &G, Block &B, const Edge &E,
const ArmConfig &ArmCfg) { … }
const uint8_t GOTEntryInit[] = …;
template <size_t Size>
static Block &allocPointer(LinkGraph &G, Section &S,
const uint8_t (&Content)[Size]) { … }
Symbol &GOTBuilder::createEntry(LinkGraph &G, Symbol &Target) { … }
bool GOTBuilder::visitEdge(LinkGraph &G, Block *B, Edge &E) { … }
const uint8_t ArmThumbv5LdrPc[] = …;
const uint8_t Armv7ABS[] = …;
const uint8_t Thumbv7ABS[] = …;
template <size_t Size>
static Block &allocStub(LinkGraph &G, Section &S, const uint8_t (&Code)[Size]) { … }
static Block &createStubPrev7(LinkGraph &G, Section &S, Symbol &Target) { … }
static Block &createStubThumbv7(LinkGraph &G, Section &S, Symbol &Target) { … }
static Block &createStubArmv7(LinkGraph &G, Section &S, Symbol &Target) { … }
static bool needsStub(const Edge &E) { … }
Symbol *StubsManager_prev7::getOrCreateSlotEntrypoint(LinkGraph &G,
StubMapEntry &Slot,
bool Thumb) { … }
bool StubsManager_prev7::visitEdge(LinkGraph &G, Block *B, Edge &E) { … }
bool StubsManager_v7::visitEdge(LinkGraph &G, Block *B, Edge &E) { … }
const char *getEdgeKindName(Edge::Kind K) { … }
const char *getCPUArchName(ARMBuildAttrs::CPUArch K) { … }
}
}
}