Function fault_crate_swap::constant_offset_fix
source · pub fn constant_offset_fix(
swap_ranges: &SwapRanges,
bottom: usize,
top: usize
) -> Result<(), String>
Expand description
A support function for self swap of crate
Iterates through a given set of address from top to bottom and
checks whether they fall within the range of an old crate and
shifts them by a constant offset to map them to correct region
in the new crate.
Fix is as follows if virtual address matches.
new_address
= old_address
- start_address_of_old_text_region
+ start_address_of_new_text_region
.
Address ranges are provided via SwapRanges
struct.
Uses unsafe logic for pointer manipulation