From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (NAM02-BN1-obe.outbound.protection.outlook.com [40.92.15.17]) by mx.groups.io with SMTP id smtpd.web11.3981.1642819807049680913 for ; Fri, 21 Jan 2022 18:50:07 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=noH3+8LV; spf=pass (domain: outlook.com, ip: 40.92.15.17, mailfrom: michael.kubacki@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bJMZrjxj8xwSudPGT4WQiGSg+VVRVs2fZbHRpqg9C9Lc2j+LoK46BUpNpP6ECrFVOhkWzAQYE0rn2SLNjCgitvUPA9NpiAEhmOQLuZbw91fCGTn0r9sck52TMD6JCTPDlxO6Wzk1AAJAdU7znLJiRj+IcbFhb6/fgGpIFBbhvsDHV6UY8dnWhOW67fa/PjEj8MvLLCfkRE/tR5/tFlUaWNQGVLIpLgAuhpZbQCmt31vW24wAMoZKELPt9uOCN5i03Z3yDh58+4u1pSjkBBa4G1FYvHcQFVgfdv7rb5fSn9BI4tS6A6zG5TtDLgrqLJv6+WRT5bylZFpbfCVxEUsUkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=S4lwFKRSSZueBen9+bxJG5AMQTsGTtTA8DQoq2SZlTE=; b=lMt3xuCgd7v6XEzAOTESNZCaXpM71zA7fj5DY8pt1Kivtm5lgsPkWplH6zUMFnwmJ+789tmNv5ieziQxNao+OmjEiKZpX/3G9Mhm0q2RlUmbp0uMHuOYve/L09mE/AAB8oSP3ov9qd1n51NNK+jZaterCJWZ5jstXHKwDIWqsjtEyn9Z9VbMsaGkQxV61s6myjVB9xgL2opztxYHU6g0i/M90ehLeYQ/ZkhpIWwExEcfJQpO98pkt6GX3+jREpJHcjYUl3svwyTVzdZFIpUNEhSvrBjrBIxs2IbWa9uPbtYmjUobMpVQT4hL61tOie+DWiqW4ZVqIZUUT0u2HfvyXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S4lwFKRSSZueBen9+bxJG5AMQTsGTtTA8DQoq2SZlTE=; b=noH3+8LVx1kBuBYjAa1ZOX18HOmn+WgDDkDOtyR1lWoF1vDCUQSBWDoLIQYA2BO3QFfMJd+38tdtWzS00IDtmNN9KDDP19ON5kP6gHMZnZOz6imtal8ZZcRBxDTpL3FIH7KP9yzMW20BOdtkHHoSMvXlN17rORcKc6ESiXH6HmSB8cvNLxGl3TPR0tAdLwsXZ+/AUIleO+gEw2dxEuYfA5OWaIopqH8udZSlwuA7NHFvvdwaEGmfvi1UBepfmXuIgutkpGVCkf17IVIvErPGN1SAkcCm0oxCxvAmhwPtnlEAQ4LAoJPT2uzWAS3xFMSHhZhde+XZ6JLalusu9lRFmQ== Received: from MWHPR07MB3440.namprd07.prod.outlook.com (2603:10b6:301:69::28) by BLAPR07MB7779.namprd07.prod.outlook.com (2603:10b6:208:29e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Sat, 22 Jan 2022 02:50:05 +0000 Received: from MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::69d2:4447:acdf:1a4d]) by MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::69d2:4447:acdf:1a4d%7]) with mapi id 15.20.4888.014; Sat, 22 Jan 2022 02:50:04 +0000 Message-ID: Date: Fri, 21 Jan 2022 21:50:00 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [edk2-devel][PATCH] BaseTools/GenFw: Enhance to add export table in PE-COFF To: devel@edk2.groups.io, lisa.huang@intel.com, "Gao, Liming" , "Feng, Bob C" CC: "Chen, Christine" , "Wu, Yidong" , "Xu, Wei6" , "You, Benjamin" , "mikuback@linux.microsoft.com" References: <20220112074423.5075-1-lisa.huang@intel.com> <002001d80c2b$150f2230$3f2d6690$@byosoft.com.cn> From: "Michael Kubacki" In-Reply-To: X-TMN: [J61AmVDu8qB13C3ZJvtJmsAM1NRC+dKbx70rYukSKKaF8TQSh6lRa6Fot3ruZbFl] X-ClientProxiedBy: BN6PR13CA0041.namprd13.prod.outlook.com (2603:10b6:404:13e::27) To MWHPR07MB3440.namprd07.prod.outlook.com (2603:10b6:301:69::28) Return-Path: michael.kubacki@outlook.com X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 325db011-cf5f-4b0e-dab8-08d9dd51e41f X-MS-TrafficTypeDiagnostic: BLAPR07MB7779:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mFl+MrC85BYBKp7KxA7TrH62jZ0oKS0zMitolx0XQwIKRLRJqts9QI0cN6wxeugEruHKbcuxAd4UdNqmbIMBM3M2as13KkSJTZNnsNiUCXjjH6eglMC6113ReSEjTfu3ruNjTQ6sIOqY4zVWSWz3q8z/tPwrIho1KnNOPHKkn5U2Tu3PHOptWbZxgXGTBb4yOCXYNisq1fG9w8U9gqJC2wwwUKgKqQAbrLNArye+96BKxsUIVIEmF/a+WnSaSNysipb+m7j3iJTjNSNf347w9lTii7NlbF4zjgI4yX5hbLqeLQw/f/6Xah3I2Zc1AM3+BGM90W60mzN2Lx7WuoTGxT9HwuRVQMX/hTKrwfkQ+g2zK59Nqv0AQInB85t77eIpvMNNq06Z/mPYT80nX/Omh9P/Z8hewjY/DKIXtybNgcyKrtwGRmP/mY0VYIMPYAHgLmxrdPNxEpoNdeOuXQ4E3LMMXRF1fZ9RH+oMu9f2puChi/pyMl7NOFZQ9zp3c9NzF6EvBrGagVxLV5z3qLVcen21XCeXenaZTVkqeN+f6K2uOMXf839MApawiDU1jVFOThLX20hUSHDc7opsPi0usOPKvMsgIrOiaPdO9OPlg+/zxi96vLFsMqgSUOp0LK3oBNwQquyrrXRjdSbAVkisKQ== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?1gpmb3+tUvaWKfALBjPb+RcAwWeYui97MQ0Viw0VHuCEgHXjckRsooxgNPrw?= =?us-ascii?Q?6C+APzSQvY6jb3FdvYA8bGUPIZlMVHY4RrPWPxhGL/BJ+SQbh8pHZFgqCgvR?= =?us-ascii?Q?UtVGLwHCbAdln77OWP2ENQ+fbIsaEDU51ewehO0xVYIFI0jkaKBDsKGAAt6E?= =?us-ascii?Q?0NOhbZTkM9uvn8ARMYTmI4myun1sx7C1EkWCfLtu0rwhWHkesZ6ugSr5Iaoy?= =?us-ascii?Q?s1hShzCtmBPJcoyLMxYeeUcv1+q24j9in0/KRz7LQL845ypkbvX8J9yaIQ6n?= =?us-ascii?Q?Ax8O9WnAxhGcnkJOqkbOSHd8YUijFEvKR842IB9f25PyQj3SkkcvtE3v4Mg2?= =?us-ascii?Q?H3L6qcrsaiWHRYO+x5C2oyV6esE/+3BRAu+wFUSCcimjA1RZ9BmW1i/3sobb?= =?us-ascii?Q?oWCHqSpJAsEOa48Ur0k41MEANqV8sh9VgA5XNZVxu4sN5hyzn1KUYt0wM6V5?= =?us-ascii?Q?sYESgBVWreLErG3DJLAfPU/utmf5790MuRzmTNSB/GoeES7pRCfU4wq5vc1e?= =?us-ascii?Q?nqAwsnTi+kmEuctlsmIKmOBCFof9bijeb3LSbEIx5+M+lvM0TUNjOQiyW+l1?= =?us-ascii?Q?f2FJTty2zZxteSm9uIYdxxiyeK24Dmt4KaoX1nk4fPVHhlWg5fRkzHa2+/1U?= =?us-ascii?Q?+efN07QDpWY71TL7CS8Qe2A6flOdd8XinwzkbG4JXBfAdjEt0rq0rwVlH9Ci?= =?us-ascii?Q?uFYB9OMx0TrChdS1uAYIl5xUn7731LtjrQX0G0mdjwxn4sqagU15jPMkU8C8?= =?us-ascii?Q?tP4YRA2HJJLa1Q/vVE6r8U9bu+bA0oIYXIl948WCuJKLzJ31nP29uOc4HEXm?= =?us-ascii?Q?JGJG9K7L+JLv9y2vNbpWFqWk79XLSCTUEBKfj2g1czgwa4igyBcbVK6hzD9h?= =?us-ascii?Q?vWr1euR+WNWMKLHP0x+ZF9pBfxxvJ1f0omoZFGO0fuUPgO5GlNCJ5BxvIIUn?= =?us-ascii?Q?u0QnJoBLIHkxOQZFTak1lBN8w1jxEEulACp8sLR0/H65hnEC8Z+35evHU9fg?= =?us-ascii?Q?K/1d?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 325db011-cf5f-4b0e-dab8-08d9dd51e41f X-MS-Exchange-CrossTenant-AuthSource: MWHPR07MB3440.namprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2022 02:50:04.8861 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR07MB7779 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Hi Lisa, Thank you for contributing this. Please include me on functionality=20 related to PRM. I was using the PRM_EXPORT_API macro=20 (https://github.com/tianocore/edk2-staging/blob/9da8abf66505d8ff636aaecc429= a5237ce226650/PrmPkg/Include/Prm.h#L17)=20 to support this on MS toolchain. It looks like this is to add similar functionality for ELF binaries=20 using GenFw? Thanks, Michael On 1/18/2022 1:19 AM, Huang, Li-Xia wrote: > Hi Liming, >=20 > Thanks for your feedback. >=20 > I have added some detail in BZ. =F0=9F=98=8A >=20 > https://bugzilla.tianocore.org/show_bug.cgi?id=3D3802#add_comment=20 > >=20 > Regards, >=20 > Lisa >=20 > *From:*gaoliming > *Sent:* 2022=E5=B9=B41=E6=9C=8818=E6=97=A513:20 > *To:* devel@edk2.groups.io; Huang, Li-Xia ; Feng,= =20 > Bob C > *Cc:* Chen, Christine ; Wu, Yidong=20 > ; Xu, Wei6 ; You, Benjamin=20 > > *Subject:* =E5=9B=9E=E5=A4=8D: [edk2-devel][PATCH] BaseTools/GenFw: Enhan= ce to add=20 > export table in PE-COFF >=20 > Lisa: >=20 > =C2=A0Can you give more background about PRM usage? What new usage requi= res=20 > RPM? Can you add the detail in BZ? >=20 > Thanks >=20 > Liming >=20 > *=E5=8F=91=E4=BB=B6=E4=BA=BA**:*devel@edk2.groups.io=20 > > *=E4=BB=A3=E8=A1=A8 *Huang, Li-Xia > *=E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4:* 2022=E5=B9=B41=E6=9C=8817=E6=97= =A5 11:09 > *=E6=94=B6=E4=BB=B6=E4=BA=BA:* Feng, Bob C >; devel@edk2.groups.io=20 > > *=E6=8A=84=E9=80=81:* Gao, Liming >; Chen, Christine=20 > >; Wu, Yidong=20 > >; Xu, Wei6=20 > >; You, Benjamin=20 > > > *=E4=B8=BB=E9=A2=98:* Re: [edk2-devel][PATCH] BaseTools/GenFw: Enhance to= add export=20 > table in PE-COFF >=20 > Hi Bob, >=20 > Thanks for your comments. >=20 > 1.=C2=A0 I will add the help information for "--PRM"; >=20 > 2. >=20 > @@ -750,7 +818,7 @@ ScanSections64 ( >=20 > =C2=A0=C2=A0=C2=A0=C2=A0 if (shdr->sh_addralign <=3D mCoffAlignment) { >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 continue; >=20 > =C2=A0=C2=A0=C2=A0=C2=A0 } >=20 > -=C2=A0=C2=A0=C2=A0 if (IsTextShdr(shdr) || IsDataShdr(shdr) || IsHiiRsrc= Shdr(shdr)) { >=20 > +=C2=A0=C2=A0=C2=A0 if (IsTextShdr(shdr) || IsDataShdr(shdr) || IsHiiRsrc= Shdr(shdr) ||=20 > IsSymbolShdr(shdr)) { >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mCoffAlignment =3D (UINT32)shdr->sh= _addralign; >=20 > =C2=A0=C2=A0=C2=A0=C2=A0 } >=20 > =C2=A0=C2=A0 } >=20 > 1) Above change is to Set mCoffAlignment to the maximum alignment of the= =20 > input sections including symbol section. >=20 > =C2=A0=C2=A0=C2=A0=C2=A0The symbol section will only exist with below ch= ange, so it should=20 > have no effect to other drivers. >=20 > build_rule.template: >=20 > =C2=A0=C2=A0=C2=A0 >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 $(CP) ${src} $(DEBUG_DIR)(+)$= (MODULE_NAME).debug >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #$(OBJCOPY) --strip-unneeded = -R .eh_frame ${src} >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 $(OBJCOPY) $(OBJCOPY_STRIPFLA= G) ${src} >=20 > tools_def.template: >=20 > *_*_*_OBJCOPY_STRIPFLAG=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 =3D --strip-unneeded -R .eh_frame >=20 > PrmAddrTransDsm.inf: >=20 > [BuildOptions.common] >=20 > ... >=20 > =C2=A0 GCC: *_*_*_OBJCOPY_STRIPFLAG =3D=3D -R .eh_frame >=20 > 2) For PRM driver, sh_addralign of symbol section is 8, and less than=20 > other sections such as Text and Data (sh_addralign is 4096). >=20 > Regards, >=20 > Lisa >=20 > -----Original Message----- > From: Feng, Bob C > > Sent: 2022=E5=B9=B41=E6=9C=8814=E6=97=A5 14:12 > To: Huang, Li-Xia >;= =20 > devel@edk2.groups.io > Cc: Gao, Liming >; Chen, Christine=20 > > > Subject: RE: [edk2-devel][PATCH] BaseTools/GenFw: Enhance to add export= =20 > table in PE-COFF >=20 > Hi Lixia, >=20 > This patch introduce a new command line option --PRM. Could you add the= =20 > help information about --PRM? >=20 > Could you provide more information about the below change? Would there=20 > be side-effect? >=20 > @@ -750,7 +818,7 @@ ScanSections64 ( >=20 > =C2=A0=C2=A0=C2=A0=C2=A0 if (shdr->sh_addralign <=3D mCoffAlignment) { >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 continue; >=20 > =C2=A0=C2=A0=C2=A0=C2=A0 } >=20 > -=C2=A0=C2=A0=C2=A0 if (IsTextShdr(shdr) || IsDataShdr(shdr) || IsHiiRsrc= Shdr(shdr)) { >=20 > +=C2=A0=C2=A0=C2=A0 if (IsTextShdr(shdr) || IsDataShdr(shdr) || IsHiiRsrc= Shdr(shdr) ||=20 > IsSymbolShdr(shdr)) { >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mCoffAlignment =3D (UINT32)shdr->sh= _addralign; >=20 > =C2=A0=C2=A0=C2=A0=C2=A0 } >=20 > =C2=A0=C2=A0 } >=20 > Thanks, >=20 > Bob >=20 > -----Original Message----- >=20 > From: Huang, Li-Xia > >=20 > Sent: Wednesday, January 12, 2022 3:44 PM >=20 > To: devel@edk2.groups.io >=20 > Cc: Huang, Li-Xia >;= =20 > Gao, Liming >; Feng, Bob C >; Chen, Christine > >=20 > Subject: [edk2-devel][PATCH] BaseTools/GenFw: Enhance to add export=20 > table in PE-COFF >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3802=20 > >=20 > Since PRM module needs to support export table in PE-COFF, we'll enhance= =20 > GenFw tool to support this. >=20 > Add one export flag in GenFw tool. If export flag is set: >=20 > Step1: Scan ELF symbol table based on PRM module descriptor to get=20 > descriptor offset address; >=20 > Step2: Find PRM handlers number and name in COFF file based on the=20 > address from step1; >=20 > Step3: Write PRM info such as handler name and export RVA into COFF=20 > export table. >=20 > Cc: Liming Gao > >=20 > Cc: Bob Feng > >=20 > Cc: Yuwei Chen > >=20 > Signed-off-by: Lixia Huang > >=20 > --- >=20 > BaseTools/Source/C/GenFw/Elf64Convert.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 | 254 +++++++++++++++++- >=20 > BaseTools/Source/C/GenFw/ElfConvert.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 |=C2=A0 10 + >=20 > BaseTools/Source/C/GenFw/ElfConvert.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 |=C2=A0 42 ++- >=20 > BaseTools/Source/C/GenFw/GenFw.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 11 +- >=20 > .../C/Include/IndustryStandard/PeImage.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |= =C2=A0=C2=A0 7 + >=20 > 5 files changed, 318 insertions(+), 6 deletions(-) >=20 > diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c=20 > b/BaseTools/Source/C/GenFw/Elf64Convert.c >=20 > index 0bb3ead228..0079507356 100644 >=20 > --- a/BaseTools/Source/C/GenFw/Elf64Convert.c >=20 > +++ b/BaseTools/Source/C/GenFw/Elf64Convert.c >=20 > @@ -56,6 +56,18 @@ WriteDebug64 ( >=20 > =C2=A0=C2=A0 VOID=C2=A0=C2=A0 ); +STATIC+VOID+ScanSymbol64 (+=C2=A0 VOID= + =20 > );++STATIC+VOID+WriteExport64 (+=C2=A0 VOID+=C2=A0 );+ STATIC VOID SetIma= geSize64=20 > (@@ -122,7 +134,7 @@ STATIC UINT32 mDataOffset; >=20 > STATIC UINT32 mHiiRsrcOffset; STATIC UINT32 mRelocOffset; STATIC UINT32= =20 > mDebugOffset;-+STATIC UINT32 mExportOffset; // // Used for RISC-V=20 > relocations. //@@ -132,6 +144,14 @@ STATIC Elf64_Half =20 > mRiscVPass1SymSecIndex =3D 0; >=20 > STATIC INT32=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mRiscVPass1Offset; STATI= C INT32 =20 > mRiscVPass1GotFixup; +//+// Used for Export section.+//+STATIC=20 > UINT32=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mExportSize;+STATIC UINT32 =20 > mExportRVA[PRM_MODULE_EXPORT_SYMBOL_NUM];+STATIC UINT32 =20 > mExportSymNum;+STATIC CHAR8 =20 > mExportSymName[PRM_MODULE_EXPORT_SYMBOL_NUM][PRM_HANDLER_NAME_MAXIMUM_LEN= GTH];+=20 > // // Initialization Function //@@ -200,6 +220,10 @@ InitializeElf64 ( >=20 > =C2=A0=C2=A0 ElfFunctions->SetImageSize =3D SetImageSize64;=C2=A0=C2=A0 = ElfFunctions->CleanUp=20 > =3D CleanUp64; +=C2=A0 if (mExportFlag) {+=C2=A0=C2=A0=C2=A0 ElfFunctions= ->ScanSymbol =3D=20 > ScanSymbol64;+=C2=A0=C2=A0=C2=A0 ElfFunctions->WriteExport =3D WriteExpor= t64;+=C2=A0 } =20 > return TRUE; } @@ -263,6 +287,17 @@ IsHiiRsrcShdr ( >=20 > =C2=A0=C2=A0 return (BOOLEAN) (strcmp((CHAR8*)mEhdr + Namedr->sh_offset = +=20 > Shdr->sh_name, ELF_HII_SECTION_NAME) =3D=3D 0); }=20 > +STATIC+BOOLEAN+IsSymbolShdr (+=C2=A0 Elf_Shdr *Shdr+=C2=A0 )+{+=C2=A0 El= f_Shdr=20 > *Namehdr =3D GetShdrByIndex(mEhdr->e_shstrndx);++=C2=A0 return (BOOLEAN)= =20 > (strcmp((CHAR8*)mEhdr + Namehdr->sh_offset + Shdr->sh_name,=20 > ELF_SYMBOL_SECTION_NAME) =3D=3D 0);+}+ STATIC BOOLEAN IsDataShdr (@@ -335= ,6=20 > +370,38 @@ GetSymName ( >=20 > =C2=A0=C2=A0 return StrtabContents + Sym->st_name; } +//+// Get Prm Hand= ler=20 > number and name+//+STATIC+VOID+FindPrmHandler (+=C2=A0 UINT64 Offset+=C2= =A0 )+{+ =20 > PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER *PrmExport;+=C2=A0 UINT32 =20 > NameOffset;+=C2=A0 UINT32=C2=A0=C2=A0 HandlerNum;+ UINT32=C2=A0=C2=A0 Ind= ex;+=C2=A0 UINT8 =20 > SymName[PRM_HANDLER_NAME_MAXIMUM_LENGTH];++=C2=A0 PrmExport =3D=20 > (PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER*)(mCoffFile + Offset);+ =20 > NameOffset =3D sizeof(PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER) +=20 > sizeof(EFI_GUID);++=C2=A0 for (HandlerNum =3D 0; HandlerNum <=20 > PrmExport->NumberPrmHandlers; HandlerNum++) {+=C2=A0=C2=A0=C2=A0 for (Ind= ex =3D 0; Index=20 > < PRM_HANDLER_NAME_MAXIMUM_LENGTH; Index++) {+=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 SymName[Index] =3D=20 > *((UINT8 *)PrmExport + NameOffset + Index);+=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 if (SymName[Index] =3D=3D=20 > 0) {+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break;+ }+=C2=A0=C2=A0=C2= =A0 }++=C2=A0=C2=A0=C2=A0 strcpy(mExportSymName[mExportSymNum],=20 > (CHAR8*)SymName);+=C2=A0=C2=A0=C2=A0 NameOffset +=3D PRM_HANDLER_NAME_MAX= IMUM_LENGTH +=20 > sizeof(EFI_GUID);+=C2=A0=C2=A0=C2=A0 mExportSymNum ++;+=C2=A0 }+}+ // // = Find the ELF=20 > section hosting the GOT from an ELF Rva //=C2=A0=C2=A0 of a single GOT en= try.=20 > Normally, GOT is placed in@@ -717,6 +784,7 @@ ScanSections64 ( >=20 > =C2=A0=C2=A0 UINT32=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 CoffEntry; =20 > UINT32=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 SectionCount; =20 > BOOLEAN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 FoundSection;+ =20 > UINT32=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 Offset;=C2=A0=C2=A0=C2=A0 CoffEntry =3D 0;=C2=A0=C2=A0 mCoffOffse= t=20 > =3D 0;@@ -750,7 +818,7 @@ ScanSections64 ( >=20 > =C2=A0=C2=A0=C2=A0=C2=A0 if (shdr->sh_addralign <=3D mCoffAlignment) {= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 continue; =20 > }-=C2=A0=C2=A0=C2=A0 if (IsTextShdr(shdr) || IsDataShdr(shdr) || IsHiiRsr= cShdr(shdr))=20 > {+=C2=A0=C2=A0=C2=A0 if (IsTextShdr(shdr) || IsDataShdr(shdr) || IsHiiRsr= cShdr(shdr) ||=20 > IsSymbolShdr(shdr)) {=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mCoffAlignment = =3D=20 > (UINT32)shdr->sh_addralign;=C2=A0=C2=A0=C2=A0=C2=A0 }=C2=A0=C2=A0 }@@ -88= 0,6 +948,16 @@ ScanSections64 ( >=20 > =C2=A0=C2=A0=C2=A0=C2=A0 Warning (NULL, 0, 0, NULL, "Multiple sections i= n %s are merged=20 > into 1 data section. Source level debug might not work correctly.",=20 > mInImageName);=C2=A0=C2=A0 } +=C2=A0 //+=C2=A0 //=C2=A0 The Symbol sectio= ns.+=C2=A0 //+=C2=A0 if=20 > (mExportFlag) {+=C2=A0=C2=A0=C2=A0 mExportOffset =3D mCoffOffset;+=C2=A0= =C2=A0=C2=A0 mExportSize =3D=20 > sizeof(EFI_IMAGE_EXPORT_DIRECTORY) + strlen(mInImageName) + 1;+ =20 > mCoffOffset +=3D mExportSize;+=C2=A0=C2=A0=C2=A0 mCoffOffset =3D CoffAlig= n(mCoffOffset);+ =20 > }+=C2=A0=C2=A0 //=C2=A0=C2=A0 //=C2=A0 The HII resource sections.=C2=A0= =C2=A0 //@@ -962,7 +1040,11 @@=20 > ScanSections64 ( >=20 > =C2=A0=C2=A0=C2=A0=C2=A0 | EFI_IMAGE_FILE_LARGE_ADDRESS_AWARE; =20 > NtHdr->Pe32Plus.OptionalHeader.SizeOfCode =3D mDataOffset - mTextOffset;-= =20 > NtHdr->Pe32Plus.OptionalHeader.SizeOfInitializedData =3D mRelocOffset -= =20 > mDataOffset;+=C2=A0 if(mExportFlag) {+ =20 > NtHdr->Pe32Plus.OptionalHeader.SizeOfInitializedData =3D mRelocOffset -= =20 > mExportOffset;+=C2=A0 } else {+ =20 > NtHdr->Pe32Plus.OptionalHeader.SizeOfInitializedData =3D mRelocOffset -= =20 > mDataOffset;+=C2=A0 } =20 > NtHdr->Pe32Plus.OptionalHeader.SizeOfUninitializedData =3D 0; =20 > NtHdr->Pe32Plus.OptionalHeader.AddressOfEntryPoint =3D CoffEntry; @@=20 > -989,8 +1071,17 @@ ScanSections64 ( >=20 > =C2=A0=C2=A0=C2=A0=C2=A0 NtHdr->Pe32Plus.FileHeader.NumberOfSections--;= =C2=A0=C2=A0 } +=C2=A0 //+=C2=A0 // If=20 > found symbol, add edata section between data and rsrc section+=C2=A0 //+ = =20 > if(mExportFlag) {+=C2=A0=C2=A0=C2=A0 Offset =3D mExportOffset;+=C2=A0 } e= lse {+=C2=A0=C2=A0=C2=A0 Offset =3D=20 > mHiiRsrcOffset;+=C2=A0 }+=C2=A0=C2=A0 if ((mHiiRsrcOffset - mDataOffset) = > 0) {- =20 > CreateSectionHeader (".data", mDataOffset, mHiiRsrcOffset -=20 > mDataOffset,+=C2=A0=C2=A0=C2=A0 CreateSectionHeader (".data", mDataOffset= , Offset -=20 > mDataOffset,=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 EFI_IMAGE_SCN_CNT_INITIALIZED_DATA =20 > | EFI_IMAGE_SCN_MEM_WRITE | EFI_IMAGE_SCN_MEM_READ);@@ -999,6 +1090,20=20 > @@ ScanSections64 ( >=20 > =C2=A0=C2=A0=C2=A0=C2=A0 NtHdr->Pe32Plus.FileHeader.NumberOfSections--;= =C2=A0=C2=A0 } + =20 > if(mExportFlag) {+=C2=A0=C2=A0=C2=A0 if ((mHiiRsrcOffset - mExportOffset)= > 0) {+ =20 > CreateSectionHeader (".edata", mExportOffset, mHiiRsrcOffset -=20 > mExportOffset,+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 EFI_IMAGE_SCN_CNT_INITIALIZED_DATA+ |=20 > EFI_IMAGE_SCN_MEM_READ);+ =20 > NtHdr->Pe32Plus.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EX= PORT].Size=20 > =3D mHiiRsrcOffset - mExportOffset;+ =20 > NtHdr->Pe32Plus.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EX= PORT].VirtualAddress=20 > =3D mExportOffset;+ NtHdr->Pe32Plus.FileHeader.NumberOfSections++;+=C2=A0= =C2=A0=C2=A0 }=20 > else {+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // Don't make a section of size 0.+= =20 > NtHdr->Pe32Plus.FileHeader.NumberOfSections--;+=C2=A0=C2=A0=C2=A0 }+=C2= =A0 }+=C2=A0=C2=A0 if=20 > ((mRelocOffset - mHiiRsrcOffset) > 0) {=C2=A0=C2=A0=C2=A0=C2=A0 CreateSec= tionHeader=20 > (".rsrc", mHiiRsrcOffset, mRelocOffset - mHiiRsrcOffset, =20 > EFI_IMAGE_SCN_CNT_INITIALIZED_DATA@@ -1757,4 +1862,145 @@ CleanUp64 ( >=20 > =C2=A0=C2=A0 } } +STATIC+VOID+ScanSymbol64 (+=C2=A0 VOID+=C2=A0 )+{+=C2= =A0 UINT32 =20 > shIndex;+=C2=A0 UINT32=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 SymIndex;+=C2=A0 Elf= _Sym=C2=A0=C2=A0=C2=A0=C2=A0 *Sym;+=C2=A0 UINT64 =20 > SymNum;+=C2=A0 const UINT8 *SymName;++=C2=A0 for (shIndex =3D 0; shIndex = <=20 > mEhdr->e_shnum; shIndex++) {+=C2=A0=C2=A0=C2=A0 //+=C2=A0=C2=A0=C2=A0 // = Determine if this is a symbol=20 > section.+=C2=A0=C2=A0=C2=A0 //+=C2=A0=C2=A0=C2=A0 Elf_Shdr *shdr =3D GetS= hdrByIndex(shIndex);+=C2=A0=C2=A0=C2=A0 if=20 > (!IsSymbolShdr(shdr)) {+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 continue;+=C2=A0= =C2=A0=C2=A0 }++=C2=A0=C2=A0=C2=A0 UINT8=C2=A0=C2=A0=C2=A0 *Symtab =3D=20 > (UINT8*)mEhdr + shdr->sh_offset;+=C2=A0=C2=A0=C2=A0 SymNum =3D (shdr->sh_= size) /=20 > (shdr->sh_entsize);++ //+=C2=A0=C2=A0=C2=A0 // First Get PrmModuleExportD= escriptor+ =20 > //+=C2=A0=C2=A0=C2=A0 for (SymIndex =3D 0; SymIndex < SymNum; SymIndex++)= {+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Sym =3D=20 > (Elf_Sym *)(Symtab + SymIndex * shdr->sh_entsize);+=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 SymName =3D=20 > GetSymName(Sym);+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (SymName =3D=3D NULL) = {+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 continue;+=20 > }++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (strcmp((CHAR8*)SymName, PRM_MODULE_= EXPORT_DESCRIPTOR_NAME)=20 > =3D=3D 0) {+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 //+=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 // Find PrmHandler Number and Name+ =20 > //+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 FindPrmHandler(Sym->st_valu= e);++ =20 > strcpy(mExportSymName[mExportSymNum], (CHAR8*)SymName);+=20 > mExportRVA[mExportSymNum] =3D (UINT32)(Sym->st_value);+=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 mExportSize=20 > +=3D 2 * EFI_IMAGE_EXPORT_ADDR_SIZE + EFI_IMAGE_EXPORT_ORDINAL_SIZE +=20 > strlen((CHAR8 *)SymName) + 1;+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = mExportSymNum ++;+ =20 > break;+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }+=C2=A0=C2=A0=C2=A0 }++=C2=A0=C2= =A0=C2=A0 //+=C2=A0=C2=A0=C2=A0 // Second Get PrmHandler+ //+=C2=A0=C2=A0= =C2=A0 for=20 > (SymIndex =3D 0; SymIndex < SymNum; SymIndex++) {+=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 UINT32 =20 > ExpIndex;+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Sym =3D (Elf_Sym *)(Symtab + Sym= Index *=20 > shdr->sh_entsize);+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 SymName =3D GetSymName(= Sym);+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (SymName =3D=3D=20 > NULL) {+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 continue;+= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }++=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for (ExpIn= dex =3D 0; ExpIndex <=20 > (mExportSymNum -1); ExpIndex++) {+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 if (strcmp((CHAR8*)SymName,=20 > mExportSymName[ExpIndex]) !=3D 0) {+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 continue;+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }+ = =20 > mExportRVA[ExpIndex] =3D (UINT32)(Sym->st_value);+=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 mExportSize +=3D 2=20 > * EFI_IMAGE_EXPORT_ADDR_SIZE + EFI_IMAGE_EXPORT_ORDINAL_SIZE +=20 > strlen((CHAR8 *)SymName) + 1;+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }+=C2=A0=C2= =A0=C2=A0 }++=C2=A0=C2=A0=C2=A0 break;+ =20 > }+}++STATIC+VOID+WriteExport64 (+=C2=A0 VOID+=C2=A0 )+{+ =20 > EFI_IMAGE_OPTIONAL_HEADER_UNION=C2=A0=C2=A0=C2=A0=C2=A0 *NtHdr;+ =20 > EFI_IMAGE_EXPORT_DIRECTORY=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 *ExportDir;+ =20 > EFI_IMAGE_DATA_DIRECTORY *DataDir;+=C2=A0 UINT32 = =20 > FileNameOffset;+=C2=A0 UINT32=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 FuncOffset;+ =20 > UINT16=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0Index;+ =20 > UINT8=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *Tdata =3D NULL;++=C2=A0 ExportDir = =3D=20 > (EFI_IMAGE_EXPORT_DIRECTORY*)(mCoffFile + mExportOffset);+ =20 > ExportDir->Characteristics =3D 0;+=C2=A0 ExportDir->TimeDateStamp =3D 0;+= =20 > ExportDir->MajorVersion =3D 0;+=C2=A0 ExportDir->MinorVersion =3D0;+ =20 > ExportDir->Name =3D 0;+=C2=A0 ExportDir->NumberOfFunctions =3D mExportSym= Num;+ =20 > ExportDir->NumberOfNames =3D mExportSymNum;+ ExportDir->Base =3D=20 > EFI_IMAGE_EXPORT_ORDINAL_BASE;+=C2=A0 ExportDir->AddressOfFunctions =3D= =20 > mExportOffset + sizeof(EFI_IMAGE_EXPORT_DIRECTORY);+ =20 > ExportDir->AddressOfNames =3D ExportDir->AddressOfFunctions +=20 > EFI_IMAGE_EXPORT_ADDR_SIZE * mExportSymNum;+ =20 > ExportDir->AddressOfNameOrdinals =3D ExportDir->AddressOfNames +=20 > EFI_IMAGE_EXPORT_ADDR_SIZE * mExportSymNum;++=C2=A0 FileNameOffset =3D=20 > ExportDir->AddressOfNameOrdinals + EFI_IMAGE_EXPORT_ORDINAL_SIZE *=20 > mExportSymNum;+=C2=A0 FuncOffset =3D FileNameOffset + strlen(mInImageName= ) +=20 > 1;++=C2=A0 // Write Input image Name RVA+=C2=A0 Tdata =3D mCoffFile + 12;= +=C2=A0 *(UINT32=20 > *)Tdata =3D FileNameOffset;++=C2=A0 // Write Input image Name+=C2=A0 strc= py((char=20 > *)(mCoffFile + FileNameOffset), mInImageName);++=C2=A0 for (Index =3D 0; = Index=20 > < mExportSymNum; Index++) {+=C2=A0=C2=A0=C2=A0 //+=C2=A0=C2=A0=C2=A0 // W= rite Export Address Table+=20 > //+=C2=A0=C2=A0=C2=A0 Tdata =3D mCoffFile + ExportDir->AddressOfFunctions= + Index *=20 > EFI_IMAGE_EXPORT_ADDR_SIZE;+=C2=A0=C2=A0=C2=A0 *(UINT32 *)Tdata =3D=20 > mExportRVA[Index];++=C2=A0=C2=A0=C2=A0 //+=C2=A0=C2=A0=C2=A0 // Write Exp= ort Name Pointer Table+ =20 > //+=C2=A0=C2=A0=C2=A0 Tdata =3D mCoffFile + ExportDir->AddressOfNames + I= ndex *=20 > EFI_IMAGE_EXPORT_ADDR_SIZE;+ *(UINT32 *)Tdata =3D FuncOffset;++=C2=A0=C2= =A0=C2=A0 //+ =20 > // Write Export Ordinal table+=C2=A0=C2=A0=C2=A0 //+=C2=A0=C2=A0=C2=A0 Td= ata =3D mCoffFile +=20 > ExportDir->AddressOfNameOrdinals + Index *=20 > EFI_IMAGE_EXPORT_ORDINAL_SIZE;+=C2=A0=C2=A0=C2=A0 *(UINT16 *)Tdata =3D In= dex;++=C2=A0=C2=A0=C2=A0 //+ =20 > // Write Export Name Table+=C2=A0=C2=A0=C2=A0 //+ strcpy((char *)(mCoffFi= le +=20 > FuncOffset), mExportSymName[Index]);+=C2=A0=C2=A0=C2=A0 FuncOffset +=3D= =20 > strlen(mExportSymName[Index]) + 1;+=C2=A0 }++=C2=A0 NtHdr =3D=20 > (EFI_IMAGE_OPTIONAL_HEADER_UNION *)(mCoffFile + mNtHdrOffset);+=C2=A0 Dat= aDir=20 > =3D=20 > &NtHdr->Pe32Plus.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_E= XPORT];+=20 > DataDir->VirtualAddress =3D mExportOffset;+ =C2=A0DataDir->Size =3D=20 > mExportSize;++} diff --git a/BaseTools/Source/C/GenFw/ElfConvert.c=20 > b/BaseTools/Source/C/GenFw/ElfConvert.c >=20 > index 7db8721167..795cdbd743 100644 >=20 > --- a/BaseTools/Source/C/GenFw/ElfConvert.c >=20 > +++ b/BaseTools/Source/C/GenFw/ElfConvert.c >=20 > @@ -223,6 +223,16 @@ ConvertElf ( >=20 > =C2=A0=C2=A0 VerboseMsg ("Write debug info.");=C2=A0=C2=A0 ElfFunctions.= WriteDebug (); + =20 > //+=C2=A0 // For PRM Driver to Write export info.+=C2=A0 //+=C2=A0 if (mE= xportFlag)=20 > {+=C2=A0=C2=A0=C2=A0 VerboseMsg ("Scan symbol info.");+=C2=A0=C2=A0=C2=A0= ElfFunctions.ScanSymbol=20 > ();+=C2=A0=C2=A0=C2=A0 VerboseMsg ("Write export info.");+=C2=A0=C2=A0=C2= =A0 ElfFunctions.WriteExport=20 > ();+=C2=A0 }+=C2=A0=C2=A0 //=C2=A0=C2=A0 // Make sure image size is corre= ct before returning the=20 > new image.=C2=A0=C2=A0 //diff --git a/BaseTools/Source/C/GenFw/ElfConvert= .h=20 > b/BaseTools/Source/C/GenFw/ElfConvert.h >=20 > index 801e8de4a2..7920765fbb 100644 >=20 > --- a/BaseTools/Source/C/GenFw/ElfConvert.h >=20 > +++ b/BaseTools/Source/C/GenFw/ElfConvert.h >=20 > @@ -24,6 +24,7 @@ extern UINT8=C2=A0 *mCoffFile;=C2=A0 extern UINT32 mTab= leOffset;=20 > extern UINT32 mOutImageType; extern UINT32 mFileBufferSize;+extern=20 > BOOLEAN mExportFlag; =C2=A0// // Common EFI specific data.@@ -31,6 +32,42= @@=20 > extern UINT32 mFileBufferSize; >=20 > #define ELF_HII_SECTION_NAME ".hii" #define ELF_STRTAB_SECTION_NAME=20 > ".strtab" #define MAX_COFF_ALIGNMENT 0x10000+#define=20 > ELF_SYMBOL_SECTION_NAME ".symtab"++//+// Platform Runtime Mechanism=20 > (PRM) specific data.+//+#define PRM_MODULE_EXPORT_SYMBOL_NUM 10+#define= =20 > PRM_HANDLER_NAME_MAXIMUM_LENGTH 128++#define=20 > PRM_MODULE_EXPORT_DESCRIPTOR_NAME =20 > "PrmModuleExportDescriptor"+#define=20 > PRM_MODULE_EXPORT_DESCRIPTOR_SIGNATURE=C2=A0=C2=A0=C2=A0 SIGNATURE_64 ('P= ', 'R', 'M',=20 > '_', 'M', 'E', 'D', 'T')+#define PRM_MODULE_EXPORT_REVISION 0x0++//+//=20 > Platform Runtime Mechanism (PRM) Export Descriptor Structures+//+#pragma= =20 > pack(push, 1)++typedef struct {+=C2=A0 EFI_GUID = =20 > =C2=A0PrmHandlerGuid;+=C2=A0 CHAR8 =20 > PrmHandlerName[PRM_HANDLER_NAME_MAXIMUM_LENGTH];+}=20 > PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT;++typedef struct {+ =20 > UINT64=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Signature;+ =20 > UINT16=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Revision;+ =20 > UINT16=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 NumberPrmHandlers;+=C2=A0 EFI= _GUID=20 > PlatformGuid;+=C2=A0 EFI_GUID=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ModuleGuid;+}=20 > PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER;++typedef struct {+ =20 > PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER=C2=A0 Header;+ =20 > PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT =20 > PrmHandlerExportDescriptors[1];+}=20 > PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT;++#pragma pack(pop)=C2=A0 // // Filte= r=20 > Types@@ -38,7 +75,8 @@ extern UINT32 mFileBufferSize; >=20 > typedef enum { =C2=A0=C2=A0SECTION_TEXT,=C2=A0=C2=A0 SECTION_HII,-=C2=A0 = SECTION_DATA+ =20 > SECTION_DATA,+=C2=A0 SECTION_SYMBOL=C2=A0 } SECTION_FILTER_TYPES; @@ -50,= 6 +88,8=20 > @@ typedef struct { >=20 > =C2=A0=C2=A0 BOOLEAN (*WriteSections) (SECTION_FILTER_TYPES=C2=A0 Filter= Type); =20 > VOID=C2=A0=C2=A0=C2=A0 (*WriteRelocations) ();=C2=A0=C2=A0 VOID=C2=A0=C2= =A0=C2=A0 (*WriteDebug) ();+=C2=A0 VOID =20 > (*ScanSymbol) ();+=C2=A0 VOID=C2=A0=C2=A0=C2=A0 (*WriteExport) ();=C2=A0= =C2=A0 VOID=C2=A0=C2=A0=C2=A0 (*SetImageSize)=20 > ();=C2=A0=C2=A0 VOID=C2=A0=C2=A0=C2=A0 (*CleanUp) (); diff --git=20 > a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c >=20 > index 8cab70ba4d..c7de5b89d8 100644 >=20 > --- a/BaseTools/Source/C/GenFw/GenFw.c >=20 > +++ b/BaseTools/Source/C/GenFw/GenFw.c >=20 > @@ -87,7 +87,7 @@ UINT32 mImageTimeStamp =3D 0; >=20 > UINT32 mImageSize =3D 0; UINT32 mOutImageType =3D FW_DUMMY_IMAGE; BOOLEAN= =20 > mIsConvertXip =3D FALSE;-+BOOLEAN mExportFlag =3D FALSE;=C2=A0 STATIC=20 > EFI_STATUS@@ -1436,6 +1436,15 @@ Returns: >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 continue;=C2=A0=C2=A0=C2=A0=C2=A0 }= +=C2=A0=C2=A0=C2=A0 if (stricmp (argv[0], "--PRM") =3D=3D 0)=20 > {+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!mExportFlag) {+=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 mExportFlag =3D TRUE;+=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 }+ =20 > argc --;+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 argv ++;+=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 continue;+=C2=A0=C2=A0=C2=A0 }+=C2=A0=C2=A0=C2=A0=C2=A0 if (argv[0][= 0] =3D=3D=20 > '-') {=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Error (NULL, 0, 1000, "Unknown= option", argv[0]); =20 > goto Finish;diff --git=20 > a/BaseTools/Source/C/Include/IndustryStandard/PeImage.h=20 > b/BaseTools/Source/C/Include/IndustryStandard/PeImage.h >=20 > index f17b8ee19b..21c968e650 100644 >=20 > --- a/BaseTools/Source/C/Include/IndustryStandard/PeImage.h >=20 > +++ b/BaseTools/Source/C/Include/IndustryStandard/PeImage.h >=20 > @@ -571,6 +571,13 @@ typedef struct { >=20 > =C2=A0=C2=A0 UINT32=C2=A0 AddressOfNameOrdinals; } EFI_IMAGE_EXPORT_DIRE= CTORY; +//+//=20 > Based export types.+//+#define EFI_IMAGE_EXPORT_ORDINAL_BASE =20 > 1+#define EFI_IMAGE_EXPORT_ADDR_SIZE=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 4+#define=20 > EFI_IMAGE_EXPORT_ORDINAL_SIZE=C2=A0=C2=A0=C2=A0=C2=A0 2+ /// /// DLL supp= ort. /// Import=20 > Format-- >=20 > 2.26.2.windows.1 >=20 >=20