From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from m42-4.mailgun.net (m42-4.mailgun.net [69.72.42.4]) by mx.groups.io with SMTP id smtpd.web10.3579.1605078546895747167 for ; Tue, 10 Nov 2020 23:09:07 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=wWruzpXQ; spf=pass (domain: mg.codeaurora.org, ip: 69.72.42.4, mailfrom: bounce+b068b4.be9e4a-devel=edk2.groups.io@mg.codeaurora.org) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1605078546; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: Cc: References: Reply-To: To: From: Subject: Sender; bh=cATCxevmgxY5SSoLEQNYuVBNBOKpuAXGJax/ecKbt/o=; b=wWruzpXQJ2fMRxcqRyL8843QdMtSMgvvTbKC9Kd1zwUoACzpWNQRpM9J4rmb5yaKfFzOxG2o Yp54hCh/yfxJWux38ROo2UY8v73Zz9kq4nk7lgZH087W9WibbTMol0gLfwzdNo0rQDVJdA2s 6BfzI5RheC7L25sbhmdAvEFkWFw= X-Mailgun-Sending-Ip: 69.72.42.4 X-Mailgun-Sid: WyI3NDFkMyIsICJkZXZlbEBlZGsyLmdyb3Vwcy5pbyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-west-2.postgun.com with SMTP id 5fab8e10e9dd187f5380d521 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 11 Nov 2020 07:09:04 GMT Sender: mojha=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 77287C433C6; Wed, 11 Nov 2020 07:09:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, NICE_REPLY_A,SPF_FAIL,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from [192.168.29.2] (unknown [49.37.83.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mojha) by smtp.codeaurora.org (Postfix) with ESMTPSA id 77DA1C433C8; Wed, 11 Nov 2020 07:08:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 77DA1C433C8 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=mojha@codeaurora.org Subject: Re: [edk2-devel] : Query regarding IsTextShdr inside Basetools From: "Mukesh Ojha" To: devel@edk2.groups.io, discuss@edk2.groups.io Reply-To: devel@edk2.groups.io References: <164632B1BC861BDB.31324@groups.io> Cc: mojha@codeaurora.org Message-ID: Date: Wed, 11 Nov 2020 12:37:58 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <164632B1BC861BDB.31324@groups.io> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US 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 > > > > >