[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/5] xen/tools: remove usages of `stat -s` in check-endbr.sh


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Wed, 11 Feb 2026 11:08:14 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=citrix.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=omeW+HwHxjhhmMyqROUjTaoySPW34Najk1rGtQyUc/Y=; b=pmiZSi4G+t4PSRGRFiKxUBBCItNFGXUDlcQQo2uowuvhDGj2D+3HTj6XoVMT2vdc9M9QsUIlduPPJBi4SDrhuENDgSSHIY15KNjMRKUPatkkkPXYc2ODSAKyBxCnHZDZ6gb77pYgBR6YK3ucz9wEFaYPOkPSZoqTHDsjQqho8RSXKeDOYXvX7udeXZbs1n/pGpLWBF1JGkNzVYMPIAaGD25iFdh53QowVtaZCPkzPsKaXtFA8iFoWujhEVCjEzQyaqkj9TRaWAwOUkiKWt1zd+qD6/gxnEphA5TBlHr/7sq2tFuNu53oNndhVZVHjSkzPn0R0vFrlp8tWhsuP+UqWw==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=omeW+HwHxjhhmMyqROUjTaoySPW34Najk1rGtQyUc/Y=; b=T3Pi9gRb05FVV2izm0fj7eqHOix4dvuTSWibXJ6MLxBnyOVfJggaNd0UKm03xovfDwVlAuyCjpFUq6hqS11otmsXIOtpgswxzOPxEiW0QeIMEf7f+h9p+RdJv95h+gBtFPc3JjnVU+0lZpYWAgrBIPhgiS6uKM1P0eFAKjP8uVn6WpSbct/hfSFV7dG6eBGfkVlJUKKHGiXA85FwvkL7JCtzuqKzP/QKzvDWycanAGE7duruRlz/OsThyDNzJzaGZhNoufXji+WuZ/vuEjM1pYu2rRc2K3HOIKFq7piFZdA2/2HBrtBN3ck9Y8c5otK3H7bJmT1+BMCKOl16SXit+Q==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=DZtO/PDlacwKc+7IGQoD1yMIMfvTwnVkD/1wWWwcDW8cfSp7GhcZBN7hjYmjElipoQRXZ2is21sKrrzUNKks+ANMZi8hp4ypwiPm+gevSDWz4fi76lT4HaEIs/F0b955716yGU9fLMIK/CEF42kWTrKV4zq1l0yJUaL3ijSZ/31/1DjsrCnQwfoF4OpVOkJfJnIL3KZsG/C5c6eO0eVMgKstHDcGsjqRsMAUgLqb9mG4bk1NEO456CNFGxi5N0kxop+IViiKaCGqpnRIVePJ13bC5sK1WtshFNPqwUHbNLr1qDlhAczP08CdEtH+c7ZQQWNov5ZEwh9KPa9T8JTnRQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UwusZM5CdIqxeANoBcj1O5RCnt1aqF9PihynA0TS6JvLyAkH1xLpUL9PXWfqE9U0sLdMA4dWCg9mrfjTJ+gk9OpCjphrVbjsIRnO9yGvI3CtqjfCX6wpgLGyYrUZ3SMswSbFNiFFa7G5X7dAVRvLP7Kt9IHDw34C1kZ2ckU8frxGeDDYrRaS12HUOdiXP3q9/Egav/xMJV3jAYrZEd7ripdLNY+9kmtaprgCiQ/OsRjvG/QMc/E2qxipiZBpmpXZkMXO2VhNrpi7hnNfHc0NHQ/+0NRvHkjvsnzMquQj+QTEy9NIdGhcM9Dv/ogdcIj9Cp5zG1bSJ1yWP3Ug0rBwxQ==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Wed, 11 Feb 2026 11:09:30 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHcm0PEG2YcjpXtf0qy6VnbXjUrurV9VtsA
  • Thread-topic: [PATCH 2/5] xen/tools: remove usages of `stat -s` in check-endbr.sh

Hi Roger,

> On 11 Feb 2026, at 11:46, Roger Pau Monne <roger.pau@xxxxxxxxxx> wrote:
> 
> The `-s` option to stat is not POSIX compatible, and hence prevents the
> check-endbr.sh script from running reliably.
> 
> The first instance of `stat -s` can be removed by fetching the section size
> from the output of objdump itself, which the script already parses to get
> the VMA values.
> 
> The other two instances can be replaced by counting the lines in the
> respective files.  Those files contain list of addresses, so the size in
> bytes is not strictly needed, we can count the number of lines instead.

I can confirm compilation works on my side and changes seem coherent
but i would like an x86 maintainer to review/ack this one to confirm that
functionally it is ok.

> 
> Suggested-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

Acked-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>

Cheers
Bertrand

> ---
> xen/tools/check-endbr.sh | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/xen/tools/check-endbr.sh b/xen/tools/check-endbr.sh
> index bf153a570db4..383d7e710a53 100755
> --- a/xen/tools/check-endbr.sh
> +++ b/xen/tools/check-endbr.sh
> @@ -92,14 +92,15 @@ ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut 
> -f 1 -d ':' > $VALID &
> #    check nevertheless.
> #
> eval $(${OBJDUMP} -j .text $1 -h |
> -    $AWK '$2 == ".text" {printf "vma_hi=%s\nvma_lo=%s\n", substr($4, 1, 9), 
> substr($4, 10, 16)}')
> +    $AWK '$2 == ".text" {printf "bin_sz=%s\nvma_hi=%s\nvma_lo=%s\n", "0x" 
> $3, substr($4, 1, 9), substr($4, 10, 16)}')
> 
> -${OBJCOPY} -j .text $1 -O binary $TEXT_BIN
> -
> -bin_sz=$(stat -c '%s' $TEXT_BIN)
> +# Convert objdump hex reported .text size to decimal
> +bin_sz=$(printf %u $bin_sz)
> [ "$bin_sz" -ge $(((1 << 28) - $vma_lo)) ] &&
>     { echo "$MSG_PFX Error: .text offsets must not exceed 256M" >&2; exit 1; }
> 
> +${OBJCOPY} -j .text $1 -O binary $TEXT_BIN
> +
> # instruction:    hex:           oct:
> # endbr64         f3 0f 1e fa    363 017 036 372
> # endbr32         f3 0f 1e fb    363 017 036 373
> @@ -116,8 +117,8 @@ fi | $AWK -F':' '{printf "%s%07x\n", "'$vma_hi'", 
> int('$((0x$vma_lo))') + $1}' >
> wait
> 
> # Sanity check $VALID and $ALL, in case the string parsing bitrots
> -val_sz=$(stat -c '%s' $VALID)
> -all_sz=$(stat -c '%s' $ALL)
> +val_sz=$(wc -l < $VALID)
> +all_sz=$(wc -l < $ALL)
> [ "$val_sz" -eq 0 ]         && { echo "$MSG_PFX Error: Empty valid-addrs" 
> >&2; exit 1; }
> [ "$all_sz" -eq 0 ]         && { echo "$MSG_PFX Error: Empty all-addrs" >&2; 
> exit 1; }
> [ "$all_sz" -lt "$val_sz" ] && { echo "$MSG_PFX Error: More valid-addrs than 
> all-addrs" >&2; exit 1; }
> -- 
> 2.51.0
> 


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.