Skip to content

ARC wrong .debug_frame #47985

Closed
zephyrproject-rtos/gcc
#9
@userid0x0

Description

@userid0x0

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:

  1. west build -b qemu_arc_em --pristine auto samples/synchronization

In order to inspect the file use e.g. objdump

  1. /arc-zephyr-elf-objdump --dwarf=frames build/zephyr/zephyr.elf

Or use TRACE32 for ARC Simulator e.g. R2022.02

  1. SYStem.CPU ARC-EM
  2. SYStem.Up
  3. Data.LOAD /build/zephyr/zephyr.elf
  4. sYmbol.List.FRAME

Impact
Prevents debugging.

Environment (please complete the following information):

  • OS: Linux
  • Toolchain: Zephyr SDK 0.14.2
  • Zephyr 3.1.0

Metadata

Metadata

Labels

area: ARCARC ArchitecturebugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions