BaseTools: FMMT replace new free space fixing in replace

In FMMT replace function, when newffs size <= targetffs size,
the new free space is calculated wrong as loss the pad data delta size.
That will cause invalid binary generated.
This patch fixes this issue.

Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
Yuwei Chen 2023-06-29 11:35:19 +08:00 committed by mergify[bot]
parent bb13a4adab
commit b5f5106c1e
1 changed files with 1 additions and 1 deletions

View File

@ -442,7 +442,7 @@ class FvHandler:
# Start free space calculating and moving process.
self.ModifyTest(TargetFv.Parent, Needed_Space)
else:
New_Free_Space = self.TargetFfs.Data.Size - self.NewFfs.Data.Size
New_Free_Space = self.TargetFfs.Data.Size + len(self.TargetFfs.Data.PadData) - self.NewFfs.Data.Size - len(self.NewFfs.Data.PadData)
# If TargetFv already have free space, move the new free space into it.
if TargetFv.Data.Free_Space:
TargetFv.Child[-1].Data.Data += b'\xff' * New_Free_Space