public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch V2 4/4] BaseTools: FMMT replace new free space fixing in replace
@ 2023-06-29  3:35 Yuwei Chen
  2023-06-29  6:58 ` Bob Feng
  0 siblings, 1 reply; 2+ messages in thread
From: Yuwei Chen @ 2023-06-29  3:35 UTC (permalink / raw)
  To: devel; +Cc: Rebecca Cran, Liming Gao, Bob Feng

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>
---
 BaseTools/Source/Python/FMMT/core/FvHandler.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/FMMT/core/FvHandler.py b/BaseTools/Source/Python/FMMT/core/FvHandler.py
index 49bbc35baa4d..7a6076033681 100644
--- a/BaseTools/Source/Python/FMMT/core/FvHandler.py
+++ b/BaseTools/Source/Python/FMMT/core/FvHandler.py
@@ -456,7 +456,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
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-29  6:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-29  3:35 [Patch V2 4/4] BaseTools: FMMT replace new free space fixing in replace Yuwei Chen
2023-06-29  6:58 ` Bob Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox