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

load_from_dwarf with a non-PIC executable fails to correctly set low_pc and high_pc for dvars #4547

Open
jornlp opened this issue Mar 28, 2024 · 0 comments
Assignees
Labels
bug Something is broken

Comments

@jornlp
Copy link

jornlp commented Mar 28, 2024

Description

I want to use dvars to retrieve the value of variables from my executable but this fails.
My executable is non-PIC I've cross_compiled on Mac using x86_64-linux-musl-gcc, so the base_addr should not be set.

state.dvars["myvar"] returns None even when it should return a value. It returns None as the address_range being checked (low_pc and high_pc) is not set correctly.

When running the following:

project.kb.dvars.load_from_dwarf()

the low_pc and high_pc are set incorrectly in debug_variables.py line 217:

low_pc = cle_var.lexical_block.low_pc + obj.mapped_base
high_pc = cle_var.lexical_block.high_pc + obj.mapped_base

I believe in this case either obj.mapped_base should be 0 or it should not be added to the low_pc/high_pc retrieved from dwarf info.

Steps to reproduce the bug

Compile a simple c file (e.g. example.c) with variables declared in a function using x86_64-linux-musl-gcc (it may be the case for any non-PIC executable).

Retrieve state.dvars["myvar"] after stepping into the function.

Environment

angr running on Mac on a cross-compiled binary:
using x86_64-linux-musl-gcc

Additional context

No response

@jornlp jornlp added bug Something is broken needs-triage Issue has yet to be looked at by a maintainer labels Mar 28, 2024
@ltfish ltfish removed the needs-triage Issue has yet to be looked at by a maintainer label Apr 2, 2024
@ltfish ltfish self-assigned this Apr 3, 2024
@jornlp jornlp changed the title load_from_dwarf with a PIC executable fails to correctly set low_pc and high_pc for dears load_from_dwarf with a PIC executable fails to correctly set low_pc and high_pc for dvars Apr 12, 2024
@jornlp jornlp changed the title load_from_dwarf with a PIC executable fails to correctly set low_pc and high_pc for dvars load_from_dwarf with a non-PIC executable fails to correctly set low_pc and high_pc for dvars Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

No branches or pull requests

2 participants