DWARFv1 constants in enums, DW_FORM_ref parsing (#335)
authorSeva Alekseyev <sevaa@yarxi.ru>
Sat, 10 Oct 2020 12:38:13 +0000 (08:38 -0400)
committerGitHub <noreply@github.com>
Sat, 10 Oct 2020 12:38:13 +0000 (05:38 -0700)
elftools/dwarf/enums.py
elftools/dwarf/locationlists.py
elftools/dwarf/structs.py

index 9ff90d7ab100153cd991b72eb3822f68bd816c2c..c90086726681ec373b31e65d7e4cac5694e94a56 100644 (file)
@@ -17,15 +17,19 @@ ENUM_DW_TAG = dict(
     DW_TAG_entry_point                 = 0x03,
     DW_TAG_enumeration_type            = 0x04,
     DW_TAG_formal_parameter            = 0x05,
+    DW_TAG_global_subroutine           = 0x06,
+    DW_TAG_global_variable             = 0x07,
     DW_TAG_imported_declaration        = 0x08,
     DW_TAG_label                       = 0x0a,
     DW_TAG_lexical_block               = 0x0b,
+    DW_TAG_local_variable              = 0x0c,
     DW_TAG_member                      = 0x0d,
     DW_TAG_pointer_type                = 0x0f,
     DW_TAG_reference_type              = 0x10,
     DW_TAG_compile_unit                = 0x11,
     DW_TAG_string_type                 = 0x12,
     DW_TAG_structure_type              = 0x13,
+    DW_TAG_subroutine                  = 0x14,
     DW_TAG_subroutine_type             = 0x15,
     DW_TAG_typedef                     = 0x16,
     DW_TAG_union_type                  = 0x17,
@@ -111,6 +115,10 @@ ENUM_DW_AT = dict(
     DW_AT_sibling                   = 0x01,
     DW_AT_location                  = 0x02,
     DW_AT_name                      = 0x03,
+    DW_AT_fund_type                 = 0x05,
+    DW_AT_mod_fund_type             = 0x06,
+    DW_AT_user_def_type             = 0x07,
+    DW_AT_mod_u_d_type              = 0x08,
     DW_AT_ordering                  = 0x09,
     DW_AT_subscr_data               = 0x0a,
     DW_AT_byte_size                 = 0x0b,
@@ -136,7 +144,9 @@ ENUM_DW_AT = dict(
     DW_AT_is_optional               = 0x21,
     DW_AT_lower_bound               = 0x22,
     DW_AT_producer                  = 0x25,
+    DW_AT_protected                 = 0x26,
     DW_AT_prototyped                = 0x27,
+    DW_AT_public                    = 0x28,
     DW_AT_return_addr               = 0x2a,
     DW_AT_start_scope               = 0x2c,
     DW_AT_bit_stride                = 0x2e,
@@ -304,6 +314,7 @@ ENUM_DW_AT = dict(
 ENUM_DW_FORM = dict(
     DW_FORM_null                = 0x00,
     DW_FORM_addr                = 0x01,
+    DW_FORM_ref                 = 0x02,
     DW_FORM_block2              = 0x03,
     DW_FORM_block4              = 0x04,
     DW_FORM_data2               = 0x05,
index a503e43d07a8c365ff8d962258e388112ab65638..e6c735f585e3a94f63d4cb9f148786d553f5ea29 100644 (file)
@@ -106,7 +106,7 @@ class LocationParser(object):
 
     @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
             not attr.name == 'DW_AT_const_value') or
             attr.form == 'DW_FORM_exprloc')
 
index 04f6c75d662656dbd8be29ff40f4d626a2858332..95130531ac831fb5eec912b4e1e6ae1382fa7085 100644 (file)
@@ -195,6 +195,7 @@ class DWARFStructs(object):
             DW_FORM_strp=self.Dwarf_offset(''),
             DW_FORM_flag=self.Dwarf_uint8(''),
 
+            DW_FORM_ref=self.Dwarf_uint32(''),
             DW_FORM_ref1=self.Dwarf_uint8(''),
             DW_FORM_ref2=self.Dwarf_uint16(''),
             DW_FORM_ref4=self.Dwarf_uint32(''),