[edk2-devel] : Query regarding IsTextShdr inside Basetools

Mukesh Ojha mojha at codeaurora.org
Wed Nov 11 07:07:58 UTC 2020


Apology for rushing into this.
Looking for a quick input on this.

-Mukesh

On 11/10/2020 6:37 PM, Mukesh Ojha wrote:
> Hi All,
>
> I have a doubt about the check we have put inside IsTextShdr() .
>
> STATIC
> BOOLEAN
> IsTextShdr (
>   Elf_Shdr *Shdr
>   )
> {
>   return (BOOLEAN) ((Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == 
> SHF_ALLOC);
> }
>
>
> We are observing one issue where while generate EFI using GenFW in 
> EDK2 because test/data section offset is different than calculated 
> mCoffSectionsOffset when scanning sections.
> I run GenFW with a failure dll in my local after adding some logs into 
> GenFW. and found that “mCoffSectionsOffset” for data ection seems not 
> to have expected value due to
> “.note.gnu.property” size. Because compiled dll has 
> “.note.gnu.property” section with alloc flag and GenFW thinks that 
> it’s a text section if alloc flag is set.
> So its size is added to the mCoffSectionsOffset.
>
> Could you please give us an advice whether we can fix IsTextShdr() 
> function like below ?
>
>
> --- a/BaseTools/Source/C/GenFw/Elf64Convert.c
> +++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
> @@ -229,7 +229,7 @@ IsTextShdr (
>    Elf_Shdr *Shdr
>    )
> {
> -  return (BOOLEAN) ((Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == 
> SHF_ALLOC);
> +  return (BOOLEAN) ((Shdr->sh_flags & (SHF_EXECINSTR | SHF_WRITE | 
> SHF_ALLOC)) == (SHF_ALLOC | SHF_EXECINSTR));^
>
>
> Thanks,
> Mukesh
>
>
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#67282): https://edk2.groups.io/g/devel/message/67282
Mute This Topic: https://groups.io/mt/78163064/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list