From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web10.15139.1646010871669768469 for ; Sun, 27 Feb 2022 17:14:32 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=epw/KLtR; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: lisa.huang@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646010871; x=1677546871; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=27V9k+x5T5iQS42IqVt+Rb5iRxeivaahUDZ8PgcRVxM=; b=epw/KLtRmpLL20/0kprzYroac9A5KmEhx27JKuiY3Skm4YOZLaWArdW2 E/Ob8TwymqmK2lidZxPLRXTNLaAVFY4lW4Td4oe5sNBikJos064EsW9Pm 9LOYDw7NE184+jzKCeuS3hA3Tf9h9oYVLQSbCWDbKetMayqkauds8UtnT NQyXyapH3JbVFI/ecUBBFeiEXz6aeqs3nZ/oX9Hir+sKNxaM16FUjYZ1c 4mAQ3WON+IWS9TYGS8/5diLuSNc9Wx+LxB9CAwJPj3+/aLqjDUn2BHwKU ceCh60/ld0IPcyaSF+MIRrRVYhjGVBns4NfgiXpkuohhyUmpRv/hshgap Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10271"; a="339213493" X-IronPort-AV: E=Sophos;i="5.90,142,1643702400"; d="scan'208";a="339213493" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2022 17:14:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,142,1643702400"; d="scan'208";a="575153404" Received: from lixiahua-desk2.ccr.corp.intel.com ([10.239.158.25]) by orsmga001.jf.intel.com with ESMTP; 27 Feb 2022 17:14:16 -0800 From: "Huang, Li-Xia" To: devel@edk2.groups.io Cc: Lixia Huang , Liming Gao , Bob Feng , Yuwei Chen Subject: [edk2-devel] [PATCH v2] BaseTools/GenFw: Enhance GenFw to support PRM GCC build Date: Mon, 28 Feb 2022 09:14:11 +0800 Message-Id: <20220228011411.3450-1-lisa.huang@intel.com> X-Mailer: git-send-email 2.26.2.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Since PRM module needs to support export table in PE-COFF, we'll enhance GenFw tool to support this. Add one export flag in GenFw tool. If export flag is set: Step1: Scan ELF symbol table based on PRM module descriptor to get descriptor offset address; Step2: Find PRM handlers number and name in COFF file based on the address from step1; Step3: Write PRM info such as handler name and export RVA into COFF export table. PRM option currently only supports DXE RUNTIME driver and X64 arch. Change-Id: I479b7c8b23beea12b5c567677688aef6f7af2085 Cc: Liming Gao Cc: Bob Feng Cc: Yuwei Chen Signed-off-by: Lixia Huang --- BaseTools/Source/C/GenFw/Elf64Convert.c | 242 +++++++++++++++++- BaseTools/Source/C/GenFw/ElfConvert.c | 8 + BaseTools/Source/C/GenFw/ElfConvert.h | 43 +++- BaseTools/Source/C/GenFw/GenFw.c | 20 +- .../C/Include/IndustryStandard/PeImage.h | 7 + 5 files changed, 315 insertions(+), 5 deletions(-) diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/G= enFw/Elf64Convert.c index 0bb3ead228..2aa9bfcc94 100644 --- a/BaseTools/Source/C/GenFw/Elf64Convert.c +++ b/BaseTools/Source/C/GenFw/Elf64Convert.c @@ -56,6 +56,12 @@ WriteDebug64 ( VOID=0D );=0D =0D +STATIC=0D +VOID=0D +WriteExport64 (=0D + VOID=0D + );=0D +=0D STATIC=0D VOID=0D SetImageSize64 (=0D @@ -106,7 +112,7 @@ STATIC UINT32 mCoffAlignment =3D 0x20; //=0D // PE section alignment.=0D //=0D -STATIC const UINT16 mCoffNbrSections =3D 4;=0D +STATIC UINT16 mCoffNbrSections =3D 4;=0D =0D //=0D // ELF sections to offset in Coff file.=0D @@ -122,7 +128,7 @@ STATIC UINT32 mDataOffset; STATIC UINT32 mHiiRsrcOffset;=0D STATIC UINT32 mRelocOffset;=0D STATIC UINT32 mDebugOffset;=0D -=0D +STATIC UINT32 mExportOffset;=0D //=0D // Used for RISC-V relocations.=0D //=0D @@ -132,6 +138,14 @@ STATIC Elf64_Half mRiscVPass1SymSecIndex =3D 0; STATIC INT32 mRiscVPass1Offset;=0D STATIC INT32 mRiscVPass1GotFixup;=0D =0D +//=0D +// Used for Export section.=0D +//=0D +STATIC UINT32 mExportSize;=0D +STATIC UINT32 mExportRVA[PRM_MODULE_EXPORT_SYMBOL_NUM];=0D +STATIC UINT32 mExportSymNum;=0D +STATIC CHAR8 mExportSymName[PRM_MODULE_EXPORT_SYMBOL_NUM][PRM_HANDLE= R_NAME_MAXIMUM_LENGTH];=0D +=0D //=0D // Initialization Function=0D //=0D @@ -171,6 +185,13 @@ InitializeElf64 ( return FALSE;=0D }=0D =0D + if (mExportFlag) {=0D + if (mEhdr->e_machine !=3D EM_X86_64) {=0D + Error (NULL, 0, 3000, "Unsupported", "--prm option currently only su= pports X64 arch.");=0D + return FALSE;=0D + }=0D + }=0D +=0D //=0D // Update section header pointers=0D //=0D @@ -200,6 +221,11 @@ InitializeElf64 ( ElfFunctions->SetImageSize =3D SetImageSize64;=0D ElfFunctions->CleanUp =3D CleanUp64;=0D =0D + if (mExportFlag) {=0D + mCoffNbrSections ++;=0D + ElfFunctions->WriteExport =3D WriteExport64;=0D + }=0D +=0D return TRUE;=0D }=0D =0D @@ -263,6 +289,17 @@ IsHiiRsrcShdr ( return (BOOLEAN) (strcmp((CHAR8*)mEhdr + Namedr->sh_offset + Shdr->sh_na= me, ELF_HII_SECTION_NAME) =3D=3D 0);=0D }=0D =0D +STATIC=0D +BOOLEAN=0D +IsSymbolShdr (=0D + Elf_Shdr *Shdr=0D + )=0D +{=0D + Elf_Shdr *Namehdr =3D GetShdrByIndex(mEhdr->e_shstrndx);=0D +=0D + return (BOOLEAN) (strcmp((CHAR8*)mEhdr + Namehdr->sh_offset + Shdr->sh_n= ame, ELF_SYMBOL_SECTION_NAME) =3D=3D 0);=0D +}=0D +=0D STATIC=0D BOOLEAN=0D IsDataShdr (=0D @@ -335,6 +372,37 @@ GetSymName ( return StrtabContents + Sym->st_name;=0D }=0D =0D +//=0D +// Get Prm Handler number and name=0D +//=0D +STATIC=0D +VOID=0D +FindPrmHandler (=0D + UINT64 Offset=0D + )=0D +{=0D + PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER *PrmExport;=0D + PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT *PrmHandler;=0D + UINT32 HandlerNum;=0D +=0D + PrmExport =3D (PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER*)((UINT8*)mEhd= r + Offset);=0D + PrmHandler =3D (PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT *)(PrmExport + 1);= =0D +=0D + for (HandlerNum =3D 0; HandlerNum < PrmExport->NumberPrmHandlers; Handle= rNum++) {=0D + strcpy(mExportSymName[mExportSymNum], PrmHandler->PrmHandlerName);=0D + mExportSymNum ++;=0D + PrmHandler +=3D 1;=0D +=0D + //=0D + // Check if PRM handler number is larger than (PRM_MODULE_EXPORT_SYMBO= L_NUM - 1)=0D + //=0D + if (mExportSymNum >=3D (PRM_MODULE_EXPORT_SYMBOL_NUM - 1)) {=0D + Error (NULL, 0, 3000, "Invalid", "FindPrmHandler: Number %u is too h= igh.", mExportSymNum);=0D + exit(EXIT_FAILURE);=0D + }=0D + }=0D +}=0D +=0D //=0D // Find the ELF section hosting the GOT from an ELF Rva=0D // of a single GOT entry. Normally, GOT is placed in=0D @@ -717,6 +785,7 @@ ScanSections64 ( UINT32 CoffEntry;=0D UINT32 SectionCount;=0D BOOLEAN FoundSection;=0D + UINT32 Offset;=0D =0D CoffEntry =3D 0;=0D mCoffOffset =3D 0;=0D @@ -880,6 +949,82 @@ ScanSections64 ( Warning (NULL, 0, 0, NULL, "Multiple sections in %s are merged into 1 = data section. Source level debug might not work correctly.", mInImageName);= =0D }=0D =0D + //=0D + // The Symbol sections.=0D + //=0D + if (mExportFlag) {=0D + UINT32 SymIndex;=0D + Elf_Sym *Sym;=0D + UINT64 SymNum;=0D + const UINT8 *SymName;=0D +=0D + mExportOffset =3D mCoffOffset;=0D + mExportSize =3D sizeof(EFI_IMAGE_EXPORT_DIRECTORY) + strlen(mInImageNa= me) + 1;=0D +=0D + for (i =3D 0; i < mEhdr->e_shnum; i++) {=0D +=0D + //=0D + // Determine if this is a symbol section.=0D + //=0D + Elf_Shdr *shdr =3D GetShdrByIndex(i);=0D + if (!IsSymbolShdr(shdr)) {=0D + continue;=0D + }=0D +=0D + UINT8 *Symtab =3D (UINT8*)mEhdr + shdr->sh_offset;=0D + SymNum =3D (shdr->sh_size) / (shdr->sh_entsize);=0D +=0D + //=0D + // First Get PrmModuleExportDescriptor=0D + //=0D + for (SymIndex =3D 0; SymIndex < SymNum; SymIndex++) {=0D + Sym =3D (Elf_Sym *)(Symtab + SymIndex * shdr->sh_entsize);=0D + SymName =3D GetSymName(Sym);=0D + if (SymName =3D=3D NULL) {=0D + continue;=0D + }=0D +=0D + if (strcmp((CHAR8*)SymName, PRM_MODULE_EXPORT_DESCRIPTOR_NAME) =3D= =3D 0) {=0D + //=0D + // Find PrmHandler Number and Name=0D + //=0D + FindPrmHandler(Sym->st_value);=0D +=0D + strcpy(mExportSymName[mExportSymNum], (CHAR8*)SymName);=0D + mExportRVA[mExportSymNum] =3D (UINT32)(Sym->st_value);=0D + mExportSize +=3D 2 * EFI_IMAGE_EXPORT_ADDR_SIZE + EFI_IMAGE_EXPO= RT_ORDINAL_SIZE + strlen((CHAR8 *)SymName) + 1;=0D + mExportSymNum ++;=0D + break;=0D + }=0D + }=0D +=0D + //=0D + // Second Get PrmHandler=0D + //=0D + for (SymIndex =3D 0; SymIndex < SymNum; SymIndex++) {=0D + UINT32 ExpIndex;=0D + Sym =3D (Elf_Sym *)(Symtab + SymIndex * shdr->sh_entsize);=0D + SymName =3D GetSymName(Sym);=0D + if (SymName =3D=3D NULL) {=0D + continue;=0D + }=0D +=0D + for (ExpIndex =3D 0; ExpIndex < (mExportSymNum -1); ExpIndex++) {= =0D + if (strcmp((CHAR8*)SymName, mExportSymName[ExpIndex]) !=3D 0) {= =0D + continue;=0D + }=0D + mExportRVA[ExpIndex] =3D (UINT32)(Sym->st_value);=0D + mExportSize +=3D 2 * EFI_IMAGE_EXPORT_ADDR_SIZE + EFI_IMAGE_EXPO= RT_ORDINAL_SIZE + strlen((CHAR8 *)SymName) + 1;=0D + }=0D + }=0D +=0D + break;=0D + }=0D +=0D + mCoffOffset +=3D mExportSize;=0D + mCoffOffset =3D CoffAlign(mCoffOffset);=0D + }=0D +=0D //=0D // The HII resource sections.=0D //=0D @@ -989,8 +1134,17 @@ ScanSections64 ( NtHdr->Pe32Plus.FileHeader.NumberOfSections--;=0D }=0D =0D + //=0D + // If found symbol, add edata section between data and rsrc section=0D + //=0D + if(mExportFlag) {=0D + Offset =3D mExportOffset;=0D + } else {=0D + Offset =3D mHiiRsrcOffset;=0D + }=0D +=0D if ((mHiiRsrcOffset - mDataOffset) > 0) {=0D - CreateSectionHeader (".data", mDataOffset, mHiiRsrcOffset - mDataOffse= t,=0D + CreateSectionHeader (".data", mDataOffset, Offset - mDataOffset,=0D EFI_IMAGE_SCN_CNT_INITIALIZED_DATA=0D | EFI_IMAGE_SCN_MEM_WRITE=0D | EFI_IMAGE_SCN_MEM_READ);=0D @@ -999,6 +1153,20 @@ ScanSections64 ( NtHdr->Pe32Plus.FileHeader.NumberOfSections--;=0D }=0D =0D + if(mExportFlag) {=0D + if ((mHiiRsrcOffset - mExportOffset) > 0) {=0D + CreateSectionHeader (".edata", mExportOffset, mHiiRsrcOffset - mExpo= rtOffset,=0D + EFI_IMAGE_SCN_CNT_INITIALIZED_DATA=0D + | EFI_IMAGE_SCN_MEM_READ);=0D + NtHdr->Pe32Plus.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENT= RY_EXPORT].Size =3D mHiiRsrcOffset - mExportOffset;=0D + NtHdr->Pe32Plus.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENT= RY_EXPORT].VirtualAddress =3D mExportOffset;=0D +=0D + } else {=0D + // Don't make a section of size 0.=0D + NtHdr->Pe32Plus.FileHeader.NumberOfSections--;=0D + }=0D + }=0D +=0D if ((mRelocOffset - mHiiRsrcOffset) > 0) {=0D CreateSectionHeader (".rsrc", mHiiRsrcOffset, mRelocOffset - mHiiRsrcO= ffset,=0D EFI_IMAGE_SCN_CNT_INITIALIZED_DATA=0D @@ -1757,4 +1925,72 @@ CleanUp64 ( }=0D }=0D =0D +STATIC=0D +VOID=0D +WriteExport64 (=0D + VOID=0D + )=0D +{=0D + EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr;=0D + EFI_IMAGE_EXPORT_DIRECTORY *ExportDir;=0D + EFI_IMAGE_DATA_DIRECTORY *DataDir;=0D + UINT32 FileNameOffset;=0D + UINT32 NameOffset;=0D + UINT16 Index;=0D + UINT8 *Tdata =3D NULL;=0D +=0D + ExportDir =3D (EFI_IMAGE_EXPORT_DIRECTORY*)(mCoffFile + mExportOffset);= =0D + ExportDir->Characteristics =3D 0;=0D + ExportDir->TimeDateStamp =3D 0;=0D + ExportDir->MajorVersion =3D 0;=0D + ExportDir->MinorVersion =3D0;=0D + ExportDir->Name =3D 0;=0D + ExportDir->NumberOfFunctions =3D mExportSymNum;=0D + ExportDir->NumberOfNames =3D mExportSymNum;=0D + ExportDir->Base =3D EFI_IMAGE_EXPORT_ORDINAL_BASE;=0D + ExportDir->AddressOfFunctions =3D mExportOffset + sizeof(EFI_IMAGE_EXPOR= T_DIRECTORY);=0D + ExportDir->AddressOfNames =3D ExportDir->AddressOfFunctions + EFI_IMAGE_= EXPORT_ADDR_SIZE * mExportSymNum;=0D + ExportDir->AddressOfNameOrdinals =3D ExportDir->AddressOfNames + EFI_IMA= GE_EXPORT_ADDR_SIZE * mExportSymNum;=0D +=0D + FileNameOffset =3D ExportDir->AddressOfNameOrdinals + EFI_IMAGE_EXPORT_O= RDINAL_SIZE * mExportSymNum;=0D + NameOffset =3D FileNameOffset + strlen(mInImageName) + 1;=0D +=0D + // Write Input image Name RVA=0D + ExportDir->Name =3D FileNameOffset;=0D +=0D + // Write Input image Name=0D + strcpy((char *)(mCoffFile + FileNameOffset), mInImageName);=0D +=0D + for (Index =3D 0; Index < mExportSymNum; Index++) {=0D + //=0D + // Write Export Address Table=0D + //=0D + Tdata =3D mCoffFile + ExportDir->AddressOfFunctions + Index * EFI_IMAG= E_EXPORT_ADDR_SIZE;=0D + *(UINT32 *)Tdata =3D mExportRVA[Index];=0D +=0D + //=0D + // Write Export Name Pointer Table=0D + //=0D + Tdata =3D mCoffFile + ExportDir->AddressOfNames + Index * EFI_IMAGE_EX= PORT_ADDR_SIZE;=0D + *(UINT32 *)Tdata =3D NameOffset;=0D +=0D + //=0D + // Write Export Ordinal table=0D + //=0D + Tdata =3D mCoffFile + ExportDir->AddressOfNameOrdinals + Index * EFI_I= MAGE_EXPORT_ORDINAL_SIZE;=0D + *(UINT16 *)Tdata =3D Index;=0D +=0D + //=0D + // Write Export Name Table=0D + //=0D + strcpy((char *)(mCoffFile + NameOffset), mExportSymName[Index]);=0D + NameOffset +=3D strlen(mExportSymName[Index]) + 1;=0D + }=0D +=0D + NtHdr =3D (EFI_IMAGE_OPTIONAL_HEADER_UNION *)(mCoffFile + mNtHdrOffset);= =0D + DataDir =3D &NtHdr->Pe32Plus.OptionalHeader.DataDirectory[EFI_IMAGE_DIRE= CTORY_ENTRY_EXPORT];=0D + DataDir->VirtualAddress =3D mExportOffset;=0D + DataDir->Size =3D mExportSize;=0D +=0D +}=0D =0D diff --git a/BaseTools/Source/C/GenFw/ElfConvert.c b/BaseTools/Source/C/Gen= Fw/ElfConvert.c index 7db8721167..be98544056 100644 --- a/BaseTools/Source/C/GenFw/ElfConvert.c +++ b/BaseTools/Source/C/GenFw/ElfConvert.c @@ -223,6 +223,14 @@ ConvertElf ( VerboseMsg ("Write debug info.");=0D ElfFunctions.WriteDebug ();=0D =0D + //=0D + // For PRM Driver to Write export info.=0D + //=0D + if (mExportFlag) {=0D + VerboseMsg ("Write export info.");=0D + ElfFunctions.WriteExport ();=0D + }=0D +=0D //=0D // Make sure image size is correct before returning the new image.=0D //=0D diff --git a/BaseTools/Source/C/GenFw/ElfConvert.h b/BaseTools/Source/C/Gen= Fw/ElfConvert.h index 801e8de4a2..6ab4605227 100644 --- a/BaseTools/Source/C/GenFw/ElfConvert.h +++ b/BaseTools/Source/C/GenFw/ElfConvert.h @@ -24,6 +24,7 @@ extern UINT8 *mCoffFile; extern UINT32 mTableOffset;=0D extern UINT32 mOutImageType;=0D extern UINT32 mFileBufferSize;=0D +extern BOOLEAN mExportFlag;=0D =0D //=0D // Common EFI specific data.=0D @@ -31,6 +32,44 @@ extern UINT32 mFileBufferSize; #define ELF_HII_SECTION_NAME ".hii"=0D #define ELF_STRTAB_SECTION_NAME ".strtab"=0D #define MAX_COFF_ALIGNMENT 0x10000=0D +#define ELF_SYMBOL_SECTION_NAME ".symtab"=0D +=0D +//=0D +// Platform Runtime Mechanism (PRM) specific data.=0D +//=0D +#define PRM_MODULE_EXPORT_SYMBOL_NUM 256=0D +=0D +// to include PRM header directly once PrmPkg is in main repo=0D +#define PRM_HANDLER_NAME_MAXIMUM_LENGTH 128=0D +=0D +#define PRM_MODULE_EXPORT_DESCRIPTOR_NAME "PrmModuleExportDescript= or"=0D +#define PRM_MODULE_EXPORT_DESCRIPTOR_SIGNATURE SIGNATURE_64 ('P', 'R', = 'M', '_', 'M', 'E', 'D', 'T')=0D +#define PRM_MODULE_EXPORT_REVISION 0x0=0D +=0D +//=0D +// Platform Runtime Mechanism (PRM) Export Descriptor Structures=0D +//=0D +#pragma pack(push, 1)=0D +=0D +typedef struct {=0D + EFI_GUID PrmHandlerGuid;=0D + CHAR8 PrmHandlerName[PRM_HANDLER_NAME_MA= XIMUM_LENGTH];=0D +} PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT;=0D +=0D +typedef struct {=0D + UINT64 Signature;=0D + UINT16 Revision;=0D + UINT16 NumberPrmHandlers;=0D + EFI_GUID PlatformGuid;=0D + EFI_GUID ModuleGuid;=0D +} PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER;=0D +=0D +typedef struct {=0D + PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER Header;=0D + PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT PrmHandlerExportDescriptors[= 1];=0D +} PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT;=0D +=0D +#pragma pack(pop)=0D =0D //=0D // Filter Types=0D @@ -38,7 +77,8 @@ extern UINT32 mFileBufferSize; typedef enum {=0D SECTION_TEXT,=0D SECTION_HII,=0D - SECTION_DATA=0D + SECTION_DATA,=0D + SECTION_SYMBOL=0D =0D } SECTION_FILTER_TYPES;=0D =0D @@ -50,6 +90,7 @@ typedef struct { BOOLEAN (*WriteSections) (SECTION_FILTER_TYPES FilterType);=0D VOID (*WriteRelocations) ();=0D VOID (*WriteDebug) ();=0D + VOID (*WriteExport) ();=0D VOID (*SetImageSize) ();=0D VOID (*CleanUp) ();=0D =0D diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/Ge= nFw.c index 8cab70ba4d..6f61f16788 100644 --- a/BaseTools/Source/C/GenFw/GenFw.c +++ b/BaseTools/Source/C/GenFw/GenFw.c @@ -87,7 +87,7 @@ UINT32 mImageTimeStamp =3D 0; UINT32 mImageSize =3D 0;=0D UINT32 mOutImageType =3D FW_DUMMY_IMAGE;=0D BOOLEAN mIsConvertXip =3D FALSE;=0D -=0D +BOOLEAN mExportFlag =3D FALSE;=0D =0D STATIC=0D EFI_STATUS=0D @@ -279,6 +279,10 @@ Returns: except for -o or -r option. It is a action option.= \n\=0D If it is combined with other action options, the l= ater\n\=0D input action option will override the previous one= .\n");=0D + fprintf (stdout, " --prm Scan symbol section from ELF i= mage and \n\=0D + write export table into PE-COFF.\n\=0D + This option can be used together with -e.\n\=0D + It doesn't work for other options.\n");=0D fprintf (stdout, " -v, --verbose Turn on verbose output with in= formational messages.\n");=0D fprintf (stdout, " -q, --quiet Disable all messages except ke= y message and fatal error\n");=0D fprintf (stdout, " -d, --debug level Enable debug messages, at inpu= t debug level.\n");=0D @@ -1436,6 +1440,20 @@ Returns: continue;=0D }=0D =0D + if (stricmp (argv[0], "--prm") =3D=3D 0) {=0D + if (stricmp (ModuleType, "DXE_RUNTIME_DRIVER") !=3D 0 ){=0D + Error (NULL, 0, 1001, "Invalid", "--prm option only supports DXE R= UNTIME driver.");=0D + goto Finish;=0D + }=0D +=0D + if (!mExportFlag) {=0D + mExportFlag =3D TRUE;=0D + }=0D + argc --;=0D + argv ++;=0D + continue;=0D + }=0D +=0D if (argv[0][0] =3D=3D '-') {=0D Error (NULL, 0, 1000, "Unknown option", argv[0]);=0D goto Finish;=0D diff --git a/BaseTools/Source/C/Include/IndustryStandard/PeImage.h b/BaseTo= ols/Source/C/Include/IndustryStandard/PeImage.h index f17b8ee19b..21c968e650 100644 --- a/BaseTools/Source/C/Include/IndustryStandard/PeImage.h +++ b/BaseTools/Source/C/Include/IndustryStandard/PeImage.h @@ -571,6 +571,13 @@ typedef struct { UINT32 AddressOfNameOrdinals;=0D } EFI_IMAGE_EXPORT_DIRECTORY;=0D =0D +//=0D +// Based export types.=0D +//=0D +#define EFI_IMAGE_EXPORT_ORDINAL_BASE 1=0D +#define EFI_IMAGE_EXPORT_ADDR_SIZE 4=0D +#define EFI_IMAGE_EXPORT_ORDINAL_SIZE 2=0D +=0D ///=0D /// DLL support.=0D /// Import Format=0D --=20 2.26.2.windows.1