public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [COMMITTED] libdw: Make sure to initialize Dwarf_CU addr_base and str_off_base.
@ 2018-04-04 14:48 Mark Wielaard
  0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2018-04-04 14:48 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-04-04 14:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-04 14:48 [COMMITTED] libdw: Make sure to initialize Dwarf_CU addr_base and str_off_base Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).