aboutsummaryrefslogtreecommitdiff
path: root/gas/dwarf2dbg.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-09-20 11:30:41 +0930
committerAlan Modra <amodra@gmail.com>2021-09-20 11:38:55 +0930
commit5b4846283c3d49138a58a3bb4d61ed3e2dfffff4 (patch)
tree9a3a322a37e0ed2a648a3ce4eecb349beb741f4d /gas/dwarf2dbg.c
parent8ac439689f4b0e7d0d03805426ae75fafdb47ad5 (diff)
downloadbinutils-5b4846283c3d49138a58a3bb4d61ed3e2dfffff4.zip
binutils-5b4846283c3d49138a58a3bb4d61ed3e2dfffff4.tar.gz
binutils-5b4846283c3d49138a58a3bb4d61ed3e2dfffff4.tar.bz2
Re: PR28149, debug info with wrong file association
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.
Diffstat (limited to 'gas/dwarf2dbg.c')
-rw-r--r--gas/dwarf2dbg.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 1250fce..e2abe19 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)