Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74D72C433EF for ; Sat, 20 Nov 2021 16:53:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237791AbhKTQ4q (ORCPT ); Sat, 20 Nov 2021 11:56:46 -0500 Received: from sonic309-21.consmr.mail.gq1.yahoo.com ([98.137.65.147]:41072 "EHLO sonic309-21.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231263AbhKTQ4p (ORCPT ); Sat, 20 Nov 2021 11:56:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.ca; s=s2048; t=1637427220; bh=XhUUxjuDvptKLJmrBs1uaon9Jq/bsYpRu4clgNCUXf8=; h=From:To:Cc:Subject:Date:References:From:Subject:Reply-To; b=l0FwT52BIKpqDLH4QhvJ8k2VYG3coeeoRRl41WebyZJI0unkYWCAZkw9NCMUwJ9IJVjczTXYbc1sbrjXtsW2avEwMj+EFfLQdslxPYZZDOSqf4iifMBh6KhOCPTgOVQforUNG+SOU1jQLg8hdsvj0XwN6mKWDgZ88VMAj7eRWUz4J7RIeEB9JAtLLyaDJt+c/i9wtkRwaTaeN/9d2Sk4+qJlpZnrWwyF7t0VJJSo+lZPRDjzJ33bwWVveHd2O5yhaRAQMVPrUhDefcGIHgQeAMqUf8dalDsiYRcWDHf5FL2DnCZSWABV7SEdyIxbYp8unBdWTfFMoaoMG+Uhpaqr3g== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1637427220; bh=fi63ap3v/Awv027m64D8EfFCe9wJJgP0fR4dzkQ9oT4=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=ePaj4YDk8iQuA0+4zVzv0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2PHud8m3uHGYtlTpQ664Y1K.U3N3coZwKPolcIK2brxNJ7vQvUjc4iuK2k h9GpeJIYkQTl9MlGqnNVR.CPWHLxxLo7SV7ASAZ6e.2sG_8AhF1VSvrnxALPbJ_jgOBwAaYwrvND .tT.olXKem3x4m5x1SvaEvUdFujlqoYKztvVntWhdhr5Gj_akZZTqrVZ4Hh4fBU21kkiFzxHCOKE bz.gxM3cWpfBPHwp0BncU3UXVCtoRNui7PYA.k_LNLScBHgbluN6oNWoCVDq2.vXXa2R8WMIBZ4f 9iV27YSELi7GD_RXgrYWaA62bgFS4592shRyyBXrfjaAQPHLbGwnS0AmE5l97v5TqlvudB2_KAMl KFnyUS5.zUAUBdjgYegJO1.W44N4SRsKQv19Xfq9WNnvgl7oDgCSou2DWjkVXW5Y7Rqf4zF3ZHei ceV.hQvKs_IuxKzxezfQlxQJALBfh4QAe7Gh3cbJl4NZuQyhg6nGWXOzPOI0btS6HY.rBgQ-- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.gq1.yahoo.com with HTTP; Sat, 20 Nov 2021 16:53:40 +0000 Received: by kubenode512.mail-prod1.omega.bf1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID bca1f4b1a1f1ece8fed7763af8799d9a; Sat, 20 Nov 2021 16:53:37 +0000 (UTC) From: "Alex Xu (Hello71)" To: Michael Forney , Masahiro Yamada , Michal Marek , Nick Desaulniers , Nick Terrell , Ingo Molnar , Sedat Dilek , Kees Cook , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Cc: "Alex Xu (Hello71)" Subject: [PATCH 1/2] kbuild: use perl instead of shell to get file size Date: Sat, 20 Nov 2021 11:53:48 -0500 Message-Id: <20211120165349.99908-1-alex_y_xu@yahoo.ca> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit References: <20211120165349.99908-1-alex_y_xu.ref@yahoo.ca> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This makes it easier to get the size of multiple files. Perl is already a requirement for all builds to do header checks, so this is not an additional dependency. --- arch/arm/boot/deflate_xip_data.sh | 2 +- arch/powerpc/boot/wrapper | 2 +- scripts/Makefile.lib | 9 ++------- scripts/file-size.pl | 8 ++++++++ scripts/file-size.sh | 4 ---- scripts/link-vmlinux.sh | 4 ++-- 6 files changed, 14 insertions(+), 15 deletions(-) create mode 100755 scripts/file-size.pl delete mode 100755 scripts/file-size.sh diff --git a/arch/arm/boot/deflate_xip_data.sh b/arch/arm/boot/deflate_xip_data.sh index 304495c3c2c5..14cfa2babb93 100755 --- a/arch/arm/boot/deflate_xip_data.sh +++ b/arch/arm/boot/deflate_xip_data.sh @@ -43,7 +43,7 @@ data_start=$(($__data_loc - $base_offset)) data_end=$(($_edata_loc - $base_offset)) # Make sure data occupies the last part of the file. -file_end=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" "$XIPIMAGE") +file_end=$(${PERL} "${srctree}/scripts/file-size.pl" "$XIPIMAGE") if [ "$file_end" != "$data_end" ]; then printf "end of xipImage doesn't match with _edata_loc (%#x vs %#x)\n" \ $(($file_end + $base_offset)) $_edata_loc 1>&2 diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper index 9184eda780fd..9f9ee8613432 100755 --- a/arch/powerpc/boot/wrapper +++ b/arch/powerpc/boot/wrapper @@ -380,7 +380,7 @@ vmz="$tmpdir/`basename \"$kernel\"`.$ext" # Calculate the vmlinux.strip size ${CROSS}objcopy $objflags "$kernel" "$vmz.$$" -strip_size=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" "$vmz.$$") +strip_size=$(${PERL} "${srctree}/scripts/file-size.pl" "$vmz.$$") if [ -z "$cacheit" -o ! -f "$vmz$compression" -o "$vmz$compression" -ot "$kernel" ]; then # recompress the image if we need to diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index d1f865b8c0cb..ca901814986a 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -379,13 +379,8 @@ dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) # Bzip2 and LZMA do not include size in file... so we have to fake that; # append the size as a 32-bit littleendian number as gzip does. -size_append = printf $(shell \ -dec_size=0; \ -for F in $(real-prereqs); do \ - fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F); \ - dec_size=$$(expr $$dec_size + $$fsize); \ -done; \ -printf "%08x\n" $$dec_size | \ +total_size = $(shell $(PERL) $(srctree)/scripts/file-size.pl $(real-prereqs)) +size_append = printf $(shell printf "%08x\n" $(total_size) | \ sed 's/\(..\)/\1 /g' | { \ read ch0 ch1 ch2 ch3; \ for ch in $$ch3 $$ch2 $$ch1 $$ch0; do \ diff --git a/scripts/file-size.pl b/scripts/file-size.pl new file mode 100755 index 000000000000..170bb6d048fa --- /dev/null +++ b/scripts/file-size.pl @@ -0,0 +1,8 @@ +#!/usr/bin/perl -w +# SPDX-License-Identifier: GPL-2.0 +my $total = 0; +foreach (@ARGV) { + @stat = stat $_ or die "$_: $!"; + $total += $stat[7]; +} +print "$total\n"; diff --git a/scripts/file-size.sh b/scripts/file-size.sh deleted file mode 100755 index 7eb7423416b5..000000000000 --- a/scripts/file-size.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: GPL-2.0 -set -- $(ls -dn "$1") -printf '%s\n' "$5" diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 5cdd9bc5c385..c3fa38bd18ab 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -384,8 +384,8 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then kallsyms_step 2 # step 3 - size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso_prev}) - size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso}) + size1=$(${PERL} "${srctree}/scripts/file-size.pl" ${kallsymso_prev}) + size2=$(${PERL} "${srctree}/scripts/file-size.pl" ${kallsymso}) if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then kallsyms_step 3 -- 2.34.0