public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Jakub Jelinek <jakub@redhat.com>
Cc: dwz@sourceware.org
Subject: Re: [PATCH] Error out on DW_AT_location with invalid encoding
Date: Tue, 01 Jan 2019 00:00:00 -0000	[thread overview]
Message-ID: <2fe7d53a-6bdd-7d5c-bb9d-1cd428f86c5d@suse.de> (raw)
In-Reply-To: <20190307075541.GS7611@tucnak>

[-- Attachment #1: Type: text/plain, Size: 835 bytes --]

On 07-03-19 08:55, Jakub Jelinek wrote:
> On Thu, Mar 07, 2019 at 08:22:42AM +0100, Tom de Vries wrote:
>> Hi,
>>
>> When processing a file containing an DW_AT_location with encoding DW_FORM_addr,
> 
> What kind of generator generates that?  Ugh.

AFAICT it's the result of generating a .s file from a .c file and then
hand-editing the debug info (
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/testsuite/gdb.dwarf2/dw2-restrict.S;h=7108b86ec109ce5a1bd299e2c36696a12024e0d5;hb=HEAD
):
...
        .byte   16                      # DW_AT_stmt_list
        .byte   1                       # DW_FORM_addr
...

> Above you mention DW_AT_location (and in ChangeLog too), but the patch
> actually handles DW_AT_stmt_list that way.  So, which one it is?

It's DW_AT_stmt_list. Updated patch attached.

Thanks,
- Tom



[-- Attachment #2: 0001-Error-out-on-DW_AT_stmt_list-with-invalid-encoding.patch --]
[-- Type: text/x-patch, Size: 2285 bytes --]

Error out on DW_AT_stmt_list with invalid encoding

When processing a file containing an DW_AT_stmt_list with encoding DW_FORM_addr,
we run into this assert in write_die:
...
dwz: dwz.c:9068: write_die: \
  Assertion `p && (form == DW_FORM_sec_offset || form == DW_FORM_data4)' failed
...

Error out instead (and do it earlier, in read_debug_info):
...
$ ./dwz -m 3 1 2
./dwz: 1: DW_AT_stmt_list not DW_FORM_sec_offset or DW_FORM_data4
./dwz: 2: DW_AT_stmt_list not DW_FORM_sec_offset or DW_FORM_data4
./dwz: Too few files for multifile optimization
...

2019-02-14  Tom de Vries  <tdevries@suse.de>

	PR dwz/24171
	* dwz.c (get_AT_int): Add and handle formp parameter.
	(read_debug_info): Error out on invalid DW_AT_stmt_list encoding.

---
 dwz.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/dwz.c b/dwz.c
index fc87abe..476807a 100644
--- a/dwz.c
+++ b/dwz.c
@@ -1325,16 +1325,16 @@ get_AT (dw_die_ref die, enum dwarf_attribute at, enum dwarf_form *formp)
 /* Return an integer attribute AT of DIE.  Set *PRESENT to true
    if found.  */
 static uint64_t
-get_AT_int (dw_die_ref die, enum dwarf_attribute at, bool *present)
+get_AT_int (dw_die_ref die, enum dwarf_attribute at, bool *present,
+	    enum dwarf_form *formp)
 {
-  enum dwarf_form form;
   unsigned char *ptr;
-  ptr = get_AT (die, at, &form);
+  ptr = get_AT (die, at, formp);
   *present = false;
   if (ptr == NULL)
     return 0;
   *present = true;
-  switch (form)
+  switch (*formp)
     {
     case DW_FORM_ref_addr:
       return read_size (ptr, die_cu (die)->cu_version == 2 ? ptr_size : 4);
@@ -5000,9 +5000,18 @@ read_debug_info (DSO *dso, int kind)
 	}
 
       cu->cu_comp_dir = get_AT_string (cu->cu_die, DW_AT_comp_dir);
-      debug_line_off = get_AT_int (cu->cu_die, DW_AT_stmt_list, &present);
+      enum dwarf_form form;
+      debug_line_off
+	= get_AT_int (cu->cu_die, DW_AT_stmt_list, &present, &form);
       if (present)
 	{
+	  if (!(form == DW_FORM_sec_offset || form == DW_FORM_data4))
+	    {
+	      error (0, 0, "%s: DW_AT_stmt_list not DW_FORM_sec_offset or"
+		     " DW_FORM_data4", dso->filename);
+	      goto fail;
+	    }
+
 	  if (cu_files != NULL && last_debug_line_off == debug_line_off)
 	    {
 	      cu->cu_nfiles = cu_nfiles;

  reply	other threads:[~2019-03-07  8:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-01  0:00 Tom de Vries
2019-01-01  0:00 ` Jakub Jelinek
2019-01-01  0:00   ` Tom de Vries [this message]
2019-01-01  0:00     ` Jakub Jelinek
2019-01-01  0:00       ` Tom de Vries
2019-01-01  0:00         ` Mark Wielaard
2019-01-01  0:00         ` Jakub Jelinek

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=2fe7d53a-6bdd-7d5c-bb9d-1cd428f86c5d@suse.de \
    --to=tdevries@suse.de \
    --cc=dwz@sourceware.org \
    --cc=jakub@redhat.com \
    /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).