1.Add FFS file type check: Only allow rebase operation for
EFI_FV_FILETYPE_SECURITY_CORE, EFI_FV_FILETYPE_PEI_CORE,
EFI_FV_FILETYPE_DXE_CORE, EFI_FV_FILETYPE_PEIM, EFI_FV_FILETYPE_DRIVER,
EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER,EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE
types, improving safety and compliance.
2.Automatically detect and complete the PE/COFF or TE image
relocation table (reloc section) to ensure integrity and compatibility
of the rebase operation.
3.After rebase, automatically update FFS checksum and FV header
information to ensure correct data structure.
4.Support recursive processing for nested FVs, ensuring all related FFS
files' PE/TE images are properly rebased and reloc tables are completed.
5.Use table-driven architecture for relocation types, making it easier to
extend to more platforms.
6.Improve error handling and logging for better robustness and
maintainability.
Please attention, only IA32 and X64 PE/COFF image are supported now.
For other Arch, will support it after testing.
Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
This patch adds and improves the rebase functionality
for firmware images (PE/COFF/TE) in the FMMT tool.
Key features include:
1.Automatically rebases PE/COFF/TE images within FFS files
when the firmware volume (FV) layout is adjusted or FFS files
are moved, ensuring correct loading and execution at new addresses.
2.Implements recursive rebase logic for nested sections,
guaranteeing all relevant images are properly relocated.
3.Adds support for rebasing subsequent FFS files within the same FV,
enhancing compatibility and stability during firmware layout changes.
4.Core code changes are mainly in FvHandler.py, BiosTreeNode.py,
and BinaryFactoryProduct.py, covering rebase flag detection, address calculation,
and actual relocation operations.
5.This feature improves the flexibility of firmware space management
and enhances the automation and reliability of the FMMT tool.
Co-Auther: Ashraf Ali S <ashraf.ali.s@intel.com>
Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
The FMMT python tool is used for firmware files operation, which has
the Fv/FFs-based 'View'&'Add'&'Delete'&'Replace' operation function:
1.Parse a FD(Firmware Device) / FV(Firmware Volume) / FFS(Firmware Files)
2.Add a new FFS into a FV file (both included in a FD file or not)
3.Replace an FFS in a FV file with a new FFS file
4.Delete an FFS in a FV file (both included in a FD file or not)
5.Extract the FFS from a FV file (both included in a FD file or not)
This version of FMMT Python tool does not support PEIM rebase feature,
this feature will be added in future update.
Currently the FMMT C tool is saved in edk2-staging repo, but its
quality and coding style can't meet the Edk2 quality, which is hard to
maintain (Hard/Duplicate Code; Regression bugs; Restrict usage).
The new Python version keeps same functions with origin C version. It
has higher quality and better coding style, and it is much easier to
extend new functions and to maintain.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1847
RFC Link: https://edk2.groups.io/g/devel/message/82877
Staging Link: https://github.com/tianocore/edk2-staging/tree/PyFMMT
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Acked-by: Liming Gao <gaoliming@byosoft.com.cn>