public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: parse map file generated by Xcode on Mac
@ 2017-11-02  5:17 Yonghong Zhu
  2017-11-02 14:13 ` Gao, Liming
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2017-11-02  5:17 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao

Add support to parse map file generated by Xcode on Mac to get
variable offset and Patchable Pcd info in current EFI file.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/Python/Common/Misc.py                | 18 ++++++++++++++++++
 .../Python/GenPatchPcdTable/GenPatchPcdTable.py       | 19 ++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index dbb711e..5299cf1 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -65,12 +65,30 @@ def GetVariableOffset(mapfilepath, efifilepath, varnames):
     if len(lines) == 0: return None
     firstline = lines[0].strip()
     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 _parseGeneral(lines, efifilepath, varnames)
 
+def _parseForXcode(lines, efifilepath, varnames):
+    status = 0
+    ret = []
+    for index, line in enumerate(lines):
+        line = line.strip()
+        if status == 0 and line == "# Symbols:":
+            status = 1
+            continue
+        if status == 1 and len(line) != 0:
+            for varname in varnames:
+                if varname in line:
+                    m = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' % varname, line)
+                    if m != None:
+                        ret.append((varname, m.group(1)))
+    return ret
+
 def _parseForGCC(lines, efifilepath, varnames):
     """ Parse map file generated by GCC linker """
     status = 0
     sections = []
     varoffset = []
diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
index 4452fac..fdad5a4 100644
--- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
+++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
@@ -3,11 +3,11 @@
 #    The Patch PCD table like:
 #    
 #    PCD Name    Offset in binary
 #    ========    ================
 #
-# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR>
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD License
 # which accompanies this distribution.  The full text of the license may be found at
 # http://opensource.org/licenses/bsd-license.php
 #
@@ -56,12 +56,29 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath):
     if len(lines) == 0: return None
     firstline = lines[0].strip()
     if (firstline.startswith("Archive member included ") and
         firstline.endswith(" file (symbol)")):
         return _parseForGCC(lines, efifilepath)
+    if firstline.startswith("# Path:"):
+        return _parseForXcode(lines, efifilepath)
     return _parseGeneral(lines, efifilepath)
 
+def _parseForXcode(lines, efifilepath):
+    status = 0
+    pcds = []
+    for index, line in enumerate(lines):
+        line = line.strip()
+        if status == 0 and line == "# Symbols:":
+            status = 1
+            continue
+        if status == 1 and len(line) != 0:
+            if '_gPcd_BinaryPatch_' in line:
+                m = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))', line)
+                if m != None:
+                    pcds.append((m.groups(0)[3], int(m.groups(0)[0], 16)))
+    return pcds
+
 def _parseForGCC(lines, efifilepath):
     """ Parse map file generated by GCC linker """
     status = 0
     imageBase = -1
     sections = []
-- 
2.6.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch] BaseTools: parse map file generated by Xcode on Mac
  2017-11-02  5:17 [Patch] BaseTools: parse map file generated by Xcode on Mac Yonghong Zhu
@ 2017-11-02 14:13 ` Gao, Liming
  0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2017-11-02 14:13 UTC (permalink / raw)
  To: Zhu, Yonghong, edk2-devel@lists.01.org

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

> -----Original Message-----
> From: Zhu, Yonghong
> Sent: Thursday, November 2, 2017 1:18 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: [Patch] BaseTools: parse map file generated by Xcode on Mac
> 
> Add support to parse map file generated by Xcode on Mac to get
> variable offset and Patchable Pcd info in current EFI file.
> 
> Cc: Liming Gao <liming.gao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
> ---
>  BaseTools/Source/Python/Common/Misc.py                | 18 ++++++++++++++++++
>  .../Python/GenPatchPcdTable/GenPatchPcdTable.py       | 19 ++++++++++++++++++-
>  2 files changed, 36 insertions(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
> index dbb711e..5299cf1 100644
> --- a/BaseTools/Source/Python/Common/Misc.py
> +++ b/BaseTools/Source/Python/Common/Misc.py
> @@ -65,12 +65,30 @@ def GetVariableOffset(mapfilepath, efifilepath, varnames):
>      if len(lines) == 0: return None
>      firstline = lines[0].strip()
>      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 _parseGeneral(lines, efifilepath, varnames)
> 
> +def _parseForXcode(lines, efifilepath, varnames):
> +    status = 0
> +    ret = []
> +    for index, line in enumerate(lines):
> +        line = line.strip()
> +        if status == 0 and line == "# Symbols:":
> +            status = 1
> +            continue
> +        if status == 1 and len(line) != 0:
> +            for varname in varnames:
> +                if varname in line:
> +                    m = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' % varname, line)
> +                    if m != None:
> +                        ret.append((varname, m.group(1)))
> +    return ret
> +
>  def _parseForGCC(lines, efifilepath, varnames):
>      """ Parse map file generated by GCC linker """
>      status = 0
>      sections = []
>      varoffset = []
> diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
> b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
> index 4452fac..fdad5a4 100644
> --- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
> +++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
> @@ -3,11 +3,11 @@
>  #    The Patch PCD table like:
>  #
>  #    PCD Name    Offset in binary
>  #    ========    ================
>  #
> -# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>
> +# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR>
>  # This program and the accompanying materials
>  # are licensed and made available under the terms and conditions of the BSD License
>  # which accompanies this distribution.  The full text of the license may be found at
>  # http://opensource.org/licenses/bsd-license.php
>  #
> @@ -56,12 +56,29 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath):
>      if len(lines) == 0: return None
>      firstline = lines[0].strip()
>      if (firstline.startswith("Archive member included ") and
>          firstline.endswith(" file (symbol)")):
>          return _parseForGCC(lines, efifilepath)
> +    if firstline.startswith("# Path:"):
> +        return _parseForXcode(lines, efifilepath)
>      return _parseGeneral(lines, efifilepath)
> 
> +def _parseForXcode(lines, efifilepath):
> +    status = 0
> +    pcds = []
> +    for index, line in enumerate(lines):
> +        line = line.strip()
> +        if status == 0 and line == "# Symbols:":
> +            status = 1
> +            continue
> +        if status == 1 and len(line) != 0:
> +            if '_gPcd_BinaryPatch_' in line:
> +                m = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))', line)
> +                if m != None:
> +                    pcds.append((m.groups(0)[3], int(m.groups(0)[0], 16)))
> +    return pcds
> +
>  def _parseForGCC(lines, efifilepath):
>      """ Parse map file generated by GCC linker """
>      status = 0
>      imageBase = -1
>      sections = []
> --
> 2.6.1.windows.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-02 14:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-02  5:17 [Patch] BaseTools: parse map file generated by Xcode on Mac Yonghong Zhu
2017-11-02 14:13 ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox