From ed1b56b557fd01785d7d59bc36b3ad6fae0a1e91 Mon Sep 17 00:00:00 2001 From: Emil Kieri Date: Mon, 10 Feb 2025 10:53:15 +0100 Subject: [PATCH] arch: arm: cortex_a_r: Add cfi directives to z_arm_cortex_r_svc Add call frame information (cfi) directives to the function z_arm_cortex_r_svc, which triggers an SVC exception whose handler will execute a context switch. The return address stored on the stack of a suspended thread will point into z_arm_cortex_r_svc, that is, this function will be the starting point when a debugger tries to produce a call stack for a suspended thread. As the function is written in assembly, most compilers will not emit any cfi automatically. This patch adds cfi directives manually so that the call stack can be unwound. The added cfi directives instruct the compiler to note in the .debug_frame section that the canonical frame address is at offset 0 from r13, i.e., from the stack pointer. Signed-off-by: Emil Kieri --- arch/arm/core/cortex_a_r/swap_helper.S | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/core/cortex_a_r/swap_helper.S b/arch/arm/core/cortex_a_r/swap_helper.S index a41e1ab5942..04b19f0b046 100644 --- a/arch/arm/core/cortex_a_r/swap_helper.S +++ b/arch/arm/core/cortex_a_r/swap_helper.S @@ -423,5 +423,9 @@ valid_syscall_id: GTEXT(z_arm_cortex_r_svc) SECTION_FUNC(TEXT, z_arm_cortex_r_svc) + .cfi_sections .debug_frame + .cfi_startproc simple + .cfi_def_cfa 13, 0x0 svc #_SVC_CALL_CONTEXT_SWITCH bx lr + .cfi_endproc