More tweaks to succesfully parse an object file generated by gcc 4.8 with
authorEli Bendersky <eliben@gmail.com>
Sat, 25 May 2013 16:28:12 +0000 (09:28 -0700)
committerEli Bendersky <eliben@gmail.com>
Sat, 25 May 2013 16:28:12 +0000 (09:28 -0700)
DWARFv4

CHANGES
elftools/dwarf/descriptions.py
elftools/dwarf/enums.py
elftools/dwarf/structs.py
test/testfiles_for_readelf/clang33-simple.o [new file with mode: 0644]
test/testfiles_for_readelf/gcc48-simple.o [new file with mode: 0644]

diff --git a/CHANGES b/CHANGES
index fe39abb1281962eb7de3b54819f7bfd0bc3ca479..8a8bd2aa4e459526606e738beb76a790a1dfe574 100644 (file)
--- 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)
 
index 3a950a01a0cb7122f1e1cd5581bad69105d6c0b9..f46ef810ed045a9eec8d68930413cf75356ea42d 100644 (file)
@@ -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,
 )
 
 
index 2b00b2a48abc43bfd3eedca7e91f33304b4436c2..ee1ff7ef3c9e7230e2fccf8aadf9e283634ba9eb 100644 (file)
@@ -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,
index ffd662ef2a2b46622f8cba220ad4373c1036028f..fb4074a096cf6c911623cc963039211a24468142 100644 (file)
@@ -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 (file)
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 (file)
index 0000000..5eb04fa
Binary files /dev/null and b/test/testfiles_for_readelf/gcc48-simple.o differ