From: Omar Sandoval <osandov@osandov.com>
To: elfutils-devel@sourceware.org
Subject: [PATCH 07/14] libdw: Recognize .debug_[ct]u_index sections in dwarf_elf_begin
Date: Wed, 27 Sep 2023 11:20:56 -0700 [thread overview]
Message-ID: <5837a252931d4a85079d29d08f8b6890ae070700.1695837512.git.osandov@fb.com> (raw)
In-Reply-To: <cover.1695837512.git.osandov@fb.com>
From: Omar Sandoval <osandov@fb.com>
DWARF package (.dwp) files have a .debug_cu_index section and,
optionally, a .debug_tu_index section. Add them to the list of DWARF
sections.
Unfortunately, it's not that simple: the other debug sections in a dwp
file have names ending with .dwo, which confuses the checks introduced
by commit 5b21e70216b8 ("libdw: dwarf_elf_begin should use either plain,
dwo or lto DWARF sections."). So, we also have to special case
.debug_cu_index and .debug_tu_index in scn_dwarf_type and check_section
to treat them as TYPE_DWO sections.
Signed-off-by: Omar Sandoval <osandov@fb.com>
---
libdw/ChangeLog | 8 +++++++
libdw/dwarf_begin_elf.c | 53 +++++++++++++++++++++--------------------
libdw/libdwP.h | 2 ++
3 files changed, 37 insertions(+), 26 deletions(-)
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index be1e40bc..52327688 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -20,6 +20,14 @@
instead of dbg parameter, which is now unused.
* libdwP.h (Dwarf_Macro_Op_Table): Replace is_64bit with address_size
and offset_size. Add dbg.
+ Add IDX_debug_cu_index and IDX_debug_tu_index.
+ * dwarf_begin_elf.c (dwarf_scnnames): Add IDX_debug_cu_index and
+ IDX_debug_tu_index.
+ (scn_to_string_section_idx): Ditto.
+ (scn_dwarf_type): Check for .debug_cu_index, .debug_tu_index,
+ .zdebug_cu_index, and .zdebug_tu_index.
+ (check_section): Change .dwo suffix matching to account for
+ .debug_cu_index and .debug_tu_index.
2023-02-22 Mark Wielaard <mark@klomp.org>
diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
index 92d76d24..7936d343 100644
--- a/libdw/dwarf_begin_elf.c
+++ b/libdw/dwarf_begin_elf.c
@@ -67,6 +67,8 @@ static const char dwarf_scnnames[IDX_last][19] =
[IDX_debug_macro] = ".debug_macro",
[IDX_debug_ranges] = ".debug_ranges",
[IDX_debug_rnglists] = ".debug_rnglists",
+ [IDX_debug_cu_index] = ".debug_cu_index",
+ [IDX_debug_tu_index] = ".debug_tu_index",
[IDX_gnu_debugaltlink] = ".gnu_debugaltlink"
};
#define ndwarf_scnnames (sizeof (dwarf_scnnames) / sizeof (dwarf_scnnames[0]))
@@ -92,6 +94,8 @@ static const enum string_section_index scn_to_string_section_idx[IDX_last] =
[IDX_debug_macro] = STR_SCN_IDX_last,
[IDX_debug_ranges] = STR_SCN_IDX_last,
[IDX_debug_rnglists] = STR_SCN_IDX_last,
+ [IDX_debug_cu_index] = STR_SCN_IDX_last,
+ [IDX_debug_tu_index] = STR_SCN_IDX_last,
[IDX_gnu_debugaltlink] = STR_SCN_IDX_last
};
@@ -109,6 +113,11 @@ scn_dwarf_type (Dwarf *result, size_t shstrndx, Elf_Scn *scn)
{
if (startswith (scnname, ".gnu.debuglto_.debug"))
return TYPE_GNU_LTO;
+ else if (strcmp (scnname, ".debug_cu_index") == 0
+ || strcmp (scnname, ".debug_tu_index") == 0
+ || strcmp (scnname, ".zdebug_cu_index") == 0
+ || strcmp (scnname, ".zdebug_tu_index") == 0)
+ return TYPE_DWO;
else if (startswith (scnname, ".debug_") || startswith (scnname, ".zdebug_"))
{
size_t len = strlen (scnname);
@@ -173,42 +182,34 @@ check_section (Dwarf *result, size_t shstrndx, Elf_Scn *scn, bool inscngrp)
bool gnu_compressed = false;
for (cnt = 0; cnt < ndwarf_scnnames; ++cnt)
{
+ /* .debug_cu_index and .debug_tu_index don't have a .dwo suffix,
+ but they are for DWO. */
+ if (result->type != TYPE_DWO
+ && (cnt == IDX_debug_cu_index || cnt == IDX_debug_tu_index))
+ continue;
+ bool need_dot_dwo =
+ (result->type == TYPE_DWO
+ && cnt != IDX_debug_cu_index
+ && cnt != IDX_debug_tu_index);
size_t dbglen = strlen (dwarf_scnnames[cnt]);
size_t scnlen = strlen (scnname);
if (strncmp (scnname, dwarf_scnnames[cnt], dbglen) == 0
- && (dbglen == scnlen
- || (scnlen == dbglen + 4
+ && ((!need_dot_dwo && dbglen == scnlen)
+ || (need_dot_dwo
+ && scnlen == dbglen + 4
&& strstr (scnname, ".dwo") == scnname + dbglen)))
- {
- if (dbglen == scnlen)
- {
- if (result->type == TYPE_PLAIN)
- break;
- }
- else if (result->type == TYPE_DWO)
- break;
- }
+ break;
else if (scnname[0] == '.' && scnname[1] == 'z'
&& (strncmp (&scnname[2], &dwarf_scnnames[cnt][1],
dbglen - 1) == 0
- && (scnlen == dbglen + 1
- || (scnlen == dbglen + 5
+ && ((!need_dot_dwo && scnlen == dbglen + 1)
+ || (need_dot_dwo
+ && scnlen == dbglen + 5
&& strstr (scnname,
".dwo") == scnname + dbglen + 1))))
{
- if (scnlen == dbglen + 1)
- {
- if (result->type == TYPE_PLAIN)
- {
- gnu_compressed = true;
- break;
- }
- }
- else if (result->type <= TYPE_DWO)
- {
- gnu_compressed = true;
- break;
- }
+ gnu_compressed = true;
+ break;
}
else if (scnlen > 14 /* .gnu.debuglto_ prefix. */
&& startswith (scnname, ".gnu.debuglto_")
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index 77959b3b..0c44d40c 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -82,6 +82,8 @@ enum
IDX_debug_macro,
IDX_debug_ranges,
IDX_debug_rnglists,
+ IDX_debug_cu_index,
+ IDX_debug_tu_index,
IDX_gnu_debugaltlink,
IDX_last
};
--
2.41.0
next prev parent reply other threads:[~2023-09-27 18:21 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
2023-09-27 18:20 ` [PATCH 01/14] libdw: Make try_split_file static Omar Sandoval
2023-10-03 16:09 ` Mark Wielaard
2023-09-27 18:20 ` [PATCH 02/14] libdw: Handle split DWARF in dwarf_entrypc Omar Sandoval
2023-10-03 16:10 ` Mark Wielaard
2023-09-27 18:20 ` [PATCH 03/14] libdw: Handle DW_AT_ranges in split DWARF 5 skeleton in dwarf_ranges Omar Sandoval
2023-10-03 16:10 ` Mark Wielaard
2023-09-27 18:20 ` [PATCH 04/14] libdw: Handle other string forms in dwarf_macro_param2 Omar Sandoval
2023-10-03 16:11 ` Mark Wielaard
2023-09-27 18:20 ` [PATCH 05/14] libdw: Fix dwarf_macro_getsrcfiles for DWARF 5 Omar Sandoval
2023-10-03 21:29 ` Mark Wielaard
2023-09-27 18:20 ` [PATCH 06/14] libdw: Handle split DWARF in dwarf_macro_getsrcfiles Omar Sandoval
2023-10-03 21:49 ` Mark Wielaard
2023-09-27 18:20 ` Omar Sandoval [this message]
2023-11-01 14:03 ` [PATCH 07/14] libdw: Recognize .debug_[ct]u_index sections in dwarf_elf_begin Mark Wielaard
2023-11-01 17:30 ` Omar Sandoval
2023-09-27 18:20 ` [PATCH 08/14] libdw: Parse DWARF package file index sections Omar Sandoval
2023-11-01 23:07 ` Mark Wielaard
2023-11-07 6:45 ` Omar Sandoval
2023-09-27 18:20 ` [PATCH 09/14] libdw, libdwfl: Save original path of ELF file Omar Sandoval
2023-11-02 17:04 ` Mark Wielaard
2023-11-07 6:46 ` Omar Sandoval
2023-09-27 18:20 ` [PATCH 10/14] libdw: Try .dwp file in __libdw_find_split_unit() Omar Sandoval
2023-11-02 19:56 ` Mark Wielaard
2023-11-07 7:07 ` Omar Sandoval
2023-09-27 18:21 ` [PATCH 11/14] tests: Handle DW_MACRO_{define,undef}_{strx,sup} in dwarf-getmacros Omar Sandoval
2023-11-02 20:30 ` [PATCH 11/14] tests: Handle DW_MACRO_{define, undef}_{strx, sup} " Mark Wielaard
2023-09-27 18:21 ` [PATCH 12/14] tests: Optionally dump all units " Omar Sandoval
2023-11-02 20:39 ` Mark Wielaard
2023-09-27 18:21 ` [PATCH 13/14] libdw: Apply DWARF package file section offsets where appropriate Omar Sandoval
2023-11-02 22:20 ` Mark Wielaard
2023-11-07 16:55 ` Omar Sandoval
2023-09-27 18:21 ` [PATCH 14/14] libdw: Handle overflowed DW_SECT_INFO offsets in DWARF package file indexes Omar Sandoval
2023-09-27 19:20 ` [PATCH 00/14] elfutils: DWARF package (.dwp) file support Frank Ch. Eigler
2023-09-27 20:17 ` Omar Sandoval
2023-10-03 21:54 ` Mark Wielaard
2023-11-02 23:05 ` Mark Wielaard
2023-11-07 17:13 ` Omar Sandoval
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=5837a252931d4a85079d29d08f8b6890ae070700.1695837512.git.osandov@fb.com \
--to=osandov@osandov.com \
--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).