backend/rv64: Adjust how relocations are stored

This commit is contained in:
Yang Liu 2024-01-07 20:05:41 +08:00 committed by Merry
parent c90c4d48d2
commit c47dacb1de
2 changed files with 9 additions and 3 deletions

View file

@ -26,7 +26,7 @@ EmittedBlockInfo EmitRV64(biscuit::Assembler& as, [[maybe_unused]] IR::Block blo
as.SW(a0, offsetof(A32JitState, regs) + 15 * sizeof(u32), a1); as.SW(a0, offsetof(A32JitState, regs) + 15 * sizeof(u32), a1);
ptrdiff_t offset = reinterpret_cast<CodePtr>(as.GetCursorPointer()) - ebi.entry_point; ptrdiff_t offset = reinterpret_cast<CodePtr>(as.GetCursorPointer()) - ebi.entry_point;
ebi.relocations[offset] = LinkTarget::ReturnFromRunCode; ebi.relocations.emplace_back(Relocation{offset, LinkTarget::ReturnFromRunCode});
as.NOP(); as.NOP();
ebi.size = reinterpret_cast<CodePtr>(as.GetCursorPointer()) - ebi.entry_point; ebi.size = reinterpret_cast<CodePtr>(as.GetCursorPointer()) - ebi.entry_point;

View file

@ -5,8 +5,9 @@
#pragma once #pragma once
#include <vector>
#include <mcl/stdint.hpp> #include <mcl/stdint.hpp>
#include <tsl/robin_map.h>
namespace biscuit { namespace biscuit {
class Assembler; class Assembler;
@ -24,10 +25,15 @@ enum class LinkTarget {
ReturnFromRunCode, ReturnFromRunCode,
}; };
struct Relocation {
std::ptrdiff_t code_offset;
LinkTarget target;
};
struct EmittedBlockInfo { struct EmittedBlockInfo {
CodePtr entry_point; CodePtr entry_point;
size_t size; size_t size;
tsl::robin_map<std::ptrdiff_t, LinkTarget> relocations; std::vector<Relocation> relocations;
}; };
EmittedBlockInfo EmitRV64(biscuit::Assembler& as, IR::Block block); EmittedBlockInfo EmitRV64(biscuit::Assembler& as, IR::Block block);