summaryrefslogtreecommitdiff
path: root/MdePkg/Library
diff options
context:
space:
mode:
authorydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2012-05-04 05:11:07 +0000
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2012-05-04 05:11:07 +0000
commit00b7e3e3a2ecead3fae83791a25c06a57f65de68 (patch)
tree4d2f361a5606b3b947a007e41a99ef78e3a8dddf /MdePkg/Library
parent5817449f2de9a2d9792cb3db1e67ffa7ee5894d7 (diff)
downloadedk2-platforms-00b7e3e3a2ecead3fae83791a25c06a57f65de68.tar.xz
Update the logic related to get section header offset for TE image.
Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13273 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library')
-rw-r--r--MdePkg/Library/BasePeCoffLib/BasePeCoff.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
index 69c649a32a..e44f04c799 100644
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
@@ -71,6 +71,7 @@ PeCoffLoaderGetPeHeader (
UINT32 SectionHeaderOffset;
UINT32 Index;
CHAR8 BufferData;
+ UINTN NumberOfSections;
EFI_IMAGE_SECTION_HEADER SectionHeader;
//
@@ -303,8 +304,15 @@ PeCoffLoaderGetPeHeader (
//
// Check each section field.
//
- SectionHeaderOffset = ImageContext->PeCoffHeaderOffset + sizeof (UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + Hdr.Pe32->FileHeader.SizeOfOptionalHeader;
- for (Index = 0; Index < Hdr.Pe32->FileHeader.NumberOfSections; Index++) {
+ if (ImageContext->IsTeImage) {
+ SectionHeaderOffset = sizeof(EFI_TE_IMAGE_HEADER);
+ NumberOfSections = (UINTN) (Hdr.Te->NumberOfSections);
+ } else {
+ SectionHeaderOffset = ImageContext->PeCoffHeaderOffset + sizeof (UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + Hdr.Pe32->FileHeader.SizeOfOptionalHeader;
+ NumberOfSections = (UINTN) (Hdr.Pe32->FileHeader.NumberOfSections);
+ }
+
+ for (Index = 0; Index < NumberOfSections; Index++) {
//
// Read section header from file
//