diff options
Diffstat (limited to 'BaseTools/Source')
-rw-r--r-- | BaseTools/Source/C/GenFw/Elf32Convert.c | 23 | ||||
-rw-r--r-- | BaseTools/Source/C/GenFw/Elf64Convert.c | 22 |
2 files changed, 33 insertions, 12 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);
diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/Elf64Convert.c index 290f04cb98..25b90e2f7b 100644 --- a/BaseTools/Source/C/GenFw/Elf64Convert.c +++ b/BaseTools/Source/C/GenFw/Elf64Convert.c @@ -260,12 +260,10 @@ ScanSections64 ( 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.
@@ -291,6 +289,8 @@ ScanSections64 ( // 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);
@@ -318,9 +318,9 @@ ScanSections64 ( //
// Set mTextOffset with the offset of the first '.text' section
//
- if (!FoundText) {
+ if (!FoundSection) {
mTextOffset = mCoffOffset;
- FoundText = TRUE;
+ FoundSection = TRUE;
}
mCoffSectionsOffset[i] = mCoffOffset;
@@ -329,7 +329,7 @@ ScanSections64 ( }
}
- if (!FoundText) {
+ if (!FoundSection) {
Error (NULL, 0, 3000, "Invalid", "Did not find any '.text' section.");
assert (FALSE);
}
@@ -346,6 +346,7 @@ ScanSections64 ( // Then data sections.
//
mDataOffset = mCoffOffset;
+ FoundSection = FALSE;
SectionCount = 0;
for (i = 0; i < mEhdr->e_shnum; i++) {
Elf_Shdr *shdr = GetShdrByIndex(i);
@@ -363,6 +364,14 @@ ScanSections64 ( 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 += (UINT32) shdr->sh_size;
SectionCount ++;
@@ -395,6 +404,7 @@ ScanSections64 ( }
}
if (shdr->sh_size != 0) {
+ mHiiRsrcOffset = mCoffOffset;
mCoffSectionsOffset[i] = mCoffOffset;
mCoffOffset += (UINT32) shdr->sh_size;
mCoffOffset = CoffAlign(mCoffOffset);
|