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

DWARFv1 constants in enums, DW_FORM_ref parsing #335

Merged
merged 9 commits into from
Oct 10, 2020
Merged

DWARFv1 constants in enums, DW_FORM_ref parsing #335

merged 9 commits into from
Oct 10, 2020

Conversation

sevaa
Copy link
Contributor

@sevaa sevaa commented Oct 8, 2020

A customer asked for support for DWARF v1.

Building support for DWARFv1 in pyelftools is probably not a fruitful endeavor, since many assumptions of DWARFv2+ break down in v1 (there is no abbrev table, no CU headers, expression and lineprogram format is different). I've already slapped together a DWARFv1 parser that mimics pyelftools and reuses some of its pieces.

That said, there are some DW_TAG_, DW_AT_, and DW_FORM_ constants that were deprecated in DWARFv2 but can be seen in the v1 spec, and also in my reference DWARFv1 binary. The enums are otherwise identical (modulo the shift-by-4 thing for attribute codes). I'd rather have those constants right there in pyelftools than patch the dicts on the fly.

If there is interest in having pyelftools support DWARFv1, let me know.

@sevaa sevaa changed the title Feature dwarf1constants DWARFv1 constants in enums, DW_AT_ref parsing Oct 8, 2020
@sevaa sevaa changed the title DWARFv1 constants in enums, DW_AT_ref parsing DWARFv1 constants in enums, DW_FORM_ref parsing Oct 8, 2020
@@ -106,7 +106,7 @@ def parse_from_attribute(self, attr, dwarf_version):

@staticmethod
def _attribute_has_loc_expr(attr, dwarf_version):
return ((dwarf_version < 4 and attr.form == 'DW_FORM_block1' and
return ((dwarf_version < 4 and attr.form.startswith('DW_FORM_block') and
Copy link
Owner

Choose a reason for hiding this comment

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

Is this correct?

The existing code seems to be specifically targeting DW_FORM_block1, not the other kinds; why is this changing? What new forms are needed for DWARFv1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Saw a location expression of formDW_FORM_block2 in the reference binary. There was no block1 in DWARF1, and no locations sections either.

If this is a dealbreaker, we can leave this one out and I'll monkeypatch.

@eliben
Copy link
Owner

eliben commented Oct 9, 2020

This PR seems mostly non-controversial, but general support for DWARF v1 is not planned.

@eliben eliben merged commit 9704150 into eliben:master Oct 10, 2020
@sevaa sevaa deleted the feature_dwarf1constants branch May 20, 2022 19:05
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