Browse Source

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>
pull/92244/head
Duy Nguyen 3 weeks ago committed by Benjamin Cabé
parent
commit
250465566b
  1. 9
      tests/ztest/error_hook/src/main.c

9
tests/ztest/error_hook/src/main.c

@ -52,6 +52,15 @@ __no_optimization static void trigger_fault_illegal_instruction(void) @@ -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
}
/*

Loading…
Cancel
Save