git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2531
6f19259b-4bc3-4df7-8a09-
765794883524
-Copyright (c) 2004, Intel Corporation \r
+Copyright (c) 2004 - 2007, Intel Corporation \r
All rights reserved. This program and the accompanying materials \r
are licensed and made available under the terms and conditions of the BSD License \r
which accompanies this distribution. The full text of the license may be found at \r
All rights reserved. This program and the accompanying materials \r
are licensed and made available under the terms and conditions of the BSD License \r
which accompanies this distribution. The full text of the license may be found at \r
//
// Note: Magic has already been tested.
//
//
// Note: Magic has already been tested.
//
return 0;
if (Ehdr->e_version != EV_CURRENT)
return 0;
return 0;
if (Ehdr->e_version != EV_CURRENT)
return 0;
+\r
+ //\r
+ // Find the section header table\r
+ //
ShdrBase = (Elf_Shdr *)((UINT8 *)Ehdr + Ehdr->e_shoff);
ShdrBase = (Elf_Shdr *)((UINT8 *)Ehdr + Ehdr->e_shoff);
- CoffSectionsOffset = (UINT32 *)malloc(Ehdr->e_shnum * sizeof (UINT32));
- memset(CoffSectionsOffset, 0, Ehdr->e_shnum * sizeof(UINT32));
+ CoffSectionsOffset = (UINT32 *)malloc(Ehdr->e_shnum * sizeof (UINT32));\r
+
+ memset(CoffSectionsOffset, 0, Ehdr->e_shnum * sizeof(UINT32));\r
{
return (Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == SHF_ALLOC;
}
{
return (Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == SHF_ALLOC;
}
int
IsDataShdr(
Elf_Shdr *Shdr
int
IsDataShdr(
Elf_Shdr *Shdr
TextOffset = CoffOffset;
for (i = 0; i < Ehdr->e_shnum; i++) {
Elf_Shdr *shdr = GetShdrByIndex(i);
TextOffset = CoffOffset;
for (i = 0; i < Ehdr->e_shnum; i++) {
Elf_Shdr *shdr = GetShdrByIndex(i);
- if (IsTextShdr(shdr)) {
+ if (IsTextShdr(shdr)) {\r
+ //\r
+ // Align the coff offset\r
+ // \r
+ CoffOffset = (CoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1);\r
- if (Ehdr->e_entry >= shdr->sh_addr
- && Ehdr->e_entry < shdr->sh_addr + shdr->sh_size) {
- CoffEntry = CoffOffset + Ehdr->e_entry - shdr->sh_addr;
+ if ((Ehdr->e_entry >= shdr->sh_addr) && \r
+ (Ehdr->e_entry < shdr->sh_addr + shdr->sh_size)) {
+ CoffEntry = CoffOffset + Ehdr->e_entry - shdr->sh_addr;
- CoffSectionsOffset[i] = CoffOffset;
+ CoffSectionsOffset[i] = CoffOffset;\r
CoffOffset += shdr->sh_size;
CoffOffset += shdr->sh_size;
CoffOffset = CoffAlign(CoffOffset);
CoffOffset = CoffAlign(CoffOffset);
//
// Then data sections.
//
//
// Then data sections.
//