This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[COMMITTED] libdw: Make sure to initialize Dwarf_CU addr_base and str_off_base.


The patches for .debug_addr and .debug_str_offsets didn't properly
initialize the addr_base and str_off_base CU fields causing random
results.

The __libdw_cu_addr_base () and __libdw_cu_str_off_base () functions
rely on these fields being initialized to -1 when the values have not
yet been set up. Shows up as a valgrind warning.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libdw/ChangeLog      | 5 +++++
 libdw/libdw_findcu.c | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index ee6a1eb..ad62771 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
+2018-04-04  Mark Wielaard  <mark@klomp.org>
+
+	* libdw_findcu.c (__libdw_intern_next_unit): Initialize Dwarf_CU
+	addr_base and str_off_base.
+
 2018-03-23  Mark Wielaard  <mark@klomp.org>
 
 	* dwarf_begin_elf.c (dwarf_scnnames): Add IDX_debug_str_offsets,
diff --git a/libdw/libdw_findcu.c b/libdw/libdw_findcu.c
index 4d1d842..04390b4 100644
--- a/libdw/libdw_findcu.c
+++ b/libdw/libdw_findcu.c
@@ -116,6 +116,8 @@ __libdw_intern_next_unit (Dwarf *dbg, bool debug_types)
   newp->orig_abbrev_offset = newp->last_abbrev_offset = abbrev_offset;
   newp->lines = NULL;
   newp->locs = NULL;
+  newp->addr_base = (Dwarf_Off) -1;
+  newp->str_off_base = (Dwarf_Off) -1;
 
   newp->startp = data->d_buf + newp->start;
   newp->endp = data->d_buf + newp->end;
-- 
1.8.3.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]