From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.groups.io with SMTP id smtpd.web11.14780.1605134441125639409 for ; Wed, 11 Nov 2020 14:40:41 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IvUENS7O; spf=pass (domain: redhat.com, ip: 63.128.21.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605134440; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4mX9bH0tj9J8Qt8fqv2sCPhNHc9DgNgmzT/AUmcOXr8=; b=IvUENS7OsHuJpP95wA5bu3DsfdS06KSjhXjML/sRxUaBW5wbZa2B5eOCgt2KfS5/DXMtZm 8zAEFwfIcyRwA5B62nwhqAZzqGX7tMITWaPSOKgL2paz3GxT5STw6b+FiFWdldclak/ar+ rvd1MfOZC4lzUtFCgBrarF7z2COAPcE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-470-eLRs4PjTOxS7B-QaemvYmQ-1; Wed, 11 Nov 2020 17:40:36 -0500 X-MC-Unique: eLRs4PjTOxS7B-QaemvYmQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AD0871007466; Wed, 11 Nov 2020 22:40:34 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-85.ams2.redhat.com [10.36.113.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5AB845B4CF; Wed, 11 Nov 2020 22:40:33 +0000 (UTC) Subject: Re: [edk2-devel] : Query regarding IsTextShdr inside Basetools To: "Ard Biesheuvel (ARM address)" , "Liming Gao (Intel address)" References: Cc: devel@edk2.groups.io, mojha@codeaurora.org, discuss@edk2.groups.io From: "Laszlo Ersek" Message-ID: <9cd5c07e-d74d-5fa7-b3a7-2ef5fec01fc5@redhat.com> Date: Wed, 11 Nov 2020 23:40:32 +0100 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Ard, Liming, can you please take a look? Thanks! Laszlo On 11/10/20 14:07, 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 section 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 > > > > >