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

False positive on LocationParser.attribute_has_location() #501

Merged
merged 5 commits into from
Sep 14, 2023

Conversation

sevaa
Copy link
Contributor

@sevaa sevaa commented Sep 13, 2023

The description of DW_AT_member_location changed between DWARFv2 and DWARFv3:

v2, section 5.5.4:

If the member entry is defined in the structure or class body, it has a
DW_AT_data_member_location attribute whose value is a location description

v3, section 5.5.6:

If a data member is defined in a structure, union or class, the corresponding member entry has a DW_AT_data_member_location attribute whose value describes the location of that member relative to the base address of the structure, union, or class that most closely encloses the member declaration. If that value is a constant, it is the offset in bytes from the beginning of the innermost enclosing structure, union or class to the beginning of the data member. Otherwise, the value must be a location description.

The case of DW_AT_data_member_location containing an integer constant is not handled by pyelftools - the method LocationParser.attribute_has_location() returns True, and it shouldn't.


I have a crash report where an attribute with the following data:

AttributeValue(name='DW_AT_data_member_location', form='DW_FORM_data1', value=0, raw_value=0, offset=402, indirection_length=0)

is being interpreted as a location list pointer (LocationParser.parse_from_attribute() tries to parse it), which in turn exceptions, because the binary doesn't contain a loclist section (self.location_lists is None).

@sevaa
Copy link
Contributor Author

sevaa commented Sep 14, 2023

While at it, also fixed a false negative in attribute_has_location() for the DWARFv5 counterparts of GNU_call_xxx attributes.

@sevaa
Copy link
Contributor Author

sevaa commented Sep 14, 2023

Done.

Copy link
Owner

@eliben eliben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@eliben eliben merged commit 07bdd57 into eliben:master Sep 14, 2023
3 checks passed
@sevaa sevaa deleted the fix_memberlocation branch September 14, 2023 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants