#include "llvm/ExecutionEngine/JITLink/ELF_riscv.h"
#include "EHFrameSupportImpl.h"
#include "ELFLinkGraphBuilder.h"
#include "JITLinkGeneric.h"
#include "PerGraphGOTAndPLTStubsBuilder.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/ExecutionEngine/JITLink/DWARFRecordSectionSplitter.h"
#include "llvm/ExecutionEngine/JITLink/JITLink.h"
#include "llvm/ExecutionEngine/JITLink/riscv.h"
#include "llvm/Object/ELF.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Support/Endian.h"
#define DEBUG_TYPE …
usingnamespacellvm;
usingnamespacellvm::jitlink;
usingnamespacellvm::jitlink::riscv;
namespace {
class PerGraphGOTAndPLTStubsBuilder_ELF_riscv
: public PerGraphGOTAndPLTStubsBuilder<
PerGraphGOTAndPLTStubsBuilder_ELF_riscv> { … };
const uint8_t PerGraphGOTAndPLTStubsBuilder_ELF_riscv::NullGOTEntryContent[8] = …;
const uint8_t
PerGraphGOTAndPLTStubsBuilder_ELF_riscv::RV64StubContent[StubEntrySize] = …;
const uint8_t
PerGraphGOTAndPLTStubsBuilder_ELF_riscv::RV32StubContent[StubEntrySize] = …;
}
namespace llvm {
namespace jitlink {
static uint32_t extractBits(uint32_t Num, unsigned Low, unsigned Size) { … }
static inline bool isAlignmentCorrect(uint64_t Value, int N) { … }
static inline bool isInRangeForImm(int64_t Value, int N) { … }
class ELFJITLinker_riscv : public JITLinker<ELFJITLinker_riscv> { … };
namespace {
struct SymbolAnchor { … };
struct BlockRelaxAux { … };
struct RelaxConfig { … };
struct RelaxAux { … };
}
static bool shouldRelax(const Section &S) { … }
static bool isRelaxable(const Edge &E) { … }
static RelaxAux initRelaxAux(LinkGraph &G) { … }
static void relaxAlign(orc::ExecutorAddr Loc, const Edge &E, uint32_t &Remove,
Edge::Kind &NewEdgeKind) { … }
static void relaxCall(const Block &B, BlockRelaxAux &Aux,
const RelaxConfig &Config, orc::ExecutorAddr Loc,
const Edge &E, uint32_t &Remove,
Edge::Kind &NewEdgeKind) { … }
static bool relaxBlock(LinkGraph &G, Block &Block, BlockRelaxAux &Aux,
const RelaxConfig &Config) { … }
static bool relaxOnce(LinkGraph &G, RelaxAux &Aux) { … }
static void finalizeBlockRelax(LinkGraph &G, Block &Block, BlockRelaxAux &Aux) { … }
static void finalizeRelax(LinkGraph &G, RelaxAux &Aux) { … }
static Error relax(LinkGraph &G) { … }
template <typename ELFT>
class ELFLinkGraphBuilder_riscv : public ELFLinkGraphBuilder<ELFT> { … };
Expected<std::unique_ptr<LinkGraph>>
createLinkGraphFromELFObject_riscv(MemoryBufferRef ObjectBuffer) { … }
void link_ELF_riscv(std::unique_ptr<LinkGraph> G,
std::unique_ptr<JITLinkContext> Ctx) { … }
LinkGraphPassFunction createRelaxationPass_ELF_riscv() { … }
}
}