From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.15111.1682673645120336540 for ; Fri, 28 Apr 2023 02:20:45 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bwvqvSze; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8FB7060E9E for ; Fri, 28 Apr 2023 09:20:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 069CFC4339C for ; Fri, 28 Apr 2023 09:20:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682673644; bh=4gFDPoNdUMbgg2FptEbi2VUhIx674UmBk99PiqfXxOY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=bwvqvSzeD47nIhk4NamICyDfdTJE4STnRJOUPBEdYfYGpt5x4nDpJbyyTrpOGfjkz kMvSPLlVgkP4ZCfTSlSVNi/taU1mWcOB5+22ce2hK88857b6/WPYx+dnXbBmRC18gh Xe0lnaw2PGIf3OaQV5e+2ZUz8DwqUZ4hf8JmO17MiMcI6EFNEpS34zOwJqNZW1HYCm p5+OeYcpZSdl9FQLhF29Qiw04Ki7qmL0fbdvlE9d7fwyOITcCU3EvhAUjYwpdV6LXv t1ZSJNHYSz1zZrqwnyeoOZEtEkNzcLbmAjrRPsyP59u+bVPNaeLnSGUIfpcGCivwey z+RV8XhFgJi/A== Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-4efef769000so7039232e87.3 for ; Fri, 28 Apr 2023 02:20:43 -0700 (PDT) X-Gm-Message-State: AC+VfDxIgCI3+BESKVGjjpEnDdkFQPEW8NXSh46Dz/iZF58ZqQXH3Gr8 Bv2yD8UfCwrx9F7vKSGkqaYwocng9lbxjuhQ+Is= X-Google-Smtp-Source: ACHHUZ5IKEtO/njUdvtf8w98dqIugjxj9zadnM0xKowQ06Bal6yAzTK0XNa2yTfzKraZvjDv6bbYuUTMq3BcGx9gm8o= X-Received: by 2002:ac2:5691:0:b0:4ed:c17c:16e5 with SMTP id 17-20020ac25691000000b004edc17c16e5mr1451581lfr.17.1682673642009; Fri, 28 Apr 2023 02:20:42 -0700 (PDT) MIME-Version: 1.0 References: <20230427061714.510-1-gaoliming@byosoft.com.cn> <001501d97997$07241c90$156c55b0$@byosoft.com.cn> In-Reply-To: <001501d97997$07241c90$156c55b0$@byosoft.com.cn> From: "Ard Biesheuvel" Date: Fri, 28 Apr 2023 10:20:30 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH] MdePkg BasePeCoffLib: Ignore the debug entry read error after it is found To: devel@edk2.groups.io, gaoliming@byosoft.com.cn Cc: Michael Kubacki Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, 28 Apr 2023 at 07:02, gaoliming via groups.io wrote: > > Ard: > > > -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- > > =E5=8F=91=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io =E4=BB=A3=E8=A1=A8 Ard > > Biesheuvel > > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2023=E5=B9=B44=E6=9C=8827=E6=97= =A5 22:47 > > =E6=94=B6=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io; gaoliming@byosoft.co= m.cn > > =E6=8A=84=E9=80=81: Michael Kubacki > > =E4=B8=BB=E9=A2=98: Re: [edk2-devel] [PATCH] MdePkg BasePeCoffLib: Igno= re the debug > > entry read error after it is found > > > > On Thu, 27 Apr 2023 at 07:17, gaoliming via groups.io > > wrote: > > > > > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4425 > > > > > > This change is to support the pre-built EFI image on the old Edk2 cod= e. > > > Old Edk2 GenFw tool generates the wrong debug entry in EFI image. > > > Those pre-built images can be loaded before d6457b309. > > > > > > Signed-off-by: Liming Gao > > > Cc: Ard Biesheuvel > > > Cc: Michael Kubacki > > > --- > > > MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > > b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > > > index 4b71176a0c..4636842eeb 100644 > > > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > > > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > > > @@ -735,7 +735,7 @@ PeCoffLoaderGetImageInfo ( > > > &Size, > > > &DebugEntry > > > ); > > > - if (RETURN_ERROR (Status) || (Size !=3D ReadSize)) { > > > + if ((ImageContext->DebugDirectoryEntryRva =3D=3D 0) && > > (RETURN_ERROR (Status) || (Size !=3D ReadSize))) { > > > > I'm not sure I understand how this fixes anything. Why is the > > condition 'RVA =3D=3D 0' significant here? > > > > Would something like the below perhaps work as well? > > > > DebugDirectoryEntryRva will set to the real value if DEBUG_TYPE_CODEVIEW = is found. > If its value is not zero, it means DebugEntry has been found. This is not= an error, and don't need to report error here. > > > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > > @@ -755,6 +755,17 @@ PeCoffLoaderGetImageInfo ( > > ImageContext->ImageSize +=3D DebugEntry.SizeOfData; > > } > > > > + // > > + // Implementations of GenFw before commit > > 60e85a39fe49071 will > > + // concatenate the debug directory entry and the codeview > > entry, > > + // and erroneously put the combined size into the debug > > directory > > + // entry's size field. If this is the case, no other relev= ant > > + // directory entries can exist, and we can terminate here. > > + // > > + if (DebugEntry.FileOffset =3D=3D > > (DebugDirectoryEntryFileOffset + Index)) { > > + break; > > + } > > + > d6457b309 adds DEBUG_TYPE_EX_DLLCHARACTERISTICS support. So, there may be= two DEBUG entries in one EFI image. > One is DEBUG_TYPE_CODEVIEW, another is DEBUG_TYPE_EX_DLLCHARACTERISTICS. > > Here break after DEBUG_TYPE_CODEVIEW is found. So, is there the chance to= search DEBUG_TYPE_EX_DLLCHARACTERISTICS? > No. But if the codeview payload follows the codeview entry directly, there cannot be any other entries, so there is no reason to proceed.