This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: [PATCH] libdw: Resolve alt file on first use.
- From: Mark Wielaard <mark at klomp dot org>
- To: elfutils-devel at sourceware dot org
- Date: Thu, 25 Jan 2018 16:28:08 +0100
- Subject: Re: [PATCH] libdw: Resolve alt file on first use.
- Authentication-results: sourceware.org; auth=none
- References: <1516620651-14393-1-git-send-email-mark@klomp.org>
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;