[PATCH] libdw: Resolve alt file on first use.
Mark Wielaard
mark@klomp.org
Thu Jan 25 15:28:00 GMT 2018
On Mon, 2018-01-22 at 12:30 +0100, Mark Wielaard wrote:
> +static void
> +find_debug_altlink (Dwarf *dbg)
> +{
> + const char *altname;
> + const void *build_id;
> + 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;
Testing under valgrind showed that this should be build_id_len <= 0.
When dwelf_dwarf_gnu_debugaltlink returns 0 it means there was no
.gnu_debugaltlink section at all. A negative return value means the
data found was corrupt. In both cases neither altname nor build_id
might be set up. So I added the following fixup:
diff --git a/libdw/dwarf_getalt.c b/libdw/dwarf_getalt.c
index 7b41a2b..3e5af15 100644
--- a/libdw/dwarf_getalt.c
+++ b/libdw/dwarf_getalt.c
@@ -117,7 +117,7 @@ find_debug_altlink (Dwarf *dbg)
&build_id);
/* Couldn't even get the debugaltlink. It probably doesn't exist. */
- if (build_id_len < 0)
+ if (build_id_len <= 0)
return;
const uint8_t *id = (const uint8_t *) build_id;
More information about the Elfutils-devel
mailing list