This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] dwarf display: false (location list) in DWARF-4


Hi,

echo 'struct s { char a[1<<24]; int b; } s;'|gcc -gdwarf-4 -o 1.o -c -x c -;readelf -wia 1.o

 <2><34>: Abbrev Number: 4 (DW_TAG_member)
    <35>   DW_AT_name        : b
    <37>   DW_AT_decl_file   : 1
    <38>   DW_AT_decl_line   : 1
    <39>   DW_AT_type        : <0x55>
    <3d>   DW_AT_data_member_location: 0x1000000        (location list)
+
   4      DW_TAG_member    [no children]
    DW_AT_name         DW_FORM_string
    DW_AT_decl_file    DW_FORM_data1
    DW_AT_decl_line    DW_FORM_data1
    DW_AT_type         DW_FORM_ref4
    DW_AT_data_member_location DW_FORM_data4

But that is wrong, DWARF-4 has DW_FORM_sec_offset for `(location list)',
0x1000000 is normal data (DW_FORM_data4) in DWARF-4.  There should be just:

    <3d>   DW_AT_data_member_location: 0x1000000

No regressions on {x86_64,i686}-fedora16pre-linux-gnu.  I haven't found the
string "location list" anywhere in the testsuites so I hope I did not break any
other targets' testsuites.


Thanks,
Jan


binutils/
2011-07-27  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf.c (read_and_display_attr_value): Recognize DW_FORM_data4 and
	DW_FORM_data8 as location list pointers only for DWARF < 4.

--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -1485,8 +1485,8 @@ read_and_display_attr_value (unsigned long attribute,
 	case DW_AT_GNU_call_site_data_value:
 	case DW_AT_GNU_call_site_target:
 	case DW_AT_GNU_call_site_target_clobbered:
-    	  if (form == DW_FORM_data4
-	      || form == DW_FORM_data8
+    	  if ((dwarf_version < 4
+	       && (form == DW_FORM_data4 || form == DW_FORM_data8))
 	      || form == DW_FORM_sec_offset)
 	    {
 	      /* Process location list.  */
@@ -1516,8 +1516,8 @@ read_and_display_attr_value (unsigned long attribute,
 	  break;
 
 	case DW_AT_ranges:
-	  if (form == DW_FORM_data4
-	      || form == DW_FORM_data8
+    	  if ((dwarf_version < 4
+	       && (form == DW_FORM_data4 || form == DW_FORM_data8))
 	      || form == DW_FORM_sec_offset)
 	    {
 	      /* Process range list.  */
@@ -1734,8 +1734,8 @@ read_and_display_attr_value (unsigned long attribute,
     case DW_AT_GNU_call_site_data_value:
     case DW_AT_GNU_call_site_target:
     case DW_AT_GNU_call_site_target_clobbered:
-      if (form == DW_FORM_data4
-	  || form == DW_FORM_data8
+      if ((dwarf_version < 4
+           && (form == DW_FORM_data4 || form == DW_FORM_data8))
 	  || form == DW_FORM_sec_offset)
 	printf (_("(location list)"));
       /* Fall through.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]