From 250465566b533de220d6ccbd341f6e2af62c6848 Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Tue, 17 Jun 2025 10:29:03 +0700 Subject: [PATCH] tests: error_hook: Workaround for RX architecture GCC for RX would crash with an internal compiler error during DWARF frame generation in `dwarf2out_frame_debug_adjust_cfa()` when compiling the `trigger_fault_illegal_instruction()` test function. This patch adds `__builtin_unreachable()` to help the compiler reason about control flow, preventing incorrect DWARF CFA generation. Signed-off-by: Duy Nguyen --- tests/ztest/error_hook/src/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/ztest/error_hook/src/main.c b/tests/ztest/error_hook/src/main.c index e4b05fc3eb0..325f931a62d 100644 --- a/tests/ztest/error_hook/src/main.c +++ b/tests/ztest/error_hook/src/main.c @@ -52,6 +52,15 @@ __no_optimization static void trigger_fault_illegal_instruction(void) /* execute an illegal instruction */ ((void(*)(void))&a)(); +#ifdef CONFIG_RX + /* + * Intentionally execute an illegal instruction by calling a NULL pointer. + * Optimization is disabled to avoid GCC internal error during DWARF frame generation. + * __builtin_unreachable() hints to the compiler that control flow never returns here, + * which prevents faulty CFA emission on RX targets. + */ + __builtin_unreachable(); +#endif } /*