[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [ImageBuilder] uboot-script-gen: use size from arm32 zImage header
On Mon, 20 Nov 2023, Michal Orzel wrote: > Take an example from commit 8bf401c99035 ("uboot-script-gen: use size from > arm64 Image header") and add support for calculating the effective image > size from arm32 zImage header. > > Introduce get_image_size() function and use it to to probe the supported > header magic values and to retrieve the effective image size. Use this > value in add_size(), whenever it's bigger than the one obtained using > 'stat -L'. > > Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx> Acked-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> > --- > This patch together with 'bootz' support will allow us to enable testing Xen > on arm{32,64} in gitlab CI with UBSAN enabled. > --- > scripts/uboot-script-gen | 38 ++++++++++++++++++++++++++++---------- > 1 file changed, 28 insertions(+), 10 deletions(-) > > diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen > index 9e3d86e4743a..078a667c61ab 100755 > --- a/scripts/uboot-script-gen > +++ b/scripts/uboot-script-gen > @@ -431,23 +431,41 @@ function device_tree_editing() > fi > } > > -function add_size() > +# Read effective image size from a header, which may be larger than the > filesize > +# due to noload sections, e.g. bss. > +function get_image_size() > { > - local filename=$1 > - local size=`stat -L --printf="%s" $filename` > + local image=$1 > + local effective_size=0 > # Read arm64 header magic > (https://www.kernel.org/doc/Documentation/arm64/booting.txt) > - local arm64_header_magic=$(od -j 56 -N 4 -t x4 ${filename} | awk 'NR==1 > {print $2}') > + local arm64_header_magic=$(od -j 56 -N 4 -t x4 ${image} | awk 'NR==1 > {print $2}') > + # Read arm32 header magic > (http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html) > + local arm32_header_magic=$(od -j 36 -N 4 -t x4 ${image} | awk 'NR==1 > {print $2}') > > # Check for valid arm64 header magic value 0x644d5241 > if [ "${arm64_header_magic}" = "644d5241" ] > then > - # Read effective size, which may be larger than the filesize due to > noload sections, e.g. bss > - local arm64_header_size=$(od -j 16 -N 8 -t u8 ${filename} | awk > 'NR==1 {print $2}') > + effective_size=$(od -j 16 -N 8 -t u8 ${image} | awk 'NR==1 {print > $2}') > + # Check for valid arm32 header magic value 0x016f2818 > + elif [ "${arm32_header_magic}" = "016f2818" ] > + then > + local start=$(od -j 40 -N 4 -t u4 ${image} | awk 'NR==1 {print $2}') > + local end=$(od -j 44 -N 4 -t u4 ${image} | awk 'NR==1 {print $2}') > + effective_size=$(( end - start )) > + fi > > - if [ "${arm64_header_size}" -gt "${size}" ] > - then > - size=${arm64_header_size} > - fi > + printf "%u" $effective_size > +} > + > +function add_size() > +{ > + local filename=$1 > + local size=`stat -L --printf="%s" $filename` > + local image_size=`get_image_size $filename` > + > + if [ "${image_size}" -gt "${size}" ] > + then > + size=${image_size} > fi > > memaddr=$(( $memaddr + $size + $offset - 1)) > -- > 2.25.1 >
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |