Skip to content

Commit

Permalink
BaseTools: Fixed '-D EDK2_REDUCE_FW_SIZE' build option.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Krichanov committed Nov 3, 2023
1 parent 70265b6 commit 3dff9d7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion BaseTools/ImageTool/PeEmit.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,12 @@ ToolImageEmitPeFile (
SizeOfPeHeaders = SectionHeadersOffset + SectionHeadersSize;
SizeOfHeaders = sizeof (mDosHdr) + SizeOfPeHeaders;
AlignedSizeOfHeaders = ALIGN_VALUE (SizeOfHeaders, FileAlignment);
//
// Necessary adjustment for '-D EDK2_REDUCE_FW_SIZE' build option.
//
if (AlignedSizeOfHeaders < Image->SegmentInfo.Segments[0].ImageAddress) {
AlignedSizeOfHeaders = (uint32_t)Image->SegmentInfo.Segments[0].ImageAddress;
}

PeOffset = ImageToolBufferAppendReserve (
Buffer,
Expand Down Expand Up @@ -623,7 +629,7 @@ ToolImageEmitPeFile (
PeHdr->ImageBase = (EFI_IMAGE_NT_BASE_ADDRESS)Image->HeaderInfo.BaseAddress;
PeHdr->SectionAlignment = Image->SegmentInfo.SegmentAlignment;
PeHdr->FileAlignment = FileAlignment;
PeHdr->SizeOfImage = ALIGN_VALUE (SizeOfHeaders, PeHdr->SectionAlignment);
PeHdr->SizeOfImage = AlignedSizeOfHeaders;
PeHdr->SizeOfHeaders = AlignedSizeOfHeaders;
PeHdr->Subsystem = Image->HeaderInfo.Subsystem;
PeHdr->NumberOfRvaAndSizes = EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES;
Expand Down

0 comments on commit 3dff9d7

Please sign in to comment.