Browse Source

elf_mem_map: decode correctly void pointers

Yuri D'Elia 2 years ago
parent
commit
4c6339ac46
1 changed files with 7 additions and 3 deletions
  1. 7 3
      tools/elf_mem_map

+ 7 - 3
tools/elf_mem_map

@@ -47,11 +47,15 @@ def get_elf_globals(path):
             # variable name
             name = DIE.attributes['DW_AT_name'].value.decode('ascii')
 
-            # recurse on type to find the leaf definition
+            # recurse on type to find the final storage definition
             type_DIE = DIE
-            while 'DW_AT_type' in type_DIE.attributes:
+            byte_size = None
+            while True:
+                if 'DW_AT_byte_size' in type_DIE.attributes:
+                    byte_size = type_DIE.attributes.get('DW_AT_byte_size')
+                if 'DW_AT_type' not in type_DIE.attributes:
+                    break
                 type_DIE = type_DIE.get_DIE_from_attribute('DW_AT_type')
-            byte_size = type_DIE.attributes.get('DW_AT_byte_size')
             if byte_size is None:
                 continue
             size = byte_size.value