]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Enable building with -Og.
authorMark Wielaard <mark@klomp.org>
Fri, 23 Nov 2018 19:50:51 +0000 (20:50 +0100)
committerMark Wielaard <mark@klomp.org>
Fri, 23 Nov 2018 20:06:30 +0000 (21:06 +0100)
When building with -Og gcc is unable to see that __libdw_dieabbrev ()
will initialize what the second argument points to when no error occurs
as called by dwarf_child and dwarf_getattrs. Causing an possibly
uninitialized error. Just initialize readp/die_addr to NULL, which is
the value we would return if an error occurs anyway.

https://sourceware.org/bugzilla/show_bug.cgi?id=23914

Signed-off-by: Mark Wielaard <mark@klomp.org>
libdw/ChangeLog
libdw/dwarf_child.c
libdw/dwarf_getattrs.c

index 7caa2234e0ffce8852a9e843313d540dd90627d8..44405d75e4d4ae446c3db3c4af4e193231aca188 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-23  Mark Wielaard  <mark@klomp.org>
+
+       * dwarf_child.c (__libdw_find_attr): Initialize readp to NULL.
+       * dwarf_getattrs.c (dwarf_getattrs): Initialize die_addr to NULL.
+
 2018-10-20  Mark Wielaard  <mark@klomp.org>
 
        * libdw.map (ELFUTILS_0.175): New section. Add dwelf_elf_begin.
index 9446b880e1accaacecd473b3a6554872cdbfd132..2e39d834e8e50370ce4348a72c5d954c0f355914 100644 (file)
@@ -43,7 +43,7 @@ internal_function
 __libdw_find_attr (Dwarf_Die *die, unsigned int search_name,
                   unsigned int *codep, unsigned int *formp)
 {
-  const unsigned char *readp;
+  const unsigned char *readp = NULL;
 
   /* Find the abbreviation entry.  */
   Dwarf_Abbrev *abbrevp = __libdw_dieabbrev (die, &readp);
index 50faf988b9acd4e63efc669c7b3b68be15eef79d..4ac16b1aa0654dfeedc4be46188850867fbd6d3e 100644 (file)
@@ -44,7 +44,7 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) (Dwarf_Attribute *, void *),
   if (unlikely (offset == 1))
     return 1;
 
-  const unsigned char *die_addr;
+  const unsigned char *die_addr = NULL;
 
   /* Find the abbreviation entry.  */
   Dwarf_Abbrev *abbrevp = __libdw_dieabbrev (die, &die_addr);