[PATCH] bfd: Fix addr2line for skipped DW_FORM_ref_addr CUs and DWARF5 one-file line tables
Jan Beulich
jbeulich@suse.com
Fri Nov 6 08:53:02 GMT 2026
On 03.11.2026 17:50, Kumar N, Bhuvanendra wrote:
> From: bhkumarn Bhuvanendra.KumarN@amd.com<mailto:Bhuvanendra.KumarN@amd.com>
> Date: Tue, 3 Nov 2026 16:00:28 +0000
> Subject: [PATCH] bfd: Fix addr2line for skipped DW_FORM_ref_addr CUs and
> DWARF5 one-file line tables
>
> For clang compiled objects, addr2line can miss a later compilation unit
> when an earlier CU is scanned and DW_FORM_ref_addr causes stash_comp_unit
> to parse ahead. Those units never go through the sequential reader.
> Queue them on unsearched_units and search only that small set.
>
> Separately, PR 30783 starts the DWARF5 line state machine at file
> index 1. A table that contains only file 0 then reports a bad file
> number. Keep the initial index at 1 when that slot exists; fall back
> to file 0 only for a one-entry DWARF5 table.
>
> bfd/
> * dwarf2.c (struct dwarf2_debug_file): Add unsearched_units.
> (struct comp_unit): Add next_unsearched.
> (decode_line_info): Fall back to file 0 when a DWARF5 line
> table has no file 1.
> (find_abstract_instance): Queue CUs parsed via DW_FORM_ref_addr
> or DW_FORM_GNU_ref_alt.
> (_bfd_dwarf2_find_nearest_line_with_alt): Drain unsearched_units
> as a work queue after the sequential scan.
Okay, albeit I think I'll ...
> @@ -6016,6 +6030,25 @@ _bfd_dwarf2_find_nearest_line_with_alt
> break;
> }
> + /* Search CUs parsed via DW_FORM_ref_addr. */
> + if (!found && !do_line)
> + {
> + while (stash->f.unsearched_units != NULL)
> + {
> + each = stash->f.unsearched_units;
> + stash->f.unsearched_units = each->next_unsearched;
> + each->next_unsearched = NULL;
> + found = (comp_unit_may_contain_address (each, addr)
> + && comp_unit_find_nearest_line (each, addr,
> + filename_ptr,
> + &function,
> + linenumber_ptr,
> + discriminator_ptr));
> + if (found)
> + break;
> + }
> + }
> +
> done:
> if (functionname_ptr && function && function->is_linkage)
> {
... shrink this hunk some before committing.
Jan
More information about the Binutils
mailing list