From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84316 invoked by alias); 15 May 2018 10:33:44 -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 84305 invoked by uid 89); 15 May 2018 10:33:44 -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= 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; Tue, 15 May 2018 10:33:42 +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 2A4F8302BB04; Tue, 15 May 2018 12:33:39 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id DD874414C685; Tue, 15 May 2018 12:33:39 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [PATCH] libdw, readelf: Handle .debug_*.dwo section name variants. Date: Tue, 15 May 2018 10:33:00 -0000 Message-Id: <1526380413-26703-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/msg00044.txt.bz2 The .debug_*.dwo section names are handled just like their none .dwo variants. The section contents is the same as sections without the .dwo name, but they are only found in split-dwarf files. This patch allows opening and inspecting split-dwarf files. It doesn't yet connect the split-dwarf with their skeleton (or the other way around). It also doesn't yet handle any special split-dwarf attributes or tags. Signed-off-by: Mark Wielaard --- libdw/ChangeLog | 5 +++++ libdw/dwarf_begin_elf.c | 31 +++++++++++++++++++++---------- src/ChangeLog | 4 ++++ src/readelf.c | 32 +++++++++++++++++++++----------- 4 files changed, 51 insertions(+), 21 deletions(-) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index e66a1ec..42777b5 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,8 @@ +2018-05-12 Mark Wielaard + + * dwarf_begin_elf.c (check_section): Also recognize .dwo section + name variants. + 2018-05-11 Mark Wielaard * dwarf_formudata.c (dwarf_formudata): Handle DW_AT_macros as macptr. diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c index 8bdcea2..61de752 100644 --- a/libdw/dwarf_begin_elf.c +++ b/libdw/dwarf_begin_elf.c @@ -1,7 +1,6 @@ /* Create descriptor from ELF descriptor for processing file. - Copyright (C) 2002-2011, 2014, 2015, 2018 Red Hat, Inc. + Copyright (C) 2002-2011, 2014, 2015, 2017, 2018 Red Hat, Inc. This file is part of elfutils. - Written by Ulrich Drepper , 2002. This file is free software; you can redistribute it and/or modify it under the terms of either @@ -116,14 +115,26 @@ check_section (Dwarf *result, GElf_Ehdr *ehdr, Elf_Scn *scn, bool inscngrp) size_t cnt; bool gnu_compressed = false; for (cnt = 0; cnt < ndwarf_scnnames; ++cnt) - if (strcmp (scnname, dwarf_scnnames[cnt]) == 0) - break; - else if (scnname[0] == '.' && scnname[1] == 'z' - && strcmp (&scnname[2], &dwarf_scnnames[cnt][1]) == 0) - { - gnu_compressed = true; - break; - } + { + 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 + && strstr (scnname, ".dwo") == scnname + dbglen))) + break; + else if (scnname[0] == '.' && scnname[1] == 'z' + && (strncmp (&scnname[2], &dwarf_scnnames[cnt][1], + dbglen - 1) == 0 + && (scnlen == dbglen + 1 + || (scnlen == dbglen + 5 + && strstr (scnname, + ".dwo") == scnname + dbglen + 1)))) + { + gnu_compressed = true; + break; + } + } if (cnt >= ndwarf_scnnames) /* Not a debug section; ignore it. */ diff --git a/src/ChangeLog b/src/ChangeLog index 419fa20..9b5ef79 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2018-05-12 Mark Wielaard + + * readelf.c (print_debug): Also recognize .dwo section name variants. + 2018-05-15 Mark Wielaard * readelf.c (print_form_data): Cast comparisons against offset_len to diff --git a/src/readelf.c b/src/readelf.c index 854d31c..f34dd36 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -9127,17 +9127,27 @@ print_debug (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr) int n; for (n = 0; n < ndebug_sections; ++n) - if (strcmp (name, debug_sections[n].name) == 0 - || (name[0] == '.' && name[1] == 'z' - && debug_sections[n].name[1] == 'd' - && strcmp (&name[2], &debug_sections[n].name[1]) == 0) - ) - { - if ((print_debug_sections | implicit_debug_sections) - & debug_sections[n].bitmask) - debug_sections[n].fp (dwflmod, ebl, ehdr, scn, shdr, dbg); - break; - } + { + size_t dbglen = strlen (debug_sections[n].name); + size_t scnlen = strlen (name); + if ((strncmp (name, debug_sections[n].name, dbglen) == 0 + && (dbglen == scnlen + || (scnlen == dbglen + 4 + && strstr (name, ".dwo") == name + dbglen))) + || (name[0] == '.' && name[1] == 'z' + && debug_sections[n].name[1] == 'd' + && strncmp (&name[2], &debug_sections[n].name[1], + dbglen - 1) == 0 + && (scnlen == dbglen + 1 + || (scnlen == dbglen + 5 + && strstr (name, ".dwo") == name + dbglen + 1)))) + { + if ((print_debug_sections | implicit_debug_sections) + & debug_sections[n].bitmask) + debug_sections[n].fp (dwflmod, ebl, ehdr, scn, shdr, dbg); + break; + } + } } } -- 1.8.3.1