-
Notifications
You must be signed in to change notification settings - Fork 126
Description
Description
-
Observation (high level) buf_test.tar.gz
I tried to use angr's one feature to resolve the source level variable. I provided a source code as an example, a binary I compiled using Makefile, and the corresponding Python script to trace the value of a local variable. I believe you can replay this directly. Let me know if the script does not work. -
Reasoning
From DAWRF 5 manual (page 61):
A full or partial compilation unit entry may have the following attributes:
1. Either a DW_AT_low_pc and DW_AT_high_pc pair of attributes or a
DW_AT_ranges attribute whose values encode the contiguous or
non-contiguous address ranges, respectively, of the machine instructions
generated for the compilation unit (see Section 2.17 on page 51).
There is no guarantee a compilation unit is contiguous, however, the class CompilationUnit requires the DWARF attributes including low_pc and high_pc. This implementation does not work in general. In my binary example, there is no compilation unit object for main.c. That is why no debug information after loading DWARF.
Alternatives
The binary I compiled is using -O2. The compilation unit could be contiguous address space if -O0 specifies. So I don't think this is a bug. This will be a new feature in angr cle if the CompilationUnit supports non-contiguous address ranges. Hopes you can add this feature on.
Additional context
You can check the debug info I exported:
<0><314>: Abbrev Number: 16 (DW_TAG_compile_unit)
<315> DW_AT_producer : (indirect string, offset: 0xa): GNU C17 11.4.0 -mtune=generic -march=x86-64 -g -O2 -fasynchronous-unwind-tables -fstack-protector-strong -fstack-clash-protection -fcf-protection
<319> DW_AT_language : 29 (C11)
<31a> DW_AT_name : (indirect line string, offset: 0xb3): main.c
<31e> DW_AT_comp_dir : (indirect line string, offset: 0x0): /home/yusen/angr/buf_test
<322> DW_AT_ranges : 0xc
<326> DW_AT_low_pc : 0x0
<32e> DW_AT_stmt_list : 0x136
This compile unit has DW_AT_ranges.