public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Don't handle blocks as exprlocs for DWARF version 4 or higher.
@ 2021-02-13 22:46 Mark Wielaard
  2021-02-18 13:40 ` Mark Wielaard
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Wielaard @ 2021-02-13 22:46 UTC (permalink / raw)
  To: dwz; +Cc: Mark Wielaard

Since DWARF version 4 blocks just contain bytes, trying to interpret
them as exprlocs will most likely fail.

     * dwz.c (add_locexpr_dummy_dies): Only handle block as exprloc
     for cu_version < 4.
     (checksum_die): Likewise.
     (write_die): Likewise.

https://sourceware.org/bugzilla/show_bug.cgi?id=26987
---
 dwz.c | 166 +++++++++++++++++++++++++++++-----------------------------
 1 file changed, 84 insertions(+), 82 deletions(-)

diff --git a/dwz.c b/dwz.c
index d6b9df0..02fcd8c 100644
--- a/dwz.c
+++ b/dwz.c
@@ -2913,43 +2913,44 @@ add_locexpr_dummy_dies (DSO *dso, dw_cu_ref cu, dw_die_ref die,
   if (form == DW_FORM_block1)
     {
       /* Old DWARF uses blocks instead of exprlocs.  */
-      switch (attr)
-	{
-	case DW_AT_frame_base:
-	case DW_AT_location:
-	case DW_AT_data_member_location:
-	case DW_AT_vtable_elem_location:
-	case DW_AT_byte_size:
-	case DW_AT_bit_offset:
-	case DW_AT_bit_size:
-	case DW_AT_string_length:
-	case DW_AT_lower_bound:
-	case DW_AT_return_addr:
-	case DW_AT_bit_stride:
-	case DW_AT_upper_bound:
-	case DW_AT_count:
-	case DW_AT_segment:
-	case DW_AT_static_link:
-	case DW_AT_use_location:
-	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_GNU_call_site_value:
-	case DW_AT_GNU_call_site_data_value:
-	case DW_AT_GNU_call_site_target:
-	case DW_AT_GNU_call_site_target_clobbered:
-	  if (read_exprloc_low_mem_phase1 (dso, die, ptr, len))
-	    return 1;
-	default:
-	  break;
-	}
+      if (cu->cu_version < 4)
+	switch (attr)
+	  {
+	  case DW_AT_frame_base:
+	  case DW_AT_location:
+	  case DW_AT_data_member_location:
+	  case DW_AT_vtable_elem_location:
+	  case DW_AT_byte_size:
+	  case DW_AT_bit_offset:
+	  case DW_AT_bit_size:
+	  case DW_AT_string_length:
+	  case DW_AT_lower_bound:
+	  case DW_AT_return_addr:
+	  case DW_AT_bit_stride:
+	  case DW_AT_upper_bound:
+	  case DW_AT_count:
+	  case DW_AT_segment:
+	  case DW_AT_static_link:
+	  case DW_AT_use_location:
+	  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_GNU_call_site_value:
+	  case DW_AT_GNU_call_site_data_value:
+	  case DW_AT_GNU_call_site_target:
+	  case DW_AT_GNU_call_site_target_clobbered:
+	    if (read_exprloc_low_mem_phase1 (dso, die, ptr, len))
+	      return 1;
+	  default:
+	    break;
+	  }
 
       return 0;
     }
@@ -3736,50 +3737,51 @@ checksum_die (DSO *dso, dw_cu_ref cu, dw_die_ref top_die, dw_die_ref die)
       if (form == DW_FORM_block1)
 	{
 	  /* Old DWARF uses blocks instead of exprlocs.  */
-	  switch (t->attr[i].attr)
-	    {
-	    case DW_AT_frame_base:
-	    case DW_AT_location:
-	    case DW_AT_data_member_location:
-	    case DW_AT_vtable_elem_location:
-	    case DW_AT_byte_size:
-	    case DW_AT_bit_offset:
-	    case DW_AT_bit_size:
-	    case DW_AT_string_length:
-	    case DW_AT_lower_bound:
-	    case DW_AT_return_addr:
-	    case DW_AT_bit_stride:
-	    case DW_AT_upper_bound:
-	    case DW_AT_count:
-	    case DW_AT_segment:
-	    case DW_AT_static_link:
-	    case DW_AT_use_location:
-	    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_GNU_call_site_value:
-	    case DW_AT_GNU_call_site_data_value:
-	    case DW_AT_GNU_call_site_target:
-	    case DW_AT_GNU_call_site_target_clobbered:
-	      if (die->die_ck_state != CK_BAD)
-		{
-		  s = t->attr[i].attr;
-		  die->u.p1.die_hash
-		    = iterative_hash_object (s, die->u.p1.die_hash);
-		}
-	      if (read_exprloc (dso, die, ptr, len, NULL))
-		return 1;
-	      handled = true;
-	    default:
-	      break;
-	    }
+	  if (cu->cu_version < 4)
+	    switch (t->attr[i].attr)
+	      {
+	      case DW_AT_frame_base:
+	      case DW_AT_location:
+	      case DW_AT_data_member_location:
+	      case DW_AT_vtable_elem_location:
+	      case DW_AT_byte_size:
+	      case DW_AT_bit_offset:
+	      case DW_AT_bit_size:
+	      case DW_AT_string_length:
+	      case DW_AT_lower_bound:
+	      case DW_AT_return_addr:
+	      case DW_AT_bit_stride:
+	      case DW_AT_upper_bound:
+	      case DW_AT_count:
+	      case DW_AT_segment:
+	      case DW_AT_static_link:
+	      case DW_AT_use_location:
+	      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_GNU_call_site_value:
+	      case DW_AT_GNU_call_site_data_value:
+	      case DW_AT_GNU_call_site_target:
+	      case DW_AT_GNU_call_site_target_clobbered:
+		if (die->die_ck_state != CK_BAD)
+		  {
+		    s = t->attr[i].attr;
+		    die->u.p1.die_hash
+		      = iterative_hash_object (s, die->u.p1.die_hash);
+		  }
+		if (read_exprloc (dso, die, ptr, len, NULL))
+		  return 1;
+		handled = true;
+	      default:
+		break;
+	      }
 	  ptr += len;
 	}
       else if (form == DW_FORM_exprloc)
@@ -12392,7 +12394,7 @@ write_die (unsigned char *ptr, dw_cu_ref cu, dw_die_ref die,
 	  ptr += inptr - orig_ptr;
 
 	  /* Old DWARF uses blocks instead of exprlocs.  */
-	  if (form == DW_FORM_block1)
+	  if (form == DW_FORM_block1 && cu->cu_version < 4)
 	    switch (reft->attr[i].attr)
 	      {
 	      case DW_AT_frame_base:
-- 
2.20.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-02-18 21:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-13 22:46 [PATCH] Don't handle blocks as exprlocs for DWARF version 4 or higher Mark Wielaard
2021-02-18 13:40 ` Mark Wielaard
2021-02-18 14:09   ` Jakub Jelinek
2021-02-18 16:18     ` Mark Wielaard
2021-02-18 16:59       ` Jakub Jelinek
2021-02-18 17:32         ` Jakub Jelinek
2021-02-18 20:01         ` Mark Wielaard
2021-02-18 20:06           ` Jakub Jelinek
2021-02-18 21:17             ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).