diff options
author | Yonghong Zhu <yonghong.zhu@intel.com> | 2015-12-18 06:45:34 +0000 |
---|---|---|
committer | vanjeff <vanjeff@Edk2> | 2015-12-18 06:45:34 +0000 |
commit | 5fbc2feda298235bd54b38a1e2838db01501aca3 (patch) | |
tree | 6b1c2c3d4bbdb78fca1cfdb0ad8a72b6e60d5b46 /BaseTools/Source/Python/GenFds/FfsInfStatement.py | |
parent | a166931e9404a5b42aa9955282d21d09a0a5df6d (diff) | |
download | edk2-platforms-5fbc2feda298235bd54b38a1e2838db01501aca3.tar.xz |
BaseTools: Add support for INF statement in FD region
FD region today can be file or data, but not a patched image.Add support
for an INF statement in an FD region, so the binary from the INF can be
patched prior to being added to the FD region.
(Sync patch r19136 from main trunk.)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/branches/UDK2015@19372 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/GenFds/FfsInfStatement.py')
-rw-r--r-- | BaseTools/Source/Python/GenFds/FfsInfStatement.py | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index ed767d3fa6..7b221399b4 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -331,25 +331,63 @@ class FfsInfStatement(FfsInfStatementClassObject): # If passed in file does not end with efi, return as is
#
def PatchEfiFile(self, EfiFile, FileType):
+ #
+ # If the module does not have any patches, then return path to input file
+ #
if not self.PatchPcds:
return EfiFile
+
+ #
+ # Only patch file if FileType is PE32 or ModuleType is USER_DEFINED
+ #
if FileType != 'PE32' and self.ModuleType != "USER_DEFINED":
return EfiFile
+
+ #
+ # Generate path to patched output file
+ #
+ Basename = os.path.basename(EfiFile)
+ Output = os.path.normpath (os.path.join(self.OutputPath, Basename))
+
+ #
+ # If this file has already been patched, then return the path to the patched file
+ #
+ if self.PatchedBinFile == Output:
+ return Output
+
+ #
+ # If a different file from the same module has already been patched, then generate an error
+ #
if self.PatchedBinFile:
EdkLogger.error("GenFds", GENFDS_ERROR,
'Only one binary file can be patched:\n'
' a binary file has been patched: %s\n'
' current file: %s' % (self.PatchedBinFile, EfiFile),
File=self.InfFileName)
- Basename = os.path.basename(EfiFile)
- Output = os.path.join(self.OutputPath, Basename)
+
+ #
+ # Copy unpatched file contents to output file location to perform patching
+ #
CopyLongFilePath(EfiFile, Output)
+
+ #
+ # Apply patches to patched output file
+ #
for Pcd, Value in self.PatchPcds:
RetVal, RetStr = PatchBinaryFile(Output, int(Pcd.Offset, 0), Pcd.DatumType, Value, Pcd.MaxDatumSize)
if RetVal:
EdkLogger.error("GenFds", GENFDS_ERROR, RetStr, File=self.InfFileName)
- self.PatchedBinFile = os.path.normpath(EfiFile)
+
+ #
+ # Save the path of the patched output file
+ #
+ self.PatchedBinFile = Output
+
+ #
+ # Return path to patched output file
+ #
return Output
+
## GenFfs() method
#
# Generate FFS
|