public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: dwz@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH] Don't handle blocks as exprlocs for DWARF version 4 or higher.
Date: Sat, 13 Feb 2021 23:46:22 +0100	[thread overview]
Message-ID: <20210213224622.16521-1-mark@klomp.org> (raw)

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


             reply	other threads:[~2021-02-13 22:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-13 22:46 Mark Wielaard [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210213224622.16521-1-mark@klomp.org \
    --to=mark@klomp.org \
    --cc=dwz@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).