From: Ulf Hermann <ulf.hermann@qt.io>
To: elfutils-devel@sourceware.org
Subject: [PATCH 2/2 v2] Generalize cu_sec_idx
Date: Fri, 08 Dec 2017 15:06:00 -0000 [thread overview]
Message-ID: <c6506d04-d50d-350e-1af2-3bb5669e7e1f@qt.io> (raw)
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
next reply other threads:[~2017-12-08 15:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-08 15:06 Ulf Hermann [this message]
2017-12-14 13:51 ` Mark Wielaard
2017-12-14 13:53 ` Ulf Hermann
2017-12-20 18:09 ` Mark Wielaard
2017-12-21 13:48 ` Ulf Hermann
2017-12-21 20:22 ` Mark Wielaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c6506d04-d50d-350e-1af2-3bb5669e7e1f@qt.io \
--to=ulf.hermann@qt.io \
--cc=elfutils-devel@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).