Use reg from StorageManager instead of XR while loading args

When a function returns via arg pointer, the caller sets XR (x8) to
the address where the return value goes. We were sometimes using XR
as a temporary register while loading args, which lead to a segfault
when returning.

It will now request a general available register from StorageManager
instead.
This commit is contained in:
Agus Zubiaga 2023-10-04 14:58:29 -03:00 committed by Folkert
parent 905dc8cd59
commit 1021423e69
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -766,7 +766,8 @@ impl AArch64CallLoadArgs {
in_layout,
);
let tmp_reg = AArch64GeneralReg::XR;
let tmp_sym = Symbol::DEV_TMP;
let tmp_reg = storage_manager.claim_general_reg(buf, &tmp_sym);
super::x86_64::copy_to_base_offset::<_, _, AArch64Assembler>(
buf,
@ -777,6 +778,8 @@ impl AArch64CallLoadArgs {
0,
);
storage_manager.free_symbol(&tmp_sym);
self.general_i += 1;
}
None => {