EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr;\r
UINT32 CoffEntry;\r
UINT32 SectionCount;\r
- BOOLEAN FoundText;\r
+ BOOLEAN FoundSection;\r
\r
CoffEntry = 0;\r
mCoffOffset = 0;\r
- mTextOffset = 0;\r
- FoundText = FALSE;\r
\r
//\r
// Coff file start with a DOS header.\r
// First text sections.\r
//\r
mCoffOffset = CoffAlign(mCoffOffset);\r
+ mTextOffset = mCoffOffset;\r
+ FoundSection = FALSE;\r
SectionCount = 0;\r
for (i = 0; i < mEhdr->e_shnum; i++) {\r
Elf_Shdr *shdr = GetShdrByIndex(i);\r
//\r
// Set mTextOffset with the offset of the first '.text' section\r
//\r
- if (!FoundText) {\r
+ if (!FoundSection) {\r
mTextOffset = mCoffOffset;\r
- FoundText = TRUE;\r
+ FoundSection = TRUE;\r
}\r
\r
mCoffSectionsOffset[i] = mCoffOffset;\r
}\r
}\r
\r
- if (!FoundText) {\r
+ if (!FoundSection) {\r
Error (NULL, 0, 3000, "Invalid", "Did not find any '.text' section.");\r
assert (FALSE);\r
}\r
// Then data sections.\r
//\r
mDataOffset = mCoffOffset;\r
+ FoundSection = FALSE;\r
SectionCount = 0;\r
for (i = 0; i < mEhdr->e_shnum; i++) {\r
Elf_Shdr *shdr = GetShdrByIndex(i);\r
Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");\r
}\r
}\r
+\r
+ //\r
+ // Set mDataOffset with the offset of the first '.data' section\r
+ //\r
+ if (!FoundSection) {\r
+ mDataOffset = mCoffOffset;\r
+ FoundSection = TRUE;\r
+ }\r
+\r
mCoffSectionsOffset[i] = mCoffOffset;\r
mCoffOffset += shdr->sh_size;\r
SectionCount ++;\r
}\r
}\r
if (shdr->sh_size != 0) {\r
+ mHiiRsrcOffset = mCoffOffset;\r
mCoffSectionsOffset[i] = mCoffOffset;\r
mCoffOffset += shdr->sh_size;\r
mCoffOffset = CoffAlign(mCoffOffset);\r