DWARF expression handling refactor

Cleanup logic of expression evaluation, stub out resolution of register
values to a callback in case we want to use constant propagation to try
to allow successful calculations, and add support for default static
values for treating an arch's stack frame register (e.g. RBP) like the
static CFA value we already have support for.

Add option to decorate params and local vars with their DWARF storage
location info.

Handle arrays with unspecified element type.
This commit is contained in:
dev747368 2025-08-11 11:21:28 -04:00
parent 483cd9a799
commit e908ab6fbf
42 changed files with 2517 additions and 1876 deletions

View file

@ -30,5 +30,24 @@
<!-- <register_mapping dwarf="68" ghidra="XMM16" auto_count="16"/> **not implemented yet** --> <!-- XMM16..XMM31 -->
<!-- <register_mapping dwarf="118" ghidra="K0" auto_count="8"/> **not implemented yet** -->
</register_mappings>
<!--
call_frame_cfa and stack_frame allow specifying static values for DWARF expressions that
calculate stack locations of params or variables, typically used in a func's
DW_AT_frame_base attribute (later referenced via a DW_OP_fbreg instruction),
or in param/variable DW_AT_location attributes.
Using these values is controlled by dwarf import options, but not settable by the user currently.
-->
<!--
call_frame_cfa specifies the static offset of the func's CFA, which
technically should be looked up in the func's CIE structs.
-->
<call_frame_cfa value="8"/>
<!--
stack_frame allows dwarf expressions that reference RBP to be converted to a ghidra stack
location without evaluating the actual RBP value via symbolic propagation.
-->
<stack_frame register="RBP" offset="-8" />
</dwarf>

View file

@ -30,5 +30,24 @@
<register_mapping dwarf="48" ghidra="TR"/>
<register_mapping dwarf="49" ghidra="LDTR"/>
</register_mappings>
<!--
call_frame_cfa and stack_frame allow specifying static values for DWARF expressions that
calculate stack locations of params or variables, typically used in a func's
DW_AT_frame_base attribute (later referenced via a DW_OP_fbreg instruction),
or in param/variable DW_AT_location attributes.
Using these values is controlled by dwarf import options, but not settable by the user currently.
-->
<!--
call_frame_cfa specifies the static offset of the func's CFA, which
technically should be looked up in the func's CIE structs.
-->
<call_frame_cfa value="4"/>
<!--
stack_frame allows dwarf expressions that reference EBP to be converted to a ghidra stack
location without evaluating the actual EBP value via symbolic propagation.
-->
<stack_frame register="EBP" offset="-4" />
</dwarf>