From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 87415 invoked by alias); 25 Apr 2018 11:24:28 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 87308 invoked by uid 89); 25 Apr 2018 11:24:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.4 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=specialised X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 25 Apr 2018 11:24:25 +0000 Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 9CB2331F8B4E; Wed, 25 Apr 2018 13:24:22 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 95FD2413CB83; Wed, 25 Apr 2018 13:24:22 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [PATCH] readelf: Handle .debug_line_str section. Date: Wed, 25 Apr 2018 11:24:00 -0000 Message-Id: <1524655458-1756-1-git-send-email-mark@klomp.org> X-Mailer: git-send-email 1.8.3.1 X-Spam-Flag: NO X-IsSubscribed: yes X-SW-Source: 2018-q2/txt/msg00021.txt.bz2 It is just a .debug_str section with another name. Signed-off-by: Mark Wielaard --- src/ChangeLog | 7 +++++++ src/readelf.c | 21 +++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 7764482..4b55bbc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2018-04-24 Mark Wielaard + + * readelf.c (print_debug_str_section): Take raw section data. Don't + use dwarf_getstring, but determine start and end of string from + offset and section data directly. + (print_debug): Handle ".debug_line_str" like ".debug_str". + 2018-04-19 Andreas Schwab * elflint.c (valid_e_machine): Add EM_RISCV. diff --git a/src/readelf.c b/src/readelf.c index 45fc826..c2fcfff 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -6105,6 +6105,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) case DW_FORM_indirect: case DW_FORM_strp: + case DW_FORM_line_strp: case DW_FORM_strx: case DW_FORM_strx1: case DW_FORM_strx2: @@ -8125,10 +8126,11 @@ print_debug_pubnames_section (Dwfl_Module *dwflmod __attribute__ ((unused)), static void print_debug_str_section (Dwfl_Module *dwflmod __attribute__ ((unused)), Ebl *ebl, GElf_Ehdr *ehdr, - Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg) + Elf_Scn *scn, GElf_Shdr *shdr, + Dwarf *dbg __attribute__ ((unused))) { - const size_t sh_size = (dbg->sectiondata[IDX_debug_str] ? - dbg->sectiondata[IDX_debug_str]->d_size : 0); + Elf_Data *data = elf_rawdata (scn, NULL); + const size_t sh_size = data ? data->d_size : 0; /* Compute floor(log16(shdr->sh_size)). */ GElf_Addr tmp = sh_size; @@ -8151,16 +8153,16 @@ print_debug_str_section (Dwfl_Module *dwflmod __attribute__ ((unused)), while (offset < sh_size) { size_t len; - const char *str = dwarf_getstring (dbg, offset, &len); - if (unlikely (str == NULL)) + const char *str = (const char *) data->d_buf + offset; + const char *endp = memchr (str, '\0', sh_size - offset); + if (unlikely (endp == NULL)) { - printf (gettext (" *** error while reading strings: %s\n"), - dwarf_errmsg (-1)); + printf (gettext (" *** error, missing string terminator\n")); break; } printf (" [%*" PRIx64 "] \"%s\"\n", digits, (uint64_t) offset, str); - + len = endp - str; offset += len + 1; } } @@ -8754,6 +8756,9 @@ print_debug (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr) NEW_SECTION (loc), NEW_SECTION (pubnames), NEW_SECTION (str), + /* A DWARF5 specialised debug string section. */ + { ".debug_line_str", section_str, + print_debug_str_section }, NEW_SECTION (macinfo), NEW_SECTION (macro), NEW_SECTION (ranges), -- 1.8.3.1