Skip to content

Commit

Permalink
Enhance GenFw to support handling the shared ELF object file. This is…
Browse files Browse the repository at this point in the history
… helpful to provide source level debug ability in *unix environment.

[Background]
The UnixPkg provide an simulator in *unix. To support source level debug, we need dynamically load all of modules using dlopen(). This requires the output of compiler must be a shared ELF object. Therefore the GenFw should be able to handle the kind of object to generate .efi PE file.


git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1271 7335b38e-4728-0410-8992-fb3ffe349368
  • Loading branch information
lgao4 committed Jun 30, 2008
1 parent e2a8b52 commit 435c4d9
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions Source/C/GenFw/GenFw.c
Expand Up @@ -485,7 +485,7 @@ CheckElfHeader(
return 0;
if (Ehdr->e_ident[EI_DATA] != ELFDATA2LSB)
return 0;
if (Ehdr->e_type != ET_EXEC)
if ((Ehdr->e_type != ET_EXEC) && (Ehdr->e_type != ET_DYN))
return 0;
if (Ehdr->e_machine != EM_386)
return 0;
Expand All @@ -508,15 +508,38 @@ IsTextShdr(
Elf_Shdr *Shdr
)
{
return (Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == SHF_ALLOC;
int Status;
int NotText = 1;
Status = (int)((Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == SHF_ALLOC);
if (Ehdr->e_type == ET_EXEC)
return Status;
else {
//
// this is a shared object file.
//
switch (Shdr->sh_type) {
case SHT_HASH:
case SHT_DYNSYM:
case SHT_STRTAB:
case SHT_REL:
case SHT_GNU_HASH:
NotText = 0;
break;
default:
break;
}
return Status && NotText;
}
}

int
IsDataShdr(
Elf_Shdr *Shdr
)
{
return (Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == (SHF_ALLOC | SHF_WRITE);
int Status;
Status = (Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == (SHF_ALLOC | SHF_WRITE);
return Status && !(Shdr->sh_type == (SHT_DYNAMIC));
}

VOID
Expand Down

0 comments on commit 435c4d9

Please sign in to comment.