From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web10.630.1572589657815351337 for ; Thu, 31 Oct 2019 23:27:37 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: zhiguang.liu@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Oct 2019 23:27:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,254,1569308400"; d="scan'208";a="231134010" Received: from fieedk002.ccr.corp.intel.com ([10.239.158.170]) by fmsmga002.fm.intel.com with ESMTP; 31 Oct 2019 23:27:36 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao Subject: [PATCH 2/2] BaseTools: Add support for parseing map files generated by CLANG9 in GenFv Date: Fri, 1 Nov 2019 14:27:02 +0800 Message-Id: <20191101062702.165544-2-zhiguang.liu@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20191101062702.165544-1-zhiguang.liu@intel.com> References: <20191101062702.165544-1-zhiguang.liu@intel.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2320 Add support for parseing map files generated by CLANG9 in GenFv Cc: Bob Feng Cc: Liming Gao Signed-off-by: Zhiguang Liu --- BaseTools/Source/C/GenFv/GenFvInternalLib.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c index 908740de50..daebfe894c 100644 --- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c +++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c @@ -791,6 +791,7 @@ Returns: FILE *PeMapFile; CHAR8 Line [MAX_LINE_LEN]; CHAR8 KeyWord [MAX_LINE_LEN]; + CHAR8 KeyWord2 [MAX_LINE_LEN]; CHAR8 FunctionName [MAX_LINE_LEN]; EFI_PHYSICAL_ADDRESS FunctionAddress; UINT32 FunctionType; @@ -805,6 +806,7 @@ Returns: UINT32 TextVirtualAddress; UINT32 DataVirtualAddress; EFI_PHYSICAL_ADDRESS LinkTimeBaseAddress; + BOOLEAN IsUseClang; // // Init local variable @@ -932,6 +934,7 @@ Returns: // Output Functions information into Fv Map file // LinkTimeBaseAddress = 0; + IsUseClang = FALSE; while (fgets (Line, MAX_LINE_LEN, PeMapFile) != NULL) { // // Skip blank line @@ -946,6 +949,12 @@ Returns: if (FunctionType == 0) { sscanf (Line, "%s", KeyWord); if (stricmp (KeyWord, "Address") == 0) { + sscanf (Line, "%s %s", KeyWord, KeyWord2); + if (stricmp (KeyWord2, "Size") == 0) { + IsUseClang = TRUE; + FunctionType = 1; + continue; + } // // function list // @@ -967,11 +976,20 @@ Returns: // Printf Function Information // if (FunctionType == 1) { - sscanf (Line, "%s %s %llx %s", KeyWord, FunctionName, &TempLongAddress, FunctionTypeName); - FunctionAddress = (UINT64) TempLongAddress; - if (FunctionTypeName [1] == '\0' && (FunctionTypeName [0] == 'f' || FunctionTypeName [0] == 'F')) { - fprintf (FvMapFile, " 0x%010llx ", (unsigned long long) (ImageBaseAddress + FunctionAddress - LinkTimeBaseAddress)); - fprintf (FvMapFile, "%s\n", FunctionName); + if (IsUseClang) { + sscanf (Line, "%llx %s %s %s", &TempLongAddress, KeyWord, KeyWord2, FunctionTypeName); + FunctionAddress = (UINT64) TempLongAddress; + if (FunctionTypeName [0] == '_' ) { + fprintf (FvMapFile, " 0x%010llx ", (unsigned long long) (ImageBaseAddress + FunctionAddress - LinkTimeBaseAddress)); + fprintf (FvMapFile, "%s\n", FunctionTypeName); + } + } else { + sscanf (Line, "%s %s %llx %s", KeyWord, FunctionName, &TempLongAddress, FunctionTypeName); + FunctionAddress = (UINT64) TempLongAddress; + if (FunctionTypeName [1] == '\0' && (FunctionTypeName [0] == 'f' || FunctionTypeName [0] == 'F')) { + fprintf (FvMapFile, " 0x%010llx ", (unsigned long long) (ImageBaseAddress + FunctionAddress - LinkTimeBaseAddress)); + fprintf (FvMapFile, "%s\n", FunctionName); + } } } else if (FunctionType == 2) { sscanf (Line, "%s %s %llx %s", KeyWord, FunctionName, &TempLongAddress, FunctionTypeName); -- 2.16.2.windows.1