Reviewed-by: Liming Gao <liming....@intel.com>

>-----Original Message-----
>From: Liu, Zhiguang
>Sent: Friday, November 01, 2019 2:27 PM
>To: devel@edk2.groups.io
>Cc: Feng, Bob C <bob.c.f...@intel.com>; Gao, Liming <liming....@intel.com>
>Subject: [PATCH 2/2] BaseTools: Add support for parseing map files generated
>by CLANG9 in GenFv
>
>REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2320
>
>Add support for parseing map files generated by CLANG9 in GenFv
>
>Cc: Bob Feng <bob.c.f...@intel.com>
>Cc: Liming Gao <liming....@intel.com>
>
>Signed-off-by: Zhiguang Liu <zhiguang....@intel.com>
>---
> 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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49900): https://edk2.groups.io/g/devel/message/49900
Mute This Topic: https://groups.io/mt/40403853/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to