From ac60575d78072c75f5c1ce799b16853c5dcdf84d Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Thu, 12 Dec 2024 17:33:54 -0800 Subject: [PATCH] fix calling convention preconditions Before this fix, the preconditions were too weak. In particular, in the case of a function which returns a large value on the stack, they allowed for a return value region in high memory that wraps around 0, potentially clobbering a stack in low memory. This fix strengthens the preconditions to forbid this. Signed-off-by: Nick Spinale --- logic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logic.py b/logic.py index 164dcb9a..67616bd8 100644 --- a/logic.py +++ b/logic.py @@ -156,7 +156,7 @@ def mk_eqs_arm_none_eabi_gnu (var_c_args, var_c_rets, c_imem, c_omem, init_save_seq = mk_stack_sequence (r0, 4, st, word32T, len (var_c_rets)) (_, last_arg_addr) = arg_seq[len (var_c_args) - 1] - preconds += [mk_less_eq (sp, addr) + preconds += [mk_less_eq (r0, addr) for (_, addr) in init_save_seq[-1:]] if last_arg_addr: preconds += [mk_less (last_arg_addr, addr)