]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Update acceptable forms and attributes for dwarf_getlocation.
authorMark Wielaard <mark@klomp.org>
Thu, 2 Nov 2017 15:24:17 +0000 (16:24 +0100)
committerMark Wielaard <mark@klomp.org>
Fri, 10 Nov 2017 15:36:01 +0000 (16:36 +0100)
dwarf_getlocation has to know which attributes can contain a DWARF
expression or location list because the form alone might be ambiguous.

Since DWARF4 there is DW_FORM_exprloc so always accept that. But for older
DWARF or location lists we cannot just check for DW_FORM_sec_offset since
that could be a reference to diffent kinds of sections (based on attribute).

Update the attribute list based on the latest DWARF5 encodings table.
Note that DW_AT_call_origin wasn't added because that seems to be a
typo in the DWARF5 spec. http://dwarfstd.org/ShowIssue.php?issue=171103.1

Signed-off-by: Mark Wielaard <mark@klomp.org>
libdw/ChangeLog
libdw/dwarf_getlocation.c

index 70856498a46adce5613e08aad735fd553ffe317a..bb9e8499501eca853074a56c282a88e387e4aa02 100644 (file)
@@ -1,3 +1,8 @@
+2017-11-03  Mark Wielaard  <mark@klomp.org>
+
+       * dwarf_getlocation.c (attr_ok): Always accept DW_FORM_exprloc.
+       Update list of acceptable attribute codes based on DWARF5.
+
 2017-11-03  Mark Wielaard  <mark@klomp.org>
 
        * dwarf.h: Add DW_OP_GNU_variable_value.
index a4a2761eed625e22a806b176ab4f2c7a647282d0..c59546e0d74f647f93011bb9e5e883c71468fd37 100644 (file)
@@ -45,10 +45,34 @@ attr_ok (Dwarf_Attribute *attr)
   if (attr == NULL)
     return false;
 
-  /* Must be one of the attributes listed below.  */
+  /* If it is an exprloc, it is obviously OK.  */
+  if (dwarf_whatform (attr) == DW_FORM_exprloc)
+    return true;
+
+  /* Otherwise must be one of the attributes listed below.  Older
+     DWARF versions might have encoded the exprloc as block, and we
+     cannot easily distinquish attributes in the loclist class because
+     the same forms are used for different classes.  */
   switch (attr->code)
     {
     case DW_AT_location:
+    case DW_AT_byte_size:
+    case DW_AT_bit_offset:
+    case DW_AT_bit_size:
+    case DW_AT_lower_bound:
+    case DW_AT_bit_stride:
+    case DW_AT_upper_bound:
+    case DW_AT_count:
+    case DW_AT_allocated:
+    case DW_AT_associated:
+    case DW_AT_data_location:
+    case DW_AT_byte_stride:
+    case DW_AT_rank:
+    case DW_AT_call_value:
+    case DW_AT_call_target:
+    case DW_AT_call_target_clobbered:
+    case DW_AT_call_data_location:
+    case DW_AT_call_data_value:
     case DW_AT_data_member_location:
     case DW_AT_vtable_elem_location:
     case DW_AT_string_length: