public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: Re: PR28149, debug info with wrong file association
Date: Mon, 20 Sep 2021 12:24:22 +0930	[thread overview]
Message-ID: <YUf33i1oE++pbTWF@squeak.grove.modra.org> (raw)
In-Reply-To: <YUQ+TrjMU2g4vaPg@squeak.grove.modra.org>

Linaro TCWG CI sent me a love letter.  :)

Fixes segfaults when building aarch64-linux kernel, due to only doing
part of the work necessary when allocating file numbers late.  I'd
missed looping over subsegments, which resulted in some u.filename
entries left around and later interpreted as u.view.

	PR 28149
	* dwarf2dbg.c (purge_generated_debug): Iterate over subsegs too.
	(dwarf2_finish): Call do_allocate_filenum for all subsegs too,
	in a separate loop before subsegs are chained.

diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 1250fcef54f..e2abe19c88a 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -792,19 +792,23 @@ purge_generated_debug (void)
 
   for (s = all_segs; s; s = s->next)
     {
-      struct line_subseg *lss = s->head;
-      struct line_entry *e, *next;
+      struct line_subseg *lss;
 
-      for (e = lss->head; e; e = next)
+      for (lss = s->head; lss; lss = lss->next)
 	{
-	  know (e->loc.filenum == -1u);
-	  next = e->next;
-	  free (e);
-	}
+	  struct line_entry *e, *next;
+
+	  for (e = lss->head; e; e = next)
+	    {
+	      know (e->loc.filenum == -1u);
+	      next = e->next;
+	      free (e);
+	    }
 
-      lss->head = NULL;
-      lss->ptail = &lss->head;
-      lss->pmove_tail = &lss->head;
+	  lss->head = NULL;
+	  lss->ptail = &lss->head;
+	  lss->pmove_tail = &lss->head;
+	}
     }
 }
 
@@ -2887,15 +2891,21 @@ dwarf2_finish (void)
 			     SEC_READONLY | SEC_DEBUGGING | SEC_OCTETS);
     }
 
+  for (s = all_segs; s; s = s->next)
+    {
+      struct line_subseg *lss;
+
+      for (lss = s->head; lss; lss = lss->next)
+	if (lss->head)
+	  do_allocate_filenum (lss->head);
+    }
+
   /* For each subsection, chain the debug entries together.  */
   for (s = all_segs; s; s = s->next)
     {
       struct line_subseg *lss = s->head;
       struct line_entry **ptail = lss->ptail;
 
-      if (lss->head && SEG_NORMAL (s->seg))
-	do_allocate_filenum (lss->head);
-
       /* Reset the initial view of the first subsection of the
 	 section.  */
       if (lss->head && lss->head->loc.u.view)

-- 
Alan Modra
Australia Development Lab, IBM

  reply	other threads:[~2021-09-20  2:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-17  6:56 Alan Modra
2021-09-17  7:05 ` PR28149 part 2, purge generated line info Alan Modra
2021-09-20  2:54   ` Alan Modra [this message]
2021-09-17  7:25 ` PR28149, debug info with wrong file association Eric Botcazou
2021-09-17  8:32   ` Alan Modra
2021-09-17  8:49     ` Eric Botcazou
2021-09-17  9:02       ` Alan Modra
2021-09-17  9:16         ` Eric Botcazou
2021-09-17 11:16           ` Alan Modra

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=YUf33i1oE++pbTWF@squeak.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@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).