From patchwork Tue May 18 10:12:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandre Ghiti X-Patchwork-Id: 12264507 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=-17.1 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,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 DB204C433B4 for ; Tue, 18 May 2021 10:21:10 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 64FEC611B0 for ; Tue, 18 May 2021 10:21:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 64FEC611B0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jASK8Ayh88DZcPl47iYaK4o57N8zZiaPFdRzR0NEgB8=; b=BDldt3bEtULRpyFJ6oFBaWUhn VSX5HUyyPfETY8JnkLStiRK+kPY6nETeLecnKrdrv5FTltiVUII1FPGjveS21b905edXCxgJsxGcw KXwibhCXesOHiNiNpyJbMHfodQ8WJa6DgmaVG5ecgqIVwwziyE6Dg0rgpCTHH2FQ0I6RnOaFSVCOu Be9s/xtOK0qnFQBBKaMZyUrPt7UxC2FwAnwXgqYr4b5A0MWZCFNv6RxaMSO5Zmrap1wGNdk0FZxYn hP4mBWcBSvHrZRhcJNTH4WgvqHPJABuU/lTxMku2DkpsY3IwN+rdvHnzNGl2LES5U2mapvtnHaYvD CaPo+mYYg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1liwqJ-000LRj-VY; Tue, 18 May 2021 10:20:52 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1liwky-000Jkh-NF for linux-riscv@desiato.infradead.org; Tue, 18 May 2021 10:15:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=M9dDDHzMfR3R6pJCYVEIL/GRl5YZ0w6tBTuK0cpNRvY=; b=qXw1iDCMjUOUL/7tCeugGQswhm jzlU71VWO/fPWn10KH+Osle9D9RPR/qpiLlYLpQ9Rfnnbv9WGJw2rzuFXX6q+M5Y7m6Efm5Yxqz4F VnMxs5gDCVPz22oWfKO0qJ/J3NQnQajRQvHgxIjcOtgktQiJXkitp/v+1vYFsEc7eRVbKF4nn92ul HY7Sh8302m20qaZ//aXJQz46g/n/PW4GhLNw+AYFPZkK1c0z4MJH9D2j/OczWPpM5YWF/WjemujJV Hp0bOw+s8fbMs/92EGafPpMHQX/MR96OIkPsy+rMfXAh3kXZGFugar+9rK0N7UGlBfW5C4HxZK3IR laFigI8g==; Received: from relay10.mail.gandi.net ([217.70.178.230]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1liwkv-00EYHL-S8 for linux-riscv@lists.infradead.org; Tue, 18 May 2021 10:15:19 +0000 Received: (Authenticated sender: alex@ghiti.fr) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 2B23C24000D; Tue, 18 May 2021 10:15:09 +0000 (UTC) From: Alexandre Ghiti To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Alexandre Ghiti , Anup Patel Subject: [PATCH v6 2/3] powerpc: Move script to check relocations at compile time in scripts/ Date: Tue, 18 May 2021 12:12:51 +0200 Message-Id: <20210518101252.1484465-3-alex@ghiti.fr> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210518101252.1484465-1-alex@ghiti.fr> References: <20210518101252.1484465-1-alex@ghiti.fr> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210518_031518_064918_BC666168 X-CRM114-Status: GOOD ( 13.59 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Relocating kernel at runtime is done very early in the boot process, so it is not convenient to check for relocations there and react in case a relocation was not expected. Powerpc architecture has a script that allows to check at compile time for such unexpected relocations: extract the common logic to scripts/ so that other architectures can take advantage of it. Signed-off-by: Alexandre Ghiti Reviewed-by: Anup Patel Acked-by: Michael Ellerman (powerpc) --- arch/powerpc/tools/relocs_check.sh | 18 ++---------------- scripts/relocs_check.sh | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 16 deletions(-) create mode 100755 scripts/relocs_check.sh diff --git a/arch/powerpc/tools/relocs_check.sh b/arch/powerpc/tools/relocs_check.sh index 014e00e74d2b..e367895941ae 100755 --- a/arch/powerpc/tools/relocs_check.sh +++ b/arch/powerpc/tools/relocs_check.sh @@ -15,21 +15,8 @@ if [ $# -lt 3 ]; then exit 1 fi -# Have Kbuild supply the path to objdump and nm so we handle cross compilation. -objdump="$1" -nm="$2" -vmlinux="$3" - -# Remove from the bad relocations those that match an undefined weak symbol -# which will result in an absolute relocation to 0. -# Weak unresolved symbols are of that form in nm output: -# " w _binary__btf_vmlinux_bin_end" -undef_weak_symbols=$($nm "$vmlinux" | awk '$1 ~ /w/ { print $2 }') - bad_relocs=$( -$objdump -R "$vmlinux" | - # Only look at relocation lines. - grep -E '\