Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CompilationUnit only supports contiguous #466

Open
LinerSu opened this issue Apr 2, 2024 · 0 comments
Open

CompilationUnit only supports contiguous #466

LinerSu opened this issue Apr 2, 2024 · 0 comments

Comments

@LinerSu
Copy link

LinerSu commented Apr 2, 2024

Description

  1. 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.

  2. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant