Incorrect DecodedCallFrameTable information
KelvinChung2000 opened this issue · comments
The following is the CIE/FDE information:
00000000 000000000000000c ffffffff CIE
Version: 3
Augmentation: ""
Code alignment factor: 1
Data alignment factor: -4
Return address column: 1
DW_CFA_def_cfa_register: r2 (sp)
DW_CFA_nop
00000010 000000000000002c 00000000 FDE cie=00000000 pc=00000000000108b8..00000000000109a0
DW_CFA_advance_loc: 4 to 00000000000108bc
DW_CFA_def_cfa_offset: 32
DW_CFA_advance_loc: 12 to 00000000000108c8
DW_CFA_offset: r9 (s1) at cfa-16
DW_CFA_offset: r18 (s2) at cfa-24
DW_CFA_offset: r8 (s0) at cfa-8
DW_CFA_advance_loc1: 200 to 0000000000010990
DW_CFA_restore: r8 (s0)
DW_CFA_advance_loc: 4 to 0000000000010994
DW_CFA_restore: r9 (s1)
DW_CFA_advance_loc: 4 to 0000000000010998
DW_CFA_restore: r18 (s2)
DW_CFA_advance_loc: 4 to 000000000001099c
DW_CFA_def_cfa_offset: 0
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
and the following DecodedCallFrameTable
is generated:
DecodedCallFrameTable(table=[{'pc': 67768, 'cfa': CFARule(reg=2, offset=0, expr=None)},
{'pc': 67772, 'cfa': CFARule(reg=2, offset=32, expr=None)},
{'pc': 67784, 'cfa': CFARule(reg=2, offset=32, expr=None),
9: RegisterRule(OFFSET, -16),
18: RegisterRule(OFFSET, -24),
8: RegisterRule(OFFSET, -8)},
{'pc': 67984, 'cfa': CFARule(reg=2, offset=32, expr=None),
9: RegisterRule(OFFSET, -16),
18: RegisterRule(OFFSET, -24)},
{'pc': 67988, 'cfa': CFARule(reg=2, offset=32, expr=None),
18: RegisterRule(OFFSET, -24)},
{'pc': 67992, 'cfa': CFARule(reg=2, offset=32, expr=None)},
{'pc': 67996, 'cfa': CFARule(reg=2, offset=0, expr=None)}], reg_order=[9, 18, 8])
we can see that the restore on reg8 is lost.
the code I used to get the DecodedCallFrameTable
def callFrameInfoExtract(filename: str):
with open(filename, "rb") as f:
elffile = ELFFile(f)
if not elffile.has_dwarf_info():
logging.debug(" file has no DWARF info")
raise
dwarfInfo = elffile.get_dwarf_info()
cfiEntry = dwarfInfo.CFI_entries()
for i in cfiEntry:
if isinstance(i, FDE):
print(i)
print(i.get_decoded())
break
This is the binary used. It is a RISC-V binary.
fft.zip