From patchwork Wed Jan 20 17:37:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 12033099 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51D07C433E0 for ; Wed, 20 Jan 2021 17:47:57 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E26C1223DB for ; Wed, 20 Jan 2021 17:47:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E26C1223DB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=hVLL/y7+s1T/gpSvzJ9FaASfXLhTQ4oj6AfscJ0X33o=; b=xtWjhHr55Ya/ZTnK2DBqsD/v1 6Wo0WjcxbA1KolrmMlEqwz7zxP/ofkBmfLWxPDD9Ma52dDxUq+lsV4XJ2aFluYGC8ZhkRk8O71c4t mHAFIfuCkXjrTY6pPH82jBisRdTbWUBDmmQe+n9pnAfeKO/X5enjKXk3JSWBOi+/24t36V1Fv2jry HYm+BnkpaSO4jPoUThJWvKYgyr4GesXz88dGw0C55Vwy8lzCkAq22pevq7jLc8PDPmbWZbQQioZAB zARHZfXpsiMPsjzj8/nVSwG2NKL8OtM0bpQ13d2mOhgGHjH8synJ30tKTHm+E1yuX3SU3kYYaOgvG Fb7WzHs2g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2HY9-0006k9-Hh; Wed, 20 Jan 2021 17:45:46 +0000 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2HRS-000337-Fp for linux-arm-kernel@lists.infradead.org; Wed, 20 Jan 2021 17:38:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611164325; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h+7NJAZ5HEs+o3c9ngN8mAhWOXYs+DN99Jpiq66kpMs=; b=Ztc4x4ubQkNbmWi5guyIeMU0ONTkMeigPV6j86YNERgMofn3+crsOYWBU/WOoR/aelMjKs 6XlFqeAryV5mKJTyXdCvnWvK653+1DvG8uPM3rvzJXZji0mngoXhXFT4Hff5C4Yy7k4Jka ZaCcsqOo2MWqcYq4KBll+BVe4GLPhvc= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-580-8fjB400IOZyc8JO9Rl7i9Q-1; Wed, 20 Jan 2021 12:38:41 -0500 X-MC-Unique: 8fjB400IOZyc8JO9Rl7i9Q-1 Received: by mail-wm1-f72.google.com with SMTP id d2so1836889wmc.1 for ; Wed, 20 Jan 2021 09:38:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h+7NJAZ5HEs+o3c9ngN8mAhWOXYs+DN99Jpiq66kpMs=; b=bfeiGRUbTDlTVKzCRbMOpDGXpDEQ2MuGeNG7SSk0OB8GpO3uBH60mdqVxkN387ytGB SDvau90JE9yXL4KASBJF11QysyJkjOeEXSBKllHZ5vWFqL965Cp07xRtA7kUvKjAW+dF MERgNbNhty5KeHd6uWLoLW73BkMOc0xtJ3TYdKEMgI9fuGQZo5OBYBPkKF2m4NiW0jQe HDBAxmfJ6iK34gFuig+6BLw0Y+iolincvy/yKn14YwiUDo6OhG/jaOYcEOpg8aF5RuYY vl1Kolc3oVlS27CQ0O0ZgOSRFVCkpEMl9MBESOLLWQSZBQ/OiYIkx5RYvQHZGxIdllcK +lLg== X-Gm-Message-State: AOAM530P0lzBAhhMynHQFNEwHJEP3Nsn8k3hHQblzIPLZPvraPBx5yqy evgZdn/ulo+tkpl8tKz76o5udJm+wIgMfWVdn5aoUUTd/ZoPOaE0JauT1zS4OuznCiWLwvInntK 53m/lg+qsbMxG+vc63wPHmCCoPEYsytz76DY= X-Received: by 2002:adf:fa92:: with SMTP id h18mr4344311wrr.142.1611164320484; Wed, 20 Jan 2021 09:38:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDeWheflvYEpolU09LBJTJ+72qBUJL1UqdbbjxQT7QJExRg0tyCLTSK2CpCQqblVViiEwsaA== X-Received: by 2002:adf:fa92:: with SMTP id h18mr4344296wrr.142.1611164320375; Wed, 20 Jan 2021 09:38:40 -0800 (PST) Received: from redfedo.redhat.com ([2a01:cb14:499:3d00:cd47:f651:9d80:157a]) by smtp.gmail.com with ESMTPSA id x11sm4948325wmi.4.2021.01.20.09.38.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 09:38:40 -0800 (PST) From: Julien Thierry To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 14/17] objtool: arm64: Cache section with switch table information Date: Wed, 20 Jan 2021 18:37:57 +0100 Message-Id: <20210120173800.1660730-15-jthierry@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210120173800.1660730-1-jthierry@redhat.com> References: <20210120173800.1660730-1-jthierry@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jthierry@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210120_123851_100117_1C9B865A X-CRM114-Status: GOOD ( 14.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, linux-efi@vger.kernel.org, michal.lkml@markovi.net, keescook@chromium.org, peterz@infradead.org, catalin.marinas@arm.com, masahiroy@kernel.org, broonie@kernel.org, linux-hardening@vger.kernel.org, jpoimboe@redhat.com, will@kernel.org, ardb@kernel.org, Julien Thierry Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Section ".discard.switch_table_info", created by the gcc plugin will be looked up for every dynamic jump in the object file while the section might not even exist. Cache the result of the first lookup. Signed-off-by: Julien Thierry --- tools/objtool/arch/arm64/special.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/objtool/arch/arm64/special.c b/tools/objtool/arch/arm64/special.c index 396b9c5feebd..c9c3e0bfd581 100644 --- a/tools/objtool/arch/arm64/special.c +++ b/tools/objtool/arch/arm64/special.c @@ -33,6 +33,19 @@ bool arch_support_alt_relocation(struct special_alt *special_alt, return false; } +static struct section *get_switch_table_info_section(struct objtool_file *file) +{ + static bool first = true; + static struct section *info_section = NULL; + + if (first) { + first = false; + info_section = find_section_by_name(file->elf, + ".discard.switch_table_info"); + } + + return info_section; +} /* * Aarch64 jump tables are just arrays of offsets (of varying size/signess) @@ -64,8 +77,7 @@ struct reloc *arch_find_switch_table(struct objtool_file *file, void *sti_sec_start; struct reloc *text_reloc; - table_info_sec = find_section_by_name(file->elf, - ".discard.switch_table_info"); + table_info_sec = get_switch_table_info_section(file); if (!table_info_sec) goto try_c_jmptbl;