X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FC%2FGenFw%2FElf32Convert.c;h=5c7b689ee868c182d6dded209f55347b00f91760;hp=85e8ba6614086e72411a2216033c8c782bbc0f9c;hb=234f9ff96e2179e552463dd09ccc515b1c4a6119;hpb=d8043ce905a5832f911361ef30be28765afbdc6b diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c index 85e8ba6614..5c7b689ee8 100644 --- a/BaseTools/Source/C/GenFw/Elf32Convert.c +++ b/BaseTools/Source/C/GenFw/Elf32Convert.c @@ -267,12 +267,10 @@ ScanSections32 ( EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr; UINT32 CoffEntry; UINT32 SectionCount; - BOOLEAN FoundText; + BOOLEAN FoundSection; CoffEntry = 0; mCoffOffset = 0; - mTextOffset = 0; - FoundText = FALSE; // // Coff file start with a DOS header. @@ -297,6 +295,8 @@ ScanSections32 ( // First text sections. // mCoffOffset = CoffAlign(mCoffOffset); + mTextOffset = mCoffOffset; + FoundSection = FALSE; SectionCount = 0; for (i = 0; i < mEhdr->e_shnum; i++) { Elf_Shdr *shdr = GetShdrByIndex(i); @@ -324,9 +324,9 @@ ScanSections32 ( // // Set mTextOffset with the offset of the first '.text' section // - if (!FoundText) { + if (!FoundSection) { mTextOffset = mCoffOffset; - FoundText = TRUE; + FoundSection = TRUE; } mCoffSectionsOffset[i] = mCoffOffset; @@ -335,7 +335,7 @@ ScanSections32 ( } } - if (!FoundText) { + if (!FoundSection) { Error (NULL, 0, 3000, "Invalid", "Did not find any '.text' section."); assert (FALSE); } @@ -352,6 +352,7 @@ ScanSections32 ( // Then data sections. // mDataOffset = mCoffOffset; + FoundSection = FALSE; SectionCount = 0; for (i = 0; i < mEhdr->e_shnum; i++) { Elf_Shdr *shdr = GetShdrByIndex(i); @@ -369,6 +370,15 @@ ScanSections32 ( Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment."); } } + + // + // Set mDataOffset with the offset of the first '.data' section + // + if (!FoundSection) { + mDataOffset = mCoffOffset; + FoundSection = TRUE; + } + mCoffSectionsOffset[i] = mCoffOffset; mCoffOffset += shdr->sh_size; SectionCount ++; @@ -401,6 +411,7 @@ ScanSections32 ( } } if (shdr->sh_size != 0) { + mHiiRsrcOffset = mCoffOffset; mCoffSectionsOffset[i] = mCoffOffset; mCoffOffset += shdr->sh_size; mCoffOffset = CoffAlign(mCoffOffset);