Skip to content

Commit 1a8fec9

Browse files
committed
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 <duy.nguyen.xa@renesas.com>
1 parent ec31b35 commit 1a8fec9

File tree

1 file changed

+9
-0
lines changed
  • tests/ztest/error_hook/src

1 file changed

+9
-0
lines changed

tests/ztest/error_hook/src/main.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ __no_optimization static void trigger_fault_illegal_instruction(void)
5252

5353
/* execute an illegal instruction */
5454
((void(*)(void))&a)();
55+
#ifdef CONFIG_RX
56+
/*
57+
* Intentionally execute an illegal instruction by calling a NULL pointer.
58+
* Optimization is disabled to avoid GCC internal error during DWARF frame generation.
59+
* __builtin_unreachable() hints to the compiler that control flow never returns here,
60+
* which prevents faulty CFA emission on RX targets.
61+
*/
62+
__builtin_unreachable();
63+
#endif
5564
}
5665

5766
/*

0 commit comments

Comments
 (0)