Hi Aaron,
On Mon, Jul 20, 2026 at 10:34:06PM -0400, Aaron Merey wrote:
> On Fri, Jul 10, 2026 at 6:35 PM Mark Wielaard <[email protected]> wrote:
> > diff --git a/libdw/dwarf_getalt.c b/libdw/dwarf_getalt.c
> > index f4b8ad02acdc..e94595c302a8 100644
> > --- a/libdw/dwarf_getalt.c
> > +++ b/libdw/dwarf_getalt.c
> > @@ -103,10 +103,17 @@ find_debug_altlink (Dwarf *dbg)
> > ssize_t build_id_len = INTUSE(dwelf_dwarf_gnu_debugaltlink) (dbg,
> > &altname,
> > &build_id);
> > -
> > - /* Couldn't even get the debugaltlink. It probably doesn't exist. */
> > if (build_id_len <= 0)
> > - return;
> > + {
> > + uint8_t is_sup;
> > + build_id_len = INTUSE(dwelf_dwarf_debug_sup) (dbg, NULL, &is_sup,
> > + &altname,
> > + ((const uint8_t **)
> > + &build_id));
> > + /* Does the .debug_sup exist and is this a plain DWARF? */
> > + if (build_id_len <= 0 || is_sup != 0)
>
> Here's where the no-ID return value issue from patch 1 comes up. The
> ID is not required for .debug_sup to be spec-conformant but in this case
> dwarf_getalt will act like the section doesn't exist.
Changing to if (build_id_len < 0 || altname == NULL || is_sup != 0)
That way we "accept" a zero length build_id_len if we get at least an
altname. Below we then reject the zero length build_id_len (as too
small) and fall back on just trying to use the altname.
> > diff --git a/tests/allfcts.c b/tests/allfcts.c
> > index f637311741bb..dd3bb6d345cd 100644
> > --- a/tests/allfcts.c
> > +++ b/tests/allfcts.c
> > @@ -46,7 +46,13 @@ setup_alt (Dwarf *main)
> > const void *build_id;
> > ssize_t ret = dwelf_dwarf_gnu_debugaltlink (main, &alt_name, &build_id);
> > if (ret == 0)
> > - return NULL;
> > + {
> > + uint8_t is_sup;
> > + ret = dwelf_dwarf_debug_sup (main, NULL, &is_sup, &alt_name,
> > + (const uint8_t **) &build_id);
> > + if (ret == 0 || is_sup != 0)
>
> If ret == -1 then is_sup is read while uninitialized, although this should
> never happen with the test binaries being fixed.
Yeah, check should also be ret < 0 || altname == NULL || is_sup != 0.
I'll sent a new version.
Thanks,
Mark