* [PATCH 1/2] BaseTools: Add map file parsing support for CLANG9 @ 2019-11-01 6:27 Zhiguang Liu 2019-11-01 6:27 ` [PATCH 2/2] BaseTools: Add support for parseing map files generated by CLANG9 in GenFv Zhiguang Liu 2019-11-04 3:28 ` [PATCH 1/2] BaseTools: Add map file parsing support for CLANG9 Liming Gao 0 siblings, 2 replies; 4+ messages in thread From: Zhiguang Liu @ 2019-11-01 6:27 UTC (permalink / raw) To: devel; +Cc: Bob Feng, Liming Gao Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com> --- BaseTools/Source/Python/Common/Misc.py | 9 ++++++--- BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 714eb840ea..403715e6cc 100755 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -81,19 +81,22 @@ def GetVariableOffset(mapfilepath, efifilepath, varnames): if len(lines) == 0: return None firstline = lines[0].strip() + if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', firstline): + return _parseForXcodeAndClang9(lines, efifilepath, varnames) if (firstline.startswith("Archive member included ") and firstline.endswith(" file (symbol)")): return _parseForGCC(lines, efifilepath, varnames) if firstline.startswith("# Path:"): - return _parseForXcode(lines, efifilepath, varnames) + return _parseForXcodeAndClang9(lines, efifilepath, varnames) return _parseGeneral(lines, efifilepath, varnames) -def _parseForXcode(lines, efifilepath, varnames): +def _parseForXcodeAndClang9(lines, efifilepath, varnames): status = 0 ret = [] for line in lines: line = line.strip() - if status == 0 and line == "# Symbols:": + if status == 0 and (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \ + or line == "# Symbols:"): status = 1 continue if status == 1 and len(line) != 0: diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py index 7d5e4fc34a..d962ab0add 100644 --- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py +++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py @@ -49,20 +49,23 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath): if len(lines) == 0: return None firstline = lines[0].strip() + if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', firstline): + return _parseForXcodeAndClang9(lines, efifilepath) if (firstline.startswith("Archive member included ") and firstline.endswith(" file (symbol)")): return _parseForGCC(lines, efifilepath) if firstline.startswith("# Path:"): - return _parseForXcode(lines, efifilepath) + return _parseForXcodeAndClang9(lines, efifilepath) return _parseGeneral(lines, efifilepath) -def _parseForXcode(lines, efifilepath): +def _parseForXcodeAndClang9(lines, efifilepath): valuePattern = re.compile('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))') status = 0 pcds = [] for line in lines: line = line.strip() - if status == 0 and line == "# Symbols:": + if status == 0 and (re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \ + or line == "# Symbols:"): status = 1 continue if status == 1 and len(line) != 0: -- 2.16.2.windows.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] BaseTools: Add support for parseing map files generated by CLANG9 in GenFv 2019-11-01 6:27 [PATCH 1/2] BaseTools: Add map file parsing support for CLANG9 Zhiguang Liu @ 2019-11-01 6:27 ` Zhiguang Liu 2019-11-04 3:28 ` Liming Gao 2019-11-04 3:28 ` [PATCH 1/2] BaseTools: Add map file parsing support for CLANG9 Liming Gao 1 sibling, 1 reply; 4+ messages in thread From: Zhiguang Liu @ 2019-11-01 6:27 UTC (permalink / raw) To: devel; +Cc: Bob Feng, Liming Gao 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.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Zhiguang Liu <zhiguang.liu@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 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] BaseTools: Add support for parseing map files generated by CLANG9 in GenFv 2019-11-01 6:27 ` [PATCH 2/2] BaseTools: Add support for parseing map files generated by CLANG9 in GenFv Zhiguang Liu @ 2019-11-04 3:28 ` Liming Gao 0 siblings, 0 replies; 4+ messages in thread From: Liming Gao @ 2019-11-04 3:28 UTC (permalink / raw) To: Liu, Zhiguang, devel@edk2.groups.io; +Cc: Feng, Bob C Reviewed-by: Liming Gao <liming.gao@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.feng@intel.com>; Gao, Liming <liming.gao@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.feng@intel.com> >Cc: Liming Gao <liming.gao@intel.com> > >Signed-off-by: Zhiguang Liu <zhiguang.liu@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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] BaseTools: Add map file parsing support for CLANG9 2019-11-01 6:27 [PATCH 1/2] BaseTools: Add map file parsing support for CLANG9 Zhiguang Liu 2019-11-01 6:27 ` [PATCH 2/2] BaseTools: Add support for parseing map files generated by CLANG9 in GenFv Zhiguang Liu @ 2019-11-04 3:28 ` Liming Gao 1 sibling, 0 replies; 4+ messages in thread From: Liming Gao @ 2019-11-04 3:28 UTC (permalink / raw) To: Liu, Zhiguang, devel@edk2.groups.io; +Cc: Feng, Bob C Reviewed-by: Liming Gao <liming.gao@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.feng@intel.com>; Gao, Liming <liming.gao@intel.com> >Subject: [PATCH 1/2] BaseTools: Add map file parsing support for CLANG9 > >Cc: Bob Feng <bob.c.feng@intel.com> >Cc: Liming Gao <liming.gao@intel.com> > >Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com> >--- > BaseTools/Source/Python/Common/Misc.py | 9 ++++++--- > BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py | 9 >++++++--- > 2 files changed, 12 insertions(+), 6 deletions(-) > >diff --git a/BaseTools/Source/Python/Common/Misc.py >b/BaseTools/Source/Python/Common/Misc.py >index 714eb840ea..403715e6cc 100755 >--- a/BaseTools/Source/Python/Common/Misc.py >+++ b/BaseTools/Source/Python/Common/Misc.py >@@ -81,19 +81,22 @@ def GetVariableOffset(mapfilepath, efifilepath, >varnames): > > if len(lines) == 0: return None > firstline = lines[0].strip() >+ if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', >firstline): >+ return _parseForXcodeAndClang9(lines, efifilepath, varnames) > if (firstline.startswith("Archive member included ") and > firstline.endswith(" file (symbol)")): > return _parseForGCC(lines, efifilepath, varnames) > if firstline.startswith("# Path:"): >- return _parseForXcode(lines, efifilepath, varnames) >+ return _parseForXcodeAndClang9(lines, efifilepath, varnames) > return _parseGeneral(lines, efifilepath, varnames) > >-def _parseForXcode(lines, efifilepath, varnames): >+def _parseForXcodeAndClang9(lines, efifilepath, varnames): > status = 0 > ret = [] > for line in lines: > line = line.strip() >- if status == 0 and line == "# Symbols:": >+ if status == 0 and >(re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \ >+ or line == "# Symbols:"): > status = 1 > continue > if status == 1 and len(line) != 0: >diff --git >a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py >b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py >index 7d5e4fc34a..d962ab0add 100644 >--- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py >+++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py >@@ -49,20 +49,23 @@ def parsePcdInfoFromMapFile(mapfilepath, >efifilepath): > > if len(lines) == 0: return None > firstline = lines[0].strip() >+ if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', >firstline): >+ return _parseForXcodeAndClang9(lines, efifilepath) > if (firstline.startswith("Archive member included ") and > firstline.endswith(" file (symbol)")): > return _parseForGCC(lines, efifilepath) > if firstline.startswith("# Path:"): >- return _parseForXcode(lines, efifilepath) >+ return _parseForXcodeAndClang9(lines, efifilepath) > return _parseGeneral(lines, efifilepath) > >-def _parseForXcode(lines, efifilepath): >+def _parseForXcodeAndClang9(lines, efifilepath): > valuePattern = re.compile('^([\da-fA- >FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))') > status = 0 > pcds = [] > for line in lines: > line = line.strip() >- if status == 0 and line == "# Symbols:": >+ if status == 0 and >(re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', line) \ >+ or line == "# Symbols:"): > status = 1 > continue > if status == 1 and len(line) != 0: >-- >2.16.2.windows.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-04 3:28 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-11-01 6:27 [PATCH 1/2] BaseTools: Add map file parsing support for CLANG9 Zhiguang Liu 2019-11-01 6:27 ` [PATCH 2/2] BaseTools: Add support for parseing map files generated by CLANG9 in GenFv Zhiguang Liu 2019-11-04 3:28 ` Liming Gao 2019-11-04 3:28 ` [PATCH 1/2] BaseTools: Add map file parsing support for CLANG9 Liming Gao
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox