This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[PATCH 2/2 v2] Generalize cu_sec_idx
- From: Ulf Hermann <ulf dot hermann at qt dot io>
- To: elfutils-devel at sourceware dot org
- Date: Fri, 8 Dec 2017 16:06:26 +0100
- Subject: [PATCH 2/2 v2] Generalize cu_sec_idx
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=ulf dot hermann at qt dot io;
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qtcompany.onmicrosoft.com; s=selector1-qt-io; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Kqq1xH2PJFWeSxvynxunw8KlTZSO6GpO1YV+Y4ludS4=; b=IR2/w3NJ/VZL8bREjdkENdc74NWa7pRV15r6yRx2glPj1Or71954SiCNxNqJkgLyORnxD/canSTpGWFX9Y/H59zdowNYqUTUQnhr34gi7TUuTx+/8vXT7VstmdD528BSO4riUTm84s9W0qWh1qXDvS/Xapo/ofbCxr7f/MJvWBs=
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
Apparently CUs can appear in other sections than IDX_debug_info and
IDX_types. Rather than relying on the indirect indication provided by
type_offset we compare the addresses directly to figure out which section
a given CU belongs to.
This fixes the dwarf-getmacros test.
(Signed-off instead of Change-Id ...)
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
libdw/ChangeLog | 4 ++++
libdw/libdwP.h | 12 +++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 996cd2e..508bf9c 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,7 @@
+2017-12-08 Ulf Hermann <ulf.hermann@qt.io>
+
+ * libdwP.h: Generalize cu_sec_idx to check all sections.
+
2017-05-09 Ulf Hermann <ulf.hermann@qt.io>
* libdwP.h: Fix check for the upper border of the range in
__libdw_in_section.
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index e092d8e..8f3a95c 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -715,7 +715,17 @@ __libdw_read_offset (Dwarf *dbg, Dwarf *dbg_ret,
static inline size_t
cu_sec_idx (struct Dwarf_CU *cu)
{
- return cu->type_offset == 0 ? IDX_debug_info : IDX_debug_types;
+ for (int sec_index = IDX_debug_info; sec_index < IDX_last; ++sec_index)
+ {
+ Elf_Data *data = cu->dbg->sectiondata[sec_index];
+ if (data != NULL && data->d_buf != NULL
+ && cu->startp >= data->d_buf
+ && cu->startp < data->d_buf + data->d_size)
+ {
+ return sec_index;
+ }
+ }
+ return IDX_last;
}
static inline bool
--
2.8.1.windows.1