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.web10.27378.1680188050337439860 for ; Thu, 30 Mar 2023 07:54:10 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GjCJqhWK; 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 CA208620BA for ; Thu, 30 Mar 2023 14:54:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A4D0C4339C for ; Thu, 30 Mar 2023 14:54:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680188049; bh=314Mrbc42LLPcxrqN/rwpOdLy2HFspAbsFngj7dha2c=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=GjCJqhWK50NVa/bCVLytu3H1Pu3X6Xe/0TV7MZi5QSIEV9qHuz4nSe8zHFzuF7Bhx DLvov1o+lLRXzjSqfIppFtYiHLOaXuM+nt/jfoU71mdJ76bDoWHuSSl6KkCAdmtkpO 49gnRSQg8tLIHl9W+3j7RgxQuuysHzZTqbQo+GQEa85RIhdjrA6ujKCNH2nrbKk9Z7 JBmomyxQ42yftSF6gU6wG7xRJxE8G55RixtRZOWKREKPWR6+6OfFoVyX28ShmriqHn MARsc0vrxBtD44EK8d/IeHJu0E27H+koIlnYMMeIxcbyLwY8z+lBvrJEvQcSefvyr/ +JJz3gFYIfmGg== Received: by mail-lf1-f48.google.com with SMTP id j11so24842965lfg.13 for ; Thu, 30 Mar 2023 07:54:09 -0700 (PDT) X-Gm-Message-State: AAQBX9fEtBU6g3Sk417Uq0jxmvuSspjbVM14lHIbBVlocK+TcEkYMtYj JIzakPiN2jE/MuKuYwuSLZmYI3qDnu78AyflX4Q= X-Google-Smtp-Source: AKy350a8rkjbwq2tIdhe+x1gD82SJVP4rUtI43LyacDsXgzAH17XroV9Qn9HSmxVvdltLeDNnemW4Xe6OsgPWuY9T/w= X-Received: by 2002:ac2:568d:0:b0:4eb:c44:ed50 with SMTP id 13-20020ac2568d000000b004eb0c44ed50mr5081153lfr.9.1680188047232; Thu, 30 Mar 2023 07:54:07 -0700 (PDT) MIME-Version: 1.0 References: <20230327110112.262503-1-ardb@kernel.org> <20230327110112.262503-17-ardb@kernel.org> <032fa5e2-d593-7129-27e4-e8d730814bb9@linux.microsoft.com> In-Reply-To: <032fa5e2-d593-7129-27e4-e8d730814bb9@linux.microsoft.com> From: "Ard Biesheuvel" Date: Thu, 30 Mar 2023 16:53:55 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH v2 16/17] MdePkg/PeCoffLib: Capture DLL characteristics fieldis in image context To: devel@edk2.groups.io, mikuback@linux.microsoft.com Cc: Michael Kinney , Liming Gao , Jiewen Yao , Michael Kubacki , Sean Brogan , Rebecca Cran , Leif Lindholm , Sami Mujawar , Taylor Beebe , =?UTF-8?Q?Marvin_H=C3=A4user?= , Bob Feng Content-Type: text/plain; charset="UTF-8" On Thu, 30 Mar 2023 at 16:45, Michael Kubacki wrote: > > On 3/27/2023 7:01 AM, Ard Biesheuvel wrote: > > When loading a PE/COFF image, capture the DLL characteristics fields of > > the header into our image context structure so we can refer to them when > > mapping the image. > > > > Signed-off-by: Ard Biesheuvel > > --- > > MdePkg/Include/IndustryStandard/PeImage.h | 13 +++++- > > MdePkg/Include/Library/PeCoffLib.h | 6 +++ > > MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 46 +++++++++++++++----- > > 3 files changed, 53 insertions(+), 12 deletions(-) > > > > diff --git a/MdePkg/Include/IndustryStandard/PeImage.h b/MdePkg/Include/IndustryStandard/PeImage.h > > index dd4cc25483bc4bcf..a5b9b848ed391f98 100644 > > --- a/MdePkg/Include/IndustryStandard/PeImage.h > > +++ b/MdePkg/Include/IndustryStandard/PeImage.h > > @@ -625,7 +625,8 @@ typedef struct { > > UINT32 FileOffset; ///< The file pointer to the debug data. > > > > } EFI_IMAGE_DEBUG_DIRECTORY_ENTRY; > > > > > > > > -#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2 ///< The Visual C++ debug information. > > > > +#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2 ///< The Visual C++ debug information. > > > > +#define EFI_IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS 20 > > > > > > > > /// > > > > /// Debug Data Structure defined in Microsoft C++. > > > > @@ -669,6 +670,16 @@ typedef struct { > > // > > > > } EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY; > > > > > > > > +/// > > > > +/// Extended DLL Characteristics > > > > +/// > > > > +#define EFI_IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT 0x0001 > > > > +#define EFI_IMAGE_DLLCHARACTERISTICS_EX_FORWARD_CFI_COMPAT 0x0040 > > > > + > > > > +typedef struct { > > > > + UINT16 DllCharacteristicsEx; > > > > +} EFI_IMAGE_DEBUG_EX_DLLCHARACTERISTICS_ENTRY; > > > > + > > > > /// > > > > /// Resource format. > > > > /// > > > > diff --git a/MdePkg/Include/Library/PeCoffLib.h b/MdePkg/Include/Library/PeCoffLib.h > > index b45879453785c77d..d21c932076c072f6 100644 > > --- a/MdePkg/Include/Library/PeCoffLib.h > > +++ b/MdePkg/Include/Library/PeCoffLib.h > > @@ -171,6 +171,12 @@ typedef struct { > > /// > > > > UINT16 ImageType; > > > > /// > > > > + /// Set by PeCoffLoaderGetImageInfo() to the DLL flags stored in the PE/COFF header and > > > > + /// in the DllCharacteristicsEx debug table. > > > > + /// > > > > + UINT16 DllCharacteristics; > > > > + UINT16 DllCharacteristicsEx; > > > I know DllCharacteristics has a size of 2 in the spec, but the > DllCharacteristicsEx is defined as 4 bytes. I will try to get a spec > update to clarify this. > Thanks. I'll change this to 4 in the next respin.