From patchwork Mon Oct 7 16:04:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Bushev X-Patchwork-Id: 98460 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 13292385F012 for ; Mon, 7 Oct 2024 16:06:53 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mta-03.yadro.com (mta-03.yadro.com [89.207.88.253]) by sourceware.org (Postfix) with ESMTPS id E6D363858CDA for ; Mon, 7 Oct 2024 16:06:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E6D363858CDA Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=syntacore.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=syntacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E6D363858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=89.207.88.253 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728317169; cv=none; b=TyyT639wgdaBkT7YEypOxg/Dwfuld212KruQRwIThqQEjnFDjoNh2Y5qx+aZKH40u9z/gY4xv8ld4CNK79fmHcOFh0U3KAF8sUkBbD0YFFs3/0+Jb/ryXizK+pEa2EpqVTx1qFRuQPGJc2t841CNqSSiCCWS1f/eGsM1e768MK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728317169; c=relaxed/simple; bh=8FCjF3bQwCcJrEi7VQtVQaq65cmN0LW1UNb5ylOpN0Q=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=fD5XNcwD0X0/kwyOxNEXtzTsamJBduV9B7h2uA8AdMq/TelG9XubCMynE3kIxSmDRYlT9zVBGw2TBEuKaydBMIi0KwtrA5cPIZdsgdR9UZwLhYBBMR+wl83gD2ZFQp7mKL9+lyi+U0/pvugU5CdisRaViFJaTG6Fg93h6hBxDgM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 mta-03.yadro.com EFC2EE0002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-04; t=1728317161; bh=ofgFy2dr4YVVw5Q0kAbJttuMavk1VxBuLWh21GZOmWA=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=nZ6QoZdGiyOYd75n6j6o1trMyMjvwEKa47LWASrJnlB1dc3ppAsU9nkVWjPaj2Fe7 BqmkulW79fSf7lETxYzx9s/0pqCIamGCfQ1TDfH0D+CrgzYDcT/mu8AQ7U+Zy6Fgc2 v8R2prwfMpV6w1anOMbMOq4yvPE6U5qGpojEnqLAK8/hCfBC1ZUg2YJ1mp0hDff6eA fH/yo95OfSYDlZULY7kxh8k1uc3nV9qqXQusojY05Ik1VVqRRwxMXUfZkZpsr22ayG 3c6/5QeXI8pNqHMHl+HBuxCJIi+2wLTSooAN7+DsXKpuA48L8W9hAfarRm06xxtMOs figAbOyCofr5g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-03; t=1728317161; bh=ofgFy2dr4YVVw5Q0kAbJttuMavk1VxBuLWh21GZOmWA=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=A0ryPbzV7lPqB2hyqMB+nMH9Er4On0Kx9YtG5933dv6q0qlDm5XwtY3Y9QxJIMEsT x6Mqqc95SbMHIcOEwSPc3hDJSlEbMxGwF6LikJ7VGYiZzoeDqNmka1hZ2VZRQJ7+CS p8UtErYR037XeMScE5x9x1vikOUCQeTiABIt1JX8gTaI/ac4NPSCl9sEoMl1xoUuJv iBVpLZkNG/c3S1BcuLvIXtiOFoDoPN6LLiSho9wLnykOBmM/csIvlMkmbLlJJJEHYq mG7JZ1QQjoxILZIckks1SBbNsa6ItHVnE2FKvuS4Gsst6AShOcVHjQltcjprmGsoBn iwLf2SJDM951A== From: To: CC: , Dmitry Bushev Subject: [PATCH v2] RISC-V/objdump: Do not re-seacrh for mapping symbols when didn't find any. Date: Mon, 7 Oct 2024 19:04:39 +0300 Message-ID: <20241007160439.566569-1-dmitry.bushev@syntacore.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-ClientProxiedBy: T-Exch-05.corp.yadro.com (172.17.10.109) To S-Exch-01.corp.yadro.com (10.78.5.241) X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, TXREP, T_SPF_PERMERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org From: Dmitry Bushev In object files without any mapping symbols it's better to not search up to start of a section upon each instruction entry. Instead, cache symbol number from which search was started and if no symbol found, next time do not search past that symbol. Signed-off-by: Dmitry Bushev --- opcodes/riscv-dis.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c index 551d57e4cba..2b84fbf2c7c 100644 --- a/opcodes/riscv-dis.c +++ b/opcodes/riscv-dis.c @@ -68,6 +68,7 @@ struct riscv_private_data /* Used for mapping symbols. */ static int last_map_symbol = -1; +static int no_map_symbols_before = 0; static bfd_vma last_stop_offset = 0; static bfd_vma last_map_symbol_boundary = 0; static enum riscv_seg_mstate last_map_state = MAP_NONE; @@ -1136,7 +1137,10 @@ riscv_search_mapping_symbol (bfd_vma memaddr, /* Reset the last_map_symbol if we start to dump a new section. */ if (memaddr <= 0) - last_map_symbol = -1; + { + last_map_symbol = -1; + no_map_symbols_before = 0; + } /* If the last stop offset is different from the current one, then don't use the last_map_symbol to search. We usually reset the @@ -1173,7 +1177,7 @@ riscv_search_mapping_symbol (bfd_vma memaddr, { n = from_last_map_symbol ? last_map_symbol : info->symtab_pos; - for (; n >= 0; n--) + for (; n >= no_map_symbols_before; n--) { bfd_vma addr = bfd_asymbol_value (info->symtab[n]); /* We have searched all possible symbols in the range. */ @@ -1220,6 +1224,11 @@ riscv_search_mapping_symbol (bfd_vma memaddr, if (!found_next) last_map_symbol_boundary = info->section->vma + info->section->size; } + else + /* Remember that we already scanned all symbols before symtab_pos and + * didn't find any. Next time, do not scan those symbols again. */ + no_map_symbols_before = info->symtab_pos; + /* Save the information for next use. */ last_map_symbol = symbol;