From fcf8e57b6867d46d90660542035fef5bfa1c1441 Mon Sep 17 00:00:00 2001 From: Trammell hudson Date: Sat, 20 Jan 2018 17:29:23 -0500 Subject: [PATCH] fix alignment of files and length of final pad --- bin/create-fv | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/bin/create-fv b/bin/create-fv index 7f678c4..1f472a5 100755 --- a/bin/create-fv +++ b/bin/create-fv @@ -110,11 +110,6 @@ while(<>) die "\n" unless $force; } - warn sprintf "%s: 0x%x bytes\n", - $ARGV, - length $_, - if $verbose; - # force at least 8 byte alignment for the section my $unaligned = $length % 8; $_ .= chr(0xFF) x (8 - $unaligned) @@ -125,12 +120,20 @@ while(<>) my $block_unaligned = $block_size - (length($data) % $block_size); $block_unaligned += $block_size if $block_unaligned < 0x18; - $data .= pad($block_unaligned - 0x18) . $_; + $data .= pad($block_unaligned - 0x18); + warn sprintf "%s: 0x%x bytes offset %x\n", + $ARGV, + length $_, + length $data + if $verbose; + + # finally add the section + $data .= $_; } -if ($hdr_len + length $data > $size) +if (length $data > $size) { warn sprintf "%s: data size 0x%x > volume size 0x%x\n", $output, @@ -139,14 +142,14 @@ if ($hdr_len + length $data > $size) ; die "\n" unless $force; } else { - # pad out with empty space + # pad out with empty space to the end of the volume warn sprintf "%s: 0x%x out of 0x%x\n", $output, - $hdr_len + length $data, + length $data, $size, if $verbose; - $data .= chr(0xFF) x ($size - (length($data) - $hdr_len)); + $data .= chr(0xFF) x ($size - length($data)); } if ($output eq '-')