Description
Describe the bug
With optimizationlevel -Os the ARC GCC 10.3.0 of the Zephyr SDK generates .debug_frame information with wrong polarity. I observed the following behavior. With "-Os" the instruction enter_s
is used. For these instructions the .debug_frame creates information like
RET:BLINK CFA:SP+0x8 R13:*CFA+0x8 R14:*CFA+0x4
(increment the SP by 0x8=CFA, in order to find the stacked R13 increment the CFA again by 0x8)
but it should be
RET:BLINK CFA:SP+0x8 R13:*CFA-0x8 R14:*CFA-0x4
as the stacked data should be within the CFA not outside. When the compiler generates e.g. push_s
instructions the .debug_frame information is correct.
The behavior is detected using a TRACE32 debugger and confirmed by objdump. For TRACE32 the wrong .debug_frame prevents an successful callstack unwind.
Workarounds detected: use lower optimization levels -O0/-O1/-Og/-O2
To Reproduce
Steps to reproduce the behavior:
- west build -b qemu_arc_em --pristine auto samples/synchronization
In order to inspect the file use e.g. objdump
- /arc-zephyr-elf-objdump --dwarf=frames build/zephyr/zephyr.elf
Or use TRACE32 for ARC Simulator e.g. R2022.02
- SYStem.CPU ARC-EM
- SYStem.Up
- Data.LOAD /build/zephyr/zephyr.elf
- sYmbol.List.FRAME
Impact
Prevents debugging.
Environment (please complete the following information):
- OS: Linux
- Toolchain: Zephyr SDK 0.14.2
- Zephyr 3.1.0