BaseTools GenFw: Support CLANG8ELF with conversion ELF to PE/COFF image

CLANG8ELF tool chain generated ELF image with the different attributes
in section. Update GenFw to handle them.
1. .text section with writable attribute (support)
2. .reloc section has the symbol for *ABS* (skip)

Signed-off-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Feng Bob C <bob.c.feng@intel.com>
This commit is contained in:
Liming Gao 2021-06-02 16:11:41 +08:00 committed by mergify[bot]
parent c1aa3bab12
commit c6b872c6ab
2 changed files with 6 additions and 11 deletions

View File

@ -238,7 +238,7 @@ IsTextShdr (
Elf_Shdr *Shdr Elf_Shdr *Shdr
) )
{ {
return (BOOLEAN) ((Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == SHF_ALLOC); return (BOOLEAN) ((Shdr->sh_flags & (SHF_EXECINSTR | SHF_ALLOC)) == (SHF_EXECINSTR | SHF_ALLOC));
} }
STATIC STATIC
@ -261,7 +261,7 @@ IsDataShdr (
if (IsHiiRsrcShdr(Shdr)) { if (IsHiiRsrcShdr(Shdr)) {
return FALSE; return FALSE;
} }
return (BOOLEAN) (Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == (SHF_ALLOC | SHF_WRITE); return (BOOLEAN) (Shdr->sh_flags & (SHF_EXECINSTR | SHF_WRITE | SHF_ALLOC)) == (SHF_ALLOC | SHF_WRITE);
} }
STATIC STATIC
@ -749,13 +749,7 @@ WriteSections32 (
if (SymName == NULL) { if (SymName == NULL) {
SymName = (const UINT8 *)"<unknown>"; SymName = (const UINT8 *)"<unknown>";
} }
continue;
Error (NULL, 0, 3000, "Invalid",
"%s: Bad definition for symbol '%s'@%#x or unsupported symbol type. "
"For example, absolute and undefined symbols are not supported.",
mInImageName, SymName, Sym->st_value);
exit(EXIT_FAILURE);
} }
SymShdr = GetShdrByIndex(Sym->st_shndx); SymShdr = GetShdrByIndex(Sym->st_shndx);

View File

@ -246,7 +246,7 @@ IsTextShdr (
Elf_Shdr *Shdr Elf_Shdr *Shdr
) )
{ {
return (BOOLEAN) ((Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == SHF_ALLOC); return (BOOLEAN) ((Shdr->sh_flags & (SHF_EXECINSTR | SHF_ALLOC)) == (SHF_EXECINSTR | SHF_ALLOC));
} }
STATIC STATIC
@ -269,7 +269,7 @@ IsDataShdr (
if (IsHiiRsrcShdr(Shdr)) { if (IsHiiRsrcShdr(Shdr)) {
return FALSE; return FALSE;
} }
return (BOOLEAN) (Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == (SHF_ALLOC | SHF_WRITE); return (BOOLEAN) (Shdr->sh_flags & (SHF_EXECINSTR | SHF_WRITE | SHF_ALLOC)) == (SHF_ALLOC | SHF_WRITE);
} }
STATIC STATIC
@ -1060,6 +1060,7 @@ WriteSections64 (
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
continue;
} }
SymShdr = GetShdrByIndex(Sym->st_shndx); SymShdr = GetShdrByIndex(Sym->st_shndx);