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] Fix up DW_AT_import DW_FORM_ref_addr handling in readelf


Hi!

For DW_FORM_ref_addr DW_AT_import we print complete garbage, the DIE
referenced in that case is (most probably) in a different CU and likely has
different abbrev table, so looking up the abbrev number in the current
abbrev table is usually wrong.  We don't track of .debug_info/.debug_types
section chunk starts/sizes right now, so it would be too expensive to look
up the abbrev offset corresponding to arbitrary offset.

Committed to trunk.

2012-05-10  Jakub Jelinek  <jakub@redhat.com>

	* dwarf.c (read_and_display_attr_value): Don't look up tag from
	abbrev for DW_FORM_ref_addr.

--- binutils/dwarf.c.jj	2012-05-09 20:15:15.000000000 +0200
+++ binutils/dwarf.c	2012-05-10 08:16:00.063771241 +0200
@@ -1716,11 +1716,17 @@ read_and_display_attr_value (unsigned lo
 	    abbrev_number = read_leb128 (section->start + uvalue, NULL, 0);
 
 	    printf (_("[Abbrev Number: %ld"), abbrev_number);
-	    for (entry = first_abbrev; entry != NULL; entry = entry->next)
-	      if (entry->entry == abbrev_number)
-		break;
-	    if (entry != NULL)
-	      printf (" (%s)", get_TAG_name (entry->tag));
+	    /* Don't look up abbrev for DW_FORM_ref_addr, as it very often will
+	       use different abbrev table, and we don't track .debug_info chunks
+	       yet.  */
+	    if (form != DW_FORM_ref_addr)
+	      {
+		for (entry = first_abbrev; entry != NULL; entry = entry->next)
+		  if (entry->entry == abbrev_number)
+		    break;
+		if (entry != NULL)
+		  printf (" (%s)", get_TAG_name (entry->tag));
+	      }
 	    printf ("]");
 	  }
       }

	Jakub


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