add support for Arm64Call relocations in cranelift-jit

This commit is contained in:
Monadic Cat
2021-12-10 15:15:59 -06:00
parent da73952021
commit ad36df5495

View File

@@ -81,6 +81,17 @@ impl CompiledBlob {
write_unaligned(at as *mut i32, pcrel)
};
}
Reloc::Arm64Call => {
let base = get_address(name);
// The instruction is 32 bits long.
let iptr = at as *mut u32;
let diff = (base as isize) - (at as isize);
// The lower 26 bits of the `bl` instruction form the
// immediate offset argument.
let chop = 32 - 26;
let imm26 = ((diff >> 2) as u32) << chop >> chop;
unsafe { *iptr |= imm26; }
}
_ => unimplemented!(),
}
}