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

Wrong lookups for DWARF v5 filename #548

Open
c64cryptoboy opened this issue Jan 18, 2025 · 1 comment
Open

Wrong lookups for DWARF v5 filename #548

c64cryptoboy opened this issue Jan 18, 2025 · 1 comment
Labels

Comments

@c64cryptoboy
Copy link

c64cryptoboy commented Jan 18, 2025

Description

I think I've found a bug in (edit 1/20/25: pyelftools/examples/dwarf_decode_address.py) https://github.com/angr/cle/blob/master/cle/backends/elf/elf.py that leads to wrong filenames retrievals from DWARF v5 data.
I believe the "- 1" here:

line 668: file_entry = lineprog.header["file_entry"][line.state.file - 1]

should be a "- 0" when processing DWARF v5. (In the example I was looking at, the index became -1, which wrapped around to the last entry, giving a wrong filename.)

cle uses pyelftools. Here's an example directly from the pyelftools repo that gives me the answer I expect: https://github.com/eliben/pyelftools/blob/main/examples/dwarf_decode_address.py

From that example, here's the difference in logic from the cle implementation:

line 83:  delta = 1 if lineprog.header.version < 5 else 0
line 92:  filename = lineprog['file_entry'][prevstate.file - delta].name

Steps to reproduce the bug

No response

Environment

No response

Additional context

No response

@c64cryptoboy
Copy link
Author

Sorry, I pasted in the wrong path in the opening sentence (now fixed). The bug is in cle, not pyelftools.

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

No branches or pull requests

2 participants