diff options
author | Liming Gao <liming.gao@intel.com> | 2013-11-18 07:41:21 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-11-18 07:41:21 +0000 |
commit | e8a47801a1dfdb148b1bfcd5bdc8ebc3bf51f92d (patch) | |
tree | 04e3ec271347360a5e9da898f1dccbce3d94681f /BaseTools/Source/C/GenFw/Elf32Convert.c | |
parent | fddbbc661eeff8e9f94942fa2d47fb637404a040 (diff) | |
download | edk2-platforms-e8a47801a1dfdb148b1bfcd5bdc8ebc3bf51f92d.tar.xz |
Sync BaseTool trunk (version r2610) into EDKII BaseTools.
Signed-off-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14856 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/C/GenFw/Elf32Convert.c')
-rw-r--r-- | BaseTools/Source/C/GenFw/Elf32Convert.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c index ddb45acc86..58ac333888 100644 --- a/BaseTools/Source/C/GenFw/Elf32Convert.c +++ b/BaseTools/Source/C/GenFw/Elf32Convert.c @@ -1,6 +1,7 @@ /** @file Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR> +Portions copyright (c) 2013, ARM Ltd. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this @@ -18,6 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <windows.h> #include <io.h> #endif +#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -264,9 +266,12 @@ ScanSections32 ( EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr; UINT32 CoffEntry; UINT32 SectionCount; + BOOLEAN FoundText; CoffEntry = 0; mCoffOffset = 0; + mTextOffset = 0; + FoundText = FALSE; // // Coff file start with a DOS header. @@ -291,7 +296,6 @@ ScanSections32 ( // First text sections. // mCoffOffset = CoffAlign(mCoffOffset); - mTextOffset = mCoffOffset; SectionCount = 0; for (i = 0; i < mEhdr->e_shnum; i++) { Elf_Shdr *shdr = GetShdrByIndex(i); @@ -315,12 +319,26 @@ ScanSections32 ( (mEhdr->e_entry < shdr->sh_addr + shdr->sh_size)) { CoffEntry = mCoffOffset + mEhdr->e_entry - shdr->sh_addr; } + + // + // Set mTextOffset with the offset of the first '.text' section + // + if (!FoundText) { + mTextOffset = mCoffOffset; + FoundText = TRUE; + } + mCoffSectionsOffset[i] = mCoffOffset; mCoffOffset += shdr->sh_size; SectionCount ++; } } + if (!FoundText) { + Error (NULL, 0, 3000, "Invalid", "Did not find any '.text' section."); + assert (FALSE); + } + if (mEhdr->e_machine != EM_ARM) { mCoffOffset = CoffAlign(mCoffOffset); } |