diff --git a/elftools/dwarf/datatype_cpp.py b/elftools/dwarf/datatype_cpp.py index ee82f024..55e1ae0c 100644 --- a/elftools/dwarf/datatype_cpp.py +++ b/elftools/dwarf/datatype_cpp.py @@ -12,7 +12,8 @@ cpp_symbols = dict( pointer = "*", reference = "&", - const = "const") + const = "const", + volatile = "volatile") def describe_cpp_datatype(var_die): return str(parse_cpp_datatype(var_die)) @@ -36,8 +37,8 @@ def parse_cpp_datatype(var_die): mods = [] # Unlike readelf, dwarfdump doesn't chase typedefs - while type_die.tag in ('DW_TAG_const_type', 'DW_TAG_pointer_type', 'DW_TAG_reference_type'): - modifier = _strip_type_tag(type_die) # const/reference/pointer + while type_die.tag in ('DW_TAG_const_type', 'DW_TAG_volatile_type', 'DW_TAG_pointer_type', 'DW_TAG_reference_type'): + modifier = _strip_type_tag(type_die) # const/volatile/reference/pointer mods.insert(0, modifier) if not 'DW_AT_type' in type_die.attributes: # void* is encoded as a pointer to nothing t.name = t.tag = "void" @@ -145,9 +146,9 @@ def __str__(self): mods = self.modifiers parts = [] - # Initial const applies to the var ifself, other consts apply to the pointee - if len(mods) and mods[0] == 'const': - parts.append("const") + # Initial const/volatile applies to the var ifself, other consts apply to the pointee + if len(mods) and mods[0] in ('const', 'volatile'): + parts.append(mods[0]) mods = mods[1:] # ref->const in the end, const goes in front diff --git a/test/testfiles_for_dwarfdump/dwarf_cpptype_volatile.elf b/test/testfiles_for_dwarfdump/dwarf_cpptype_volatile.elf new file mode 100644 index 00000000..38a45c59 Binary files /dev/null and b/test/testfiles_for_dwarfdump/dwarf_cpptype_volatile.elf differ