[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gas/31733] New: [RISCV] Generating a wrong initial CFI instruction
From: |
sfoon.kim at samsung dot com |
Subject: |
[Bug gas/31733] New: [RISCV] Generating a wrong initial CFI instruction |
Date: |
Mon, 13 May 2024 06:47:04 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=31733
Bug ID: 31733
Summary: [RISCV] Generating a wrong initial CFI instruction
Product: binutils
Version: 2.43 (HEAD)
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gas
Assignee: unassigned at sourceware dot org
Reporter: sfoon.kim at samsung dot com
Target Milestone: ---
I've found a bug when GAS generates an initial CFI instruction.
I think it is not an explicit bug, but it follows an old DWARF spec.
See the following lines:
$ cat test.c
int main(void)
{
return 0;
}
$ riscv64-linux-gnu-gcc test.c
$ readelf --debug=frames a.out
Contents of the .eh_frame section:
00000000 0000000000000010 00000000 CIE
Version: 3
Augmentation: "zR"
Code alignment factor: 1
Data alignment factor: -4
Return address column: 1
Augmentation data: 1b
DW_CFA_def_cfa_register: r2 (sp)
DW_CFA_nop
//...
The problem exists in `DW_CFA_def_cfa_register`.
An old DWARF 2.0 spec said about `DW_CFA_def_cfa_register` as follows [1]:
DW_CFA_def_cfa_register takes a single unsigned LEB128 argument representing a
register number. The required action is to define the current CFA rule to use
the provided register (but to keep the old offset).
While a newer DWARF spec (since 4.0) said as follows [2]:
The DW_CFA_def_cfa_register instruction takes a single unsigned LEB128 operand
representing a register number. The required action is to define the current
CFA rule to use the provided register (but to keep the old offset). This
operation is valid only if the current CFA rule is defined to use a register
and offset.
The last added statement in the newer spec said that the operation requires a
definition operation before using it.
DW_CFA_def_cfa_register makes a failure in stack unwinding when the application
uses a third-party library like libunwindstack in Android.
I think DW_CFA_def_cfa is more suitable for an initial CFI instruction than
DW_CFA_def_cfa_register to follow the newer version of DWARF spec.
Sung-hun Kim.
[1] https://dwarfstd.org/doc/dwarf-2.0.0.pdf
[2] https://dwarfstd.org/doc/DWARF5.pdf
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug gas/31733] New: [RISCV] Generating a wrong initial CFI instruction,
sfoon.kim at samsung dot com <=