Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp106771rwl; Tue, 28 Mar 2023 22:00:42 -0700 (PDT) X-Google-Smtp-Source: AKy350Y0TL2iNNU3t7Q/bYBnGA0cC9un5je1meU8UuD6g6in+55V3wCpjVGx/XMyCDPnJb3ZSMsJ X-Received: by 2002:a17:907:1706:b0:946:c033:4d18 with SMTP id le6-20020a170907170600b00946c0334d18mr5739714ejc.13.1680066041964; Tue, 28 Mar 2023 22:00:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680066041; cv=none; d=google.com; s=arc-20160816; b=EruFoWc/aRIWDc6EbVzt5h4iTyXGZerBHgheUy6SUl/zqTiGIjbKKxgKdnXu70AVc/ uMjGe4eX8ZY6cYSP7cP/NK2k6NwMquok3zdn4wib9PAbZUwzAC9Tf2x+6iXt/lqjUAnr L9fC5JD7Ut+Cxszg2X8FUAcazHxMEFQuunYtPF73gl4+gwA+i/PAefjB73NoAKNa2j49 Wk6LnNXLuBSNsNdqacLCyU08ITRm0Xab1cmRFs9WDzxeXIwTfDtyJ5+ileZYPlXR/vTh jD/6XQS4RrxHgCSAVtb+3yz8n9bzNMF9Fti0sYVDCkqOI2UcKNM6wPK6q8LqHjdMk4fk AJOw== 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=dDDQpcu4wlArU6dZYMfeUKSEQsg6b1kdryOeCUrFQlc=; b=uHZoH4UCZ95x5FrjD0UKy5LPDl0BngElvirx1okD/3pnCsyjKxyfxCUmNJflUblPgH dsOblYreaQ9imiY338R5o873EzDKZuvvHTXL5WkYkqnWui0xVIC7tvCth7EfSK+fn9As ujSm79MUD2iY5CIxtEGu/BHum1TmgkZ2d4VBgXVgD2FrpuFzSmbW2BIY2FprFvntbLqI SmxKLQObsyVMVrrRVTajIJuroLtXmUTJ9kWTB8Qseujqd3miHC8UoJyN5ZTuXoG1zK/s 0Yu/G/USJ2kRSPAVSaxNzF2zUTdJVIiHzzfW5TJ1vpFN3ScBqFJxQNiyhn3QTwLLIYXi hi+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=VKRX5Tw8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j20-20020a170906255400b008cd6f50c059si31960855ejb.669.2023.03.28.22.00.15; Tue, 28 Mar 2023 22:00:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=VKRX5Tw8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229505AbjC2E5m (ORCPT + 99 others); Wed, 29 Mar 2023 00:57:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbjC2E5k (ORCPT ); Wed, 29 Mar 2023 00:57:40 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 877C92707 for ; Tue, 28 Mar 2023 21:57:39 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id p34so8110089wms.3 for ; Tue, 28 Mar 2023 21:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; t=1680065858; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dDDQpcu4wlArU6dZYMfeUKSEQsg6b1kdryOeCUrFQlc=; b=VKRX5Tw8ADg3H3As96bXMjtA9WlMjtkGfL47ArT3E95iTfus7FSaAJlBDnfp920k7x PdemGUW/YeLJrVkn6J1yQZSUU28mxt+AhtJugWUcs2fm2mUKZ0SkjAwTFfxmYAHWaBh9 34oXo9l0Qw8UjbcFYLjr6lPWCBQFUyc7ZMbeeKPlzhXYm2TxI9Zb/khVejjqkrAi2csd V36Yv1AqWNEsC+gGTi11hi+mhiFJz3StbOahvPtxZEULbxL//+Dp1E6LZNcu2MmWc2DD 5/N1MLJY4bAjXif0FAnP0Jx1XJ+xrmLt5ZpihM+Ked2Iheb0vjcAMP+KOvbGX43nq5Gq mrXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680065858; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dDDQpcu4wlArU6dZYMfeUKSEQsg6b1kdryOeCUrFQlc=; b=RfZNUQkjwl9QEvcdCf2GlZ1MyyazL3zdBhvAkEc2ZmzgtOFP6xX8F5nvsr9xmJzGYe 3oH1iz5QYy6m5mejkcgqyis7/gweFskI/f4CRHGFISP3zDHfRliK3BH8yQtTGNaNDkls GcLN925p3SxRMXVLY22iaLpGoKX9XQfvl01jo54wqGVDn1NkvSsVtr47ZU5VMNcfWMih 3l1cSt1u/y180KWLF7w2iuz/iS2982nDOjMRHg3RxiuO7TXvWkXWkLuCUwFVMbheEb55 diCxTifWl10at+vyiIbq6eOArh+o+dPQhzAu8MTUis7LcbDTMVIU8KzeG4V+6EiRO8Or Y/Ow== X-Gm-Message-State: AAQBX9eXBay6VtCb9JVUHryRg8eWHb6AhMEHq5k1BXmY6iELihjiEbJQ qxAcgnGSi6wdjJU3kW90nOuPoA== X-Received: by 2002:a05:600c:3789:b0:3ef:62cd:1ee with SMTP id o9-20020a05600c378900b003ef62cd01eemr11455074wmr.16.1680065858027; Tue, 28 Mar 2023 21:57:38 -0700 (PDT) Received: from alex-rivos.home (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id x19-20020a1c7c13000000b003ed1f111fdesm779942wmc.20.2023.03.28.21.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 21:57:37 -0700 (PDT) From: Alexandre Ghiti To: Nick Desaulniers , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Paul Walmsley , Palmer Dabbelt , Albert Ou , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kbuild@vger.kernel.org Cc: Alexandre Ghiti , Anup Patel Subject: [PATCH v9 4/6] powerpc: Move script to check relocations at compile time in scripts/ Date: Wed, 29 Mar 2023 06:53:27 +0200 Message-Id: <20230329045329.64565-5-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230329045329.64565-1-alexghiti@rivosinc.com> References: <20230329045329.64565-1-alexghiti@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandre Ghiti 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 63792af00417..6b350e75014c 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 '\