BaseTools/GenFw: Enhance GenFw to support PRM GCC build

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3802

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.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Lixia Huang <lisa.huang@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
Huang, Li-Xia
2022-03-14 13:27:21 +08:00
committed by mergify[bot]
parent c8ea48bdf9
commit 414cd2a4d5
5 changed files with 315 additions and 5 deletions

View File

@@ -87,7 +87,7 @@ UINT32 mImageTimeStamp = 0;
UINT32 mImageSize = 0;
UINT32 mOutImageType = FW_DUMMY_IMAGE;
BOOLEAN mIsConvertXip = FALSE;
BOOLEAN mExportFlag = FALSE;
STATIC
EFI_STATUS
@@ -279,6 +279,10 @@ Returns:
except for -o or -r option. It is a action option.\n\
If it is combined with other action options, the later\n\
input action option will override the previous one.\n");
fprintf (stdout, " --prm Scan symbol section from ELF image and \n\
write export table into PE-COFF.\n\
This option can be used together with -e.\n\
It doesn't work for other options.\n");
fprintf (stdout, " -v, --verbose Turn on verbose output with informational messages.\n");
fprintf (stdout, " -q, --quiet Disable all messages except key message and fatal error\n");
fprintf (stdout, " -d, --debug level Enable debug messages, at input debug level.\n");
@@ -1436,6 +1440,20 @@ Returns:
continue;
}
if (stricmp (argv[0], "--prm") == 0) {
if (stricmp (ModuleType, "DXE_RUNTIME_DRIVER") != 0 ){
Error (NULL, 0, 1001, "Invalid", "--prm option only supports DXE RUNTIME driver.");
goto Finish;
}
if (!mExportFlag) {
mExportFlag = TRUE;
}
argc --;
argv ++;
continue;
}
if (argv[0][0] == '-') {
Error (NULL, 0, 1000, "Unknown option", argv[0]);
goto Finish;