From: emersion Date: Tue, 6 Mar 2018 13:16:41 +0000 (+0100) Subject: Fix DW_CFA_remember_state (#184) X-Git-Tag: v0.25~9 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b688d001ee77e7c8ca536ced974ef713424c11e2;p=pyelftools.git Fix DW_CFA_remember_state (#184) * Fix #103 * Fix description for DW_CFA_def_cfa_expression * Add test file for issue #103 --- diff --git a/elftools/dwarf/callframe.py b/elftools/dwarf/callframe.py index e64c745..bcef78d 100644 --- a/elftools/dwarf/callframe.py +++ b/elftools/dwarf/callframe.py @@ -567,9 +567,11 @@ class CFIEntry(object): else: cur_line.pop(instr.args[0], None) elif name == 'DW_CFA_remember_state': - line_stack.append(cur_line) + line_stack.append(copy.deepcopy(cur_line)) elif name == 'DW_CFA_restore_state': + pc = cur_line['pc'] cur_line = line_stack.pop() + cur_line['pc'] = pc # The current line is appended to the table after all instructions # have ended, if there were instructions. diff --git a/elftools/dwarf/descriptions.py b/elftools/dwarf/descriptions.py index 3a07607..eb20333 100644 --- a/elftools/dwarf/descriptions.py +++ b/elftools/dwarf/descriptions.py @@ -104,7 +104,8 @@ def describe_CFI_instructions(entry): elif name == 'DW_CFA_def_cfa_expression': expr_dumper = ExprDumper(entry.structs) expr_dumper.process_expr(instr.args[0]) - s += ' %s: (%s)\n' % (name, expr_dumper.get_str()) + # readelf output is missing a colon for DW_CFA_def_cfa_expression + s += ' %s (%s)\n' % (name, expr_dumper.get_str()) elif name == 'DW_CFA_expression': expr_dumper = ExprDumper(entry.structs) expr_dumper.process_expr(instr.args[1]) diff --git a/test/testfiles_for_readelf/issue103.elf b/test/testfiles_for_readelf/issue103.elf new file mode 100644 index 0000000..8c37a7c Binary files /dev/null and b/test/testfiles_for_readelf/issue103.elf differ