From: Eli Bendersky Date: Sat, 25 May 2013 16:28:12 +0000 (-0700) Subject: More tweaks to succesfully parse an object file generated by gcc 4.8 with X-Git-Tag: v0.22~50 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9bf1b2d54bf74707674c07c9c060f20962d8a4e0;p=pyelftools.git More tweaks to succesfully parse an object file generated by gcc 4.8 with DWARFv4 --- diff --git a/CHANGES b/CHANGES index fe39abb..8a8bd2a 100644 --- a/CHANGES +++ b/CHANGES @@ -5,8 +5,8 @@ Changelog - Added some initial support for parsing Solaris OpenCSW ELF files (contributed by Yann Rouillard). - - Added some initial support for DWARF4 and DWARF generated by recent - versions of Clang. + - Added some initial support for DWARF4 (as generated by gcc 4.8) + and DWARF generated by recent versions of Clang (3.3). + Version 0.21 (17.04.2013) diff --git a/elftools/dwarf/descriptions.py b/elftools/dwarf/descriptions.py index 3a950a0..f46ef81 100644 --- a/elftools/dwarf/descriptions.py +++ b/elftools/dwarf/descriptions.py @@ -198,6 +198,9 @@ def _describe_attr_debool(attr, die, section_offset): return '1' if attr.value else '0' def _describe_attr_present(attr, die, section_offset): + """ Some forms may simply mean that an attribute is present, + without providing any value. + """ return '1' def _describe_attr_block(attr, die, section_offset): @@ -231,10 +234,8 @@ _ATTR_DESCRIPTION_MAP = defaultdict( DW_FORM_block4=_describe_attr_block, DW_FORM_block=_describe_attr_block, DW_FORM_flag_present=_describe_attr_present, - # Not sure how to print them - # DW_FORM_exprloc=_describe_attr_value_passthrough, - # DW_FORM_ref_sig8=_describe_attr_ref, - + DW_FORM_exprloc=_describe_attr_block, + DW_FORM_ref_sig8=_describe_attr_ref, ) diff --git a/elftools/dwarf/enums.py b/elftools/dwarf/enums.py index 2b00b2a..ee1ff7e 100644 --- a/elftools/dwarf/enums.py +++ b/elftools/dwarf/enums.py @@ -215,6 +215,15 @@ ENUM_DW_AT = dict( DW_AT_GNU_vector = 0x2107, DW_AT_GNU_template_name = 0x2110, + DW_AT_GNU_call_site_value = 0x2111, + DW_AT_GNU_call_site_data_value = 0x2112, + DW_AT_GNU_call_site_target = 0x2113, + DW_AT_GNU_call_site_target_clobbered = 0x2114, + DW_AT_GNU_tail_call = 0x2115, + DW_AT_GNU_all_tail_call_sites = 0x2116, + DW_AT_GNU_all_call_sites = 0x2117, + DW_AT_GNU_all_source_call_sites = 0x2118, + DW_AT_APPLE_optimized = 0x3fe1, DW_AT_APPLE_flags = 0x3fe2, DW_AT_APPLE_isa = 0x3fe3, diff --git a/elftools/dwarf/structs.py b/elftools/dwarf/structs.py index ffd662e..fb4074a 100644 --- a/elftools/dwarf/structs.py +++ b/elftools/dwarf/structs.py @@ -194,12 +194,11 @@ class DWARFStructs(object): DW_FORM_indirect=self.Dwarf_uleb128(''), + # New forms in DWARFv4 DW_FORM_flag_present = StaticField('', 0), - # Needs checkings - #DW_FORM_sec_offset = self.Dwarf_offset(''), - #DW_FORM_exprloc = self.Dwarf_uleb128(''), - #DW_FORM_ref_sig8 = self.Dwarf_offset(''), - + DW_FORM_sec_offset = self.Dwarf_offset(''), + DW_FORM_exprloc = self._make_block_struct(self.Dwarf_uleb128), + DW_FORM_ref_sig8 = self.Dwarf_offset(''), ) def _create_lineprog_header(self): diff --git a/test/testfiles_for_readelf/clang33-simple.o b/test/testfiles_for_readelf/clang33-simple.o new file mode 100644 index 0000000..d64d2ef Binary files /dev/null and b/test/testfiles_for_readelf/clang33-simple.o differ diff --git a/test/testfiles_for_readelf/gcc48-simple.o b/test/testfiles_for_readelf/gcc48-simple.o new file mode 100644 index 0000000..5eb04fa Binary files /dev/null and b/test/testfiles_for_readelf/gcc48-simple.o differ