Current FSP rebasing script SplitFspBin.py has support for both
PE32 and PE32+ image formats. However, while updating the ImageBase
field in the image header, it always assumed the ImageBase field is
32bit long. Since PE32+ image format defined ImageBase as 64bit,
the current script will only update the lower 32bit value and leave
the upper 32bit untouched. It does not work well for PE32+ image
that requires update in the upper 32bit ImageBase field. The
expected behavior is to update the full 64bit field. This patch
implemented this fix.
Signed-off-by: Maurice Ma <maurice.ma@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
---
IntelFsp2Pkg/Tools/SplitFspBin.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/IntelFsp2Pkg/Tools/SplitFspBin.py b/IntelFsp2Pkg/Tools/SplitFspBin.py
index 3c0d5af1b6..24272e82af 100644
--- a/IntelFsp2Pkg/Tools/SplitFspBin.py
+++ b/IntelFsp2Pkg/Tools/SplitFspBin.py
@@ -677,8 +677,12 @@ class PeTeImage:
else:
offset = self.Offset + self.DosHdr.e_lfanew
offset += EFI_IMAGE_NT_HEADERS32.OptionalHeader.offset
- offset += EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.offset
- size = EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.size
+ if self.PeHdr.OptionalHeader.PePlusOptHdr.Magic == 0x20b: # PE32+ image
+ offset += EFI_IMAGE_OPTIONAL_HEADER32_PLUS.ImageBase.offset
+ size = EFI_IMAGE_OPTIONAL_HEADER32_PLUS.ImageBase.size
+ else:
+ offset += EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.offset
+ size = EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.size
value = Bytes2Val(fdbin[offset:offset+size]) + delta
fdbin[offset:offset+size] = Val2Bytes(value, size)
--
2.29.2.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#67332): https://edk2.groups.io/g/devel/message/67332
Mute This Topic: https://groups.io/mt/78196419/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com> > -----Original Message----- > From: Maurice Ma <maurice.ma@intel.com> > Sent: Thursday, November 12, 2020 8:11 AM > To: devel@edk2.groups.io > Cc: Ma, Maurice <maurice.ma@intel.com>; Chiu, Chasel > <chasel.chiu@intel.com>; Desimone, Nathaniel L > <nathaniel.l.desimone@intel.com>; Zeng, Star <star.zeng@intel.com> > Subject: [PATCH] IntelFsp2Pkg: Fix FSP binary rebasing issue for PE32+ image > > Current FSP rebasing script SplitFspBin.py has support for both > PE32 and PE32+ image formats. However, while updating the ImageBase field in > the image header, it always assumed the ImageBase field is 32bit long. Since > PE32+ image format defined ImageBase as 64bit, the current script will only > update the lower 32bit value and leave the upper 32bit untouched. It does not > work well for PE32+ image that requires update in the upper 32bit ImageBase > field. The expected behavior is to update the full 64bit field. This patch > implemented this fix. > > Signed-off-by: Maurice Ma <maurice.ma@intel.com> > > Cc: Chasel Chiu <chasel.chiu@intel.com> > Cc: Nate DeSimone <nathaniel.l.desimone@intel.com> > Cc: Star Zeng <star.zeng@intel.com> > --- > IntelFsp2Pkg/Tools/SplitFspBin.py | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/IntelFsp2Pkg/Tools/SplitFspBin.py > b/IntelFsp2Pkg/Tools/SplitFspBin.py > index 3c0d5af1b6..24272e82af 100644 > --- a/IntelFsp2Pkg/Tools/SplitFspBin.py > +++ b/IntelFsp2Pkg/Tools/SplitFspBin.py > @@ -677,8 +677,12 @@ class PeTeImage: > else: offset = self.Offset + self.DosHdr.e_lfanew offset += > EFI_IMAGE_NT_HEADERS32.OptionalHeader.offset- offset += > EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.offset- size = > EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.size+ if > self.PeHdr.OptionalHeader.PePlusOptHdr.Magic == 0x20b: # PE32+ image+ > offset += EFI_IMAGE_OPTIONAL_HEADER32_PLUS.ImageBase.offset+ > size = EFI_IMAGE_OPTIONAL_HEADER32_PLUS.ImageBase.size+ else:+ > offset += EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.offset+ size = > EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.size value = > Bytes2Val(fdbin[offset:offset+size]) + delta fdbin[offset:offset+size] = > Val2Bytes(value, size)-- > 2.29.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#67333): https://edk2.groups.io/g/devel/message/67333 Mute This Topic: https://groups.io/mt/78196419/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
Pushed: https://github.com/tianocore/edk2/commit/d448574 > -----Original Message----- > From: Maurice Ma <maurice.ma@intel.com> > Sent: Wednesday, November 11, 2020 4:11 PM > To: devel@edk2.groups.io > Cc: Ma, Maurice <maurice.ma@intel.com>; Chiu, Chasel > <chasel.chiu@intel.com>; Desimone, Nathaniel L > <nathaniel.l.desimone@intel.com>; Zeng, Star <star.zeng@intel.com> > Subject: [PATCH] IntelFsp2Pkg: Fix FSP binary rebasing issue for PE32+ image > > Current FSP rebasing script SplitFspBin.py has support for both > PE32 and PE32+ image formats. However, while updating the ImageBase field > in the image header, it always assumed the ImageBase field is 32bit long. > Since PE32+ image format defined ImageBase as 64bit, the current script will > only update the lower 32bit value and leave the upper 32bit untouched. It > does not work well for PE32+ image that requires update in the upper 32bit > ImageBase field. The expected behavior is to update the full 64bit field. This > patch implemented this fix. > > Signed-off-by: Maurice Ma <maurice.ma@intel.com> > > Cc: Chasel Chiu <chasel.chiu@intel.com> > Cc: Nate DeSimone <nathaniel.l.desimone@intel.com> > Cc: Star Zeng <star.zeng@intel.com> > --- > IntelFsp2Pkg/Tools/SplitFspBin.py | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/IntelFsp2Pkg/Tools/SplitFspBin.py > b/IntelFsp2Pkg/Tools/SplitFspBin.py > index 3c0d5af1b6..24272e82af 100644 > --- a/IntelFsp2Pkg/Tools/SplitFspBin.py > +++ b/IntelFsp2Pkg/Tools/SplitFspBin.py > @@ -677,8 +677,12 @@ class PeTeImage: > else: offset = self.Offset + self.DosHdr.e_lfanew offset += > EFI_IMAGE_NT_HEADERS32.OptionalHeader.offset- offset += > EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.offset- size = > EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.size+ if > self.PeHdr.OptionalHeader.PePlusOptHdr.Magic == 0x20b: # PE32+ image+ > offset += EFI_IMAGE_OPTIONAL_HEADER32_PLUS.ImageBase.offset+ > size = EFI_IMAGE_OPTIONAL_HEADER32_PLUS.ImageBase.size+ > else:+ offset += > EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.offset+ size = > EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.size value = > Bytes2Val(fdbin[offset:offset+size]) + delta fdbin[offset:offset+size] = > Val2Bytes(value, size)-- > 2.29.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#67576): https://edk2.groups.io/g/devel/message/67576 Mute This Topic: https://groups.io/mt/78196419/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com> > -----Original Message----- > From: Maurice Ma <maurice.ma@intel.com> > Sent: Wednesday, November 11, 2020 4:11 PM > To: devel@edk2.groups.io > Cc: Ma, Maurice <maurice.ma@intel.com>; Chiu, Chasel > <chasel.chiu@intel.com>; Desimone, Nathaniel L > <nathaniel.l.desimone@intel.com>; Zeng, Star <star.zeng@intel.com> > Subject: [PATCH] IntelFsp2Pkg: Fix FSP binary rebasing issue for PE32+ image > > Current FSP rebasing script SplitFspBin.py has support for both > PE32 and PE32+ image formats. However, while updating the ImageBase field > in the image header, it always assumed the ImageBase field is 32bit long. > Since PE32+ image format defined ImageBase as 64bit, the current script will > only update the lower 32bit value and leave the upper 32bit untouched. It > does not work well for PE32+ image that requires update in the upper 32bit > ImageBase field. The expected behavior is to update the full 64bit field. This > patch implemented this fix. > > Signed-off-by: Maurice Ma <maurice.ma@intel.com> > > Cc: Chasel Chiu <chasel.chiu@intel.com> > Cc: Nate DeSimone <nathaniel.l.desimone@intel.com> > Cc: Star Zeng <star.zeng@intel.com> > --- > IntelFsp2Pkg/Tools/SplitFspBin.py | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/IntelFsp2Pkg/Tools/SplitFspBin.py > b/IntelFsp2Pkg/Tools/SplitFspBin.py > index 3c0d5af1b6..24272e82af 100644 > --- a/IntelFsp2Pkg/Tools/SplitFspBin.py > +++ b/IntelFsp2Pkg/Tools/SplitFspBin.py > @@ -677,8 +677,12 @@ class PeTeImage: > else: offset = self.Offset + self.DosHdr.e_lfanew offset += > EFI_IMAGE_NT_HEADERS32.OptionalHeader.offset- offset += > EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.offset- size = > EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.size+ if > self.PeHdr.OptionalHeader.PePlusOptHdr.Magic == 0x20b: # PE32+ image+ > offset += EFI_IMAGE_OPTIONAL_HEADER32_PLUS.ImageBase.offset+ > size = EFI_IMAGE_OPTIONAL_HEADER32_PLUS.ImageBase.size+ > else:+ offset += > EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.offset+ size = > EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.size value = > Bytes2Val(fdbin[offset:offset+size]) + delta fdbin[offset:offset+size] = > Val2Bytes(value, size)-- > 2.29.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#67575): https://edk2.groups.io/g/devel/message/67575 Mute This Topic: https://groups.io/mt/78196419/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
Reviewed-by: Star Zeng <star.zeng@intel.com> -----Original Message----- From: Maurice Ma <maurice.ma@intel.com> Sent: Thursday, November 12, 2020 8:11 AM To: devel@edk2.groups.io Cc: Ma, Maurice <maurice.ma@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Zeng, Star <star.zeng@intel.com> Subject: [PATCH] IntelFsp2Pkg: Fix FSP binary rebasing issue for PE32+ image Current FSP rebasing script SplitFspBin.py has support for both PE32 and PE32+ image formats. However, while updating the ImageBase field in the image header, it always assumed the ImageBase field is 32bit long. Since PE32+ image format defined ImageBase as 64bit, the current script will only update the lower 32bit value and leave the upper 32bit untouched. It does not work well for PE32+ image that requires update in the upper 32bit ImageBase field. The expected behavior is to update the full 64bit field. This patch implemented this fix. Signed-off-by: Maurice Ma <maurice.ma@intel.com> Cc: Chasel Chiu <chasel.chiu@intel.com> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com> Cc: Star Zeng <star.zeng@intel.com> --- IntelFsp2Pkg/Tools/SplitFspBin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/IntelFsp2Pkg/Tools/SplitFspBin.py b/IntelFsp2Pkg/Tools/SplitFspBin.py index 3c0d5af1b6..24272e82af 100644 --- a/IntelFsp2Pkg/Tools/SplitFspBin.py +++ b/IntelFsp2Pkg/Tools/SplitFspBin.py @@ -677,8 +677,12 @@ class PeTeImage: else: offset = self.Offset + self.DosHdr.e_lfanew offset += EFI_IMAGE_NT_HEADERS32.OptionalHeader.offset - offset += EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.offset - size = EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.size + if self.PeHdr.OptionalHeader.PePlusOptHdr.Magic == 0x20b: # + PE32+ image + offset += + EFI_IMAGE_OPTIONAL_HEADER32_PLUS.ImageBase.offset + size = EFI_IMAGE_OPTIONAL_HEADER32_PLUS.ImageBase.size + else: + offset += EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.offset + size = EFI_IMAGE_OPTIONAL_HEADER32.ImageBase.size value = Bytes2Val(fdbin[offset:offset+size]) + delta fdbin[offset:offset+size] = Val2Bytes(value, size) -- 2.29.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#67353): https://edk2.groups.io/g/devel/message/67353 Mute This Topic: https://groups.io/mt/78196419/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2024 Red Hat, Inc.