diff options
Diffstat (limited to 'BaseTools/Source/C/GenFw/Elf32Convert.c')
-rw-r--r-- | BaseTools/Source/C/GenFw/Elf32Convert.c | 23 |
1 files changed, 17 insertions, 6 deletions
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);
|