Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp449633pxb; Wed, 20 Jan 2021 10:55:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXO9suuqmhWlPlNCvEe553jitnt5wNK95Yf2TfDO7Fo2anHhwig8OyDnHz3XsuGeSM5haN X-Received: by 2002:a05:6402:3192:: with SMTP id di18mr8096254edb.332.1611168931477; Wed, 20 Jan 2021 10:55:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611168931; cv=none; d=google.com; s=arc-20160816; b=Ea6hBeJKCcNmAH5GQ9DKfHtsaemTdm6tEuMw9CT8FWQz+gDX6KBKbE8Q4VfTCt/DED 6p7dwemv4q7YzwP73sP926Mahh2AvZxaNBMdb2plhC7a4nqiHg7srmLcoPxj4iF19kGC e1ueaQZO+H7JpAXXxhPe/ErdffilB7YiTJWSr/FFgtfixXdT3J0EVUXlfvUhu0hnoV9X 1j4fvmAUZIEw4IsfoeHR3TjZZqvvWpA3/5xeyQAlkXCrfEyExG1azup2YslYYUcxeGX/ B10mrlC3OvZJ27JGQRjN+YAo2VVNnrs5j4vTcf3wV00y4dlyXjMyb9oA+G+daEv0DITE cCXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=h+7NJAZ5HEs+o3c9ngN8mAhWOXYs+DN99Jpiq66kpMs=; b=UP7RgmUmG+b3qSxM8IKywLCx4FunKIqfDYCXekjLI5eY/rBWOaq6hayAm8ZDmhPM2/ LSB7RRP3HwuXc0RC9Cka+k9eZkXvAdqLGzSH0cN5fqnpqcD10nq0+B63jj1ilbNCFdoc Y5eebWoqTYA6t3jHhnLR+SrjO17Z2CPbiVeciBcozDJBt7OUzLrLOFwCX5MXvRFo9dRV W5WG4XBHMCdbVQSeV62OkZVo7aBOdSUigUchgqbBGrl0in8VTW2Mc0HknIC4HyyeOHEb D2Zyw4DMgIANwTl8hMXEaE8/4w8u5zi/OxL2h3UAr177gz8aERyiBCjvElW9937SoV2M j7ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Yw5rVZSw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk23si1176615edb.368.2021.01.20.10.55.05; Wed, 20 Jan 2021 10:55:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Yw5rVZSw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728784AbhATSwk (ORCPT + 99 others); Wed, 20 Jan 2021 13:52:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54226 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390165AbhATRkO (ORCPT ); Wed, 20 Jan 2021 12:40:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611164323; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h+7NJAZ5HEs+o3c9ngN8mAhWOXYs+DN99Jpiq66kpMs=; b=Yw5rVZSwvs6aqU8vNNdV3rASPLwrytwktzAST4fNX6WhajyL0cPqWHZXXoUKkjq+g+NIWV tq1kRR4KPVcBrVDSkeUkDABSbEBTVgtLAEkIG+8nQunFh2GztfC7bnTrl3jAmh4ELDASed 4MYceELonvfnd7zQFdo7CVcQp8Zbu2o= 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-231-Alz-lFMbMpuPQtvTc962Mw-1; Wed, 20 Jan 2021 12:38:41 -0500 X-MC-Unique: Alz-lFMbMpuPQtvTc962Mw-1 Received: by mail-wm1-f72.google.com with SMTP id u1so1834172wml.2 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=AnS0Wx0Y7vNGi5dcXHD8S7SgHETPQjV9QK8dXE6PgNDNOdgLASXjBsDSp0obtUDcJZ W+oRXYC9ypG1eXZpsRrsV2toOazMUmRiHSatxgkhX33mWKfBfFSty0lz3Dle0c5XwUbN WY9MldFxf1DHmkqu3q1NM15h8wE2tnMU7UVpJ1PdfCR9sSDjf0zSBfHkIUIaroUWF8cp /CyL3BDEZObzSOrGGtdEmZTyFKV1MSPCHme0dGn9zlKBnjXByNsnihd1eHfZtsHpL4lz JQ/XgJRHN4zW1MaTJfw76dOs1+M9qqHwzLimFLXxDjdcuufiUZwXM5AGx2xGBCkGhC7K Zm9w== X-Gm-Message-State: AOAM530cKSeoxCjhX1Ob/5TaEhaC2SyVfrpAppd46f8joQKg3E0/oGo0 LDMZxZbBVCSaS+oMS+SC9Rc9QI3RNvQ/3+V7aNCgLq83jPYCneDi+7Nd7IVK+zxrFEw2q1+2i7+ Wt85lyEQX0ANgug2TMvyOY4dveIEF7io0LhKdCSpzcC4bYh99uOXvRGHihVWnY4uUBZ1UpCQZgp Fg X-Received: by 2002:adf:fa92:: with SMTP id h18mr4344324wrr.142.1611164320568; Wed, 20 Jan 2021 09:38:40 -0800 (PST) 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 Cc: catalin.marinas@arm.com, will@kernel.org, ardb@kernel.org, masahiroy@kernel.org, keescook@chromium.org, michal.lkml@markovi.net, jpoimboe@redhat.com, peterz@infradead.org, mark.rutland@arm.com, broonie@kernel.org, linux-efi@vger.kernel.org, linux-hardening@vger.kernel.org, Julien Thierry 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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; -- 2.25.4