]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools GenFw: Keep read only alloc section as text when convert ELF
authorgaoliming <gaoliming@byosoft.com.cn>
Wed, 16 Jun 2021 07:58:09 +0000 (15:58 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 16 Jun 2021 14:11:57 +0000 (14:11 +0000)
This is the fix of the regression issue at c6b872c6.
Based on ELF spec, readonly alloc section is .rodata section. It is used.
This fix is to add back original check logic for ELF section. Now,
the readonly alloc section and execute alloc section are regarded as .text.

Signed-off-by: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
BaseTools/Source/C/GenFw/Elf32Convert.c
BaseTools/Source/C/GenFw/Elf64Convert.c

index 314f8233234ddaebbaf1139856e61c60c1bcf756..d917a444c82d94e67d2a6bd76470fe29b4d0091b 100644 (file)
@@ -238,7 +238,8 @@ IsTextShdr (
   Elf_Shdr *Shdr\r
   )\r
 {\r
-  return (BOOLEAN) ((Shdr->sh_flags & (SHF_EXECINSTR | SHF_ALLOC)) == (SHF_EXECINSTR | SHF_ALLOC));\r
+  return (BOOLEAN) (((Shdr->sh_flags & (SHF_EXECINSTR | SHF_ALLOC)) == (SHF_EXECINSTR | SHF_ALLOC)) ||\r
+                   ((Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == SHF_ALLOC));\r
 }\r
 \r
 STATIC\r
index 8b09db7b690b70b02362d03673afdfadd95444aa..33031ec8f6e7f63a64f07a5cb96db8a50b6a9c55 100644 (file)
@@ -246,7 +246,8 @@ IsTextShdr (
   Elf_Shdr *Shdr\r
   )\r
 {\r
-  return (BOOLEAN) ((Shdr->sh_flags & (SHF_EXECINSTR | SHF_ALLOC)) == (SHF_EXECINSTR | SHF_ALLOC));\r
+  return (BOOLEAN) (((Shdr->sh_flags & (SHF_EXECINSTR | SHF_ALLOC)) == (SHF_EXECINSTR | SHF_ALLOC)) ||\r
+                   ((Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == SHF_ALLOC));\r
 }\r
 \r
 STATIC\r