~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/boot/deflate_xip_data.sh

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/sh
  2 # SPDX-License-Identifier: GPL-2.0-only
  3 
  4 # XIP kernel .data segment compressor
  5 #
  6 # Created by:   Nicolas Pitre, August 2017
  7 # Copyright:    (C) 2017  Linaro Limited
  8 #
  9 
 10 # This script locates the start of the .data section in xipImage and
 11 # substitutes it with a compressed version. The needed offsets are obtained
 12 # from symbol addresses in vmlinux. It is expected that .data extends to
 13 # the end of xipImage.
 14 
 15 set -e
 16 
 17 VMLINUX="$1"
 18 XIPIMAGE="$2"
 19 
 20 DD="dd status=none"
 21 
 22 # Use "make V=1" to debug this script.
 23 case "$KBUILD_VERBOSE" in
 24 *1*)
 25         set -x
 26         ;;
 27 esac
 28 
 29 sym_val() {
 30         # extract hex value for symbol in $1
 31         local val=$($NM "$VMLINUX" 2>/dev/null | sed -n "/ $1\$/{s/ .*$//p;q}")
 32         [ "$val" ] || { echo "can't find $1 in $VMLINUX" 1>&2; exit 1; }
 33         # convert from hex to decimal
 34         echo $((0x$val))
 35 }
 36 
 37 __data_loc=$(sym_val __data_loc)
 38 _edata_loc=$(sym_val _edata_loc)
 39 base_offset=$(sym_val _xiprom)
 40 
 41 # convert to file based offsets
 42 data_start=$(($__data_loc - $base_offset))
 43 data_end=$(($_edata_loc - $base_offset))
 44 
 45 # Make sure data occupies the last part of the file.
 46 file_end=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" "$XIPIMAGE")
 47 if [ "$file_end" != "$data_end" ]; then
 48         printf "end of xipImage doesn't match with _edata_loc (%#x vs %#x)\n" \
 49                $(($file_end + $base_offset)) $_edata_loc 1>&2
 50         exit 1;
 51 fi
 52 
 53 # be ready to clean up
 54 trap 'rm -f "$XIPIMAGE.tmp"; exit 1' 1 2 3
 55 
 56 # substitute the data section by a compressed version
 57 $DD if="$XIPIMAGE" count=$data_start iflag=count_bytes of="$XIPIMAGE.tmp"
 58 $DD if="$XIPIMAGE"  skip=$data_start iflag=skip_bytes |
 59 $KGZIP -9 >> "$XIPIMAGE.tmp"
 60 
 61 # replace kernel binary
 62 mv -f "$XIPIMAGE.tmp" "$XIPIMAGE"

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php