From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10029 invoked by alias); 16 Apr 2018 08:32:59 -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 9250 invoked by uid 89); 16 Apr 2018 08:32:58 -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,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1825 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,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; Mon, 16 Apr 2018 08:32:57 +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 2E209302BB23; Mon, 16 Apr 2018 10:32:55 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 028C6413CEBB; Mon, 16 Apr 2018 10:32:54 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [COMMITTED] readelf: Fix advance_pc to use op_addr_advance, not just op_advance. Date: Mon, 16 Apr 2018 08:32:00 -0000 Message-Id: <1523867573-13059-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/msg00011.txt.bz2 Found by John Mellor-Crummey. The reason this bug wasn't found earlier is because gcc fixes minimum_instr_len and max_ops_per_instr to 1 for all architectures (in theory max_ops_per_instr could be overridden, but I didn't find any architecture that does). And op_index always seems zero (it looks like it is really only for special VLWI architectures). So in all cases I saw it means that: op_addr_advance = minimum_instr_len * ((op_index + op_advance) / max_ops_per_instr) = 1 * ((0 + op_advance) / 1) = op_advance Completely masking the bug. The libdw dwarf_getsrclines.c implementation does get this right. Because it doesn't care about the data representation and so does the calculation directly. Signed-off-by: Mark Wielaard --- src/ChangeLog | 5 +++++ src/readelf.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 068c87b..2d525e6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2018-04-16 Mark Wielaard + + * readelf.c (print_debug_line_section). In advance_pc, advance + using op_addr_advance, not op_advance. + 2018-04-14 Mark Wielaard * readelf.c (attr_callback): Only show errors when not silent. diff --git a/src/readelf.c b/src/readelf.c index 8c0ef6c..45fc826 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -6971,7 +6971,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, { op_addr_advance = minimum_instr_len * ((op_index + op_advance) / max_ops_per_instr); - address += op_advance; + address += op_addr_advance; show_op_index = (op_index > 0 || (op_index + op_advance) % max_ops_per_instr > 0); op_index = (op_index + op_advance) % max_ops_per_instr; -- 1.8.3.1