From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128060 invoked by alias); 5 Jun 2018 21:23:54 -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 128048 invoked by uid 89); 5 Jun 2018 21:23:53 -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, 05 Jun 2018 21:23:52 +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 C9EDD301470B; Tue, 5 Jun 2018 23:23:49 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 6C0FF44263C1; Tue, 5 Jun 2018 23:23:49 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [PATCH] readelf: Always initialize .debug_addr unit_length, even without a header. Date: Tue, 05 Jun 2018 21:23:00 -0000 Message-Id: <1528233823-449-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/msg00156.txt.bz2 We would print a "fake" .debug_addr header, but didn't always setup the unit_length (in case there was a mix of GNU DebugFission and DWARF5 tables). Make sure to always set the unit_length (we do always calculate the next unit offset already). Signed-off-by: Mark Wielaard --- src/ChangeLog | 5 +++++ src/readelf.c | 7 ++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index ec07bb1..b213c91 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2018-06-05 Mark Wielaard + * readelf.c (print_debug_addr_section): Set unit_length always to + (next_unitp - readp) in case we don't have a real header. + +2018-06-05 Mark Wielaard + * readelf.c (print_debug_loc_section): Set begin to idx when failing to read the start address if DW_LLE_GNU_start_end_entry. diff --git a/src/readelf.c b/src/readelf.c index eaeb70c..d2c65fd 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -5149,10 +5149,7 @@ print_debug_addr_section (Dwfl_Module *dwflmod __attribute__ ((unused)), /* The addresses start here, but where do they end? */ listptr = get_listptr (&known_addrbases, idx); if (listptr == NULL) - { - next_unitp = readendp; - unit_length = (uint64_t) (next_unitp - readp); - } + next_unitp = readendp; else if (listptr->cu->version < 5) { next_unitp = start + listptr->offset; @@ -5163,7 +5160,6 @@ print_debug_addr_section (Dwfl_Module *dwflmod __attribute__ ((unused)), PRIx64, off); next_unitp = readendp; } - unit_length = (uint64_t) (next_unitp - readp); } else { @@ -5186,6 +5182,7 @@ print_debug_addr_section (Dwfl_Module *dwflmod __attribute__ ((unused)), next_unitp = readendp; } } + unit_length = (uint64_t) (next_unitp - readp); /* Pretend we have a header. */ printf ("\n"); -- 1.8.3.1