pub unsafe fn perform_relocations(
code: *mut u8,
code_rx: *const u8,
relocs: &[AsmReloc],
get_address: impl Fn(&RelocTarget) -> *const u8,
get_got_entry: impl Fn(&RelocTarget) -> *const u8,
get_plt_entry: impl Fn(&RelocTarget) -> *const u8,
)Expand description
A generic implementation of relocation resolving.
§NOTE
Very simple and incomplete. At the moment only Abs4, Abs8, X86 and RISC-V GOT relocations are supported.
§Safety
Code and code_rx must be valid pointers to the beginning of the code section. They are used to compute the addresses of the instructions to patch.
get_address, get_got_entry and get_plt_entry must return valid pointers to the target addresses for the given relocation targets.