]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: parse map file generated by Xcode on Mac
authorYonghong Zhu <yonghong.zhu@intel.com>
Thu, 2 Nov 2017 05:15:34 +0000 (13:15 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Fri, 3 Nov 2017 06:30:49 +0000 (14:30 +0800)
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>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/Python/Common/Misc.py
BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py

index dbb711e96cefa02ea50d4f981c3d46beda31d0d1..2a5125d72da8c08f943bb0ac4fbdc113f49ba043 100644 (file)
@@ -67,8 +67,26 @@ def GetVariableOffset(mapfilepath, efifilepath, varnames):
     if (firstline.startswith("Archive member included ") and\r
         firstline.endswith(" file (symbol)")):\r
         return _parseForGCC(lines, efifilepath, varnames)\r
+    if firstline.startswith("# Path:"):\r
+        return _parseForXcode(lines, efifilepath, varnames)\r
     return _parseGeneral(lines, efifilepath, varnames)\r
 \r
+def _parseForXcode(lines, efifilepath, varnames):\r
+    status = 0\r
+    ret = []\r
+    for index, line in enumerate(lines):\r
+        line = line.strip()\r
+        if status == 0 and line == "# Symbols:":\r
+            status = 1\r
+            continue\r
+        if status == 1 and len(line) != 0:\r
+            for varname in varnames:\r
+                if varname in line:\r
+                    m = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' % varname, line)\r
+                    if m != None:\r
+                        ret.append((varname, m.group(1)))\r
+    return ret\r
+\r
 def _parseForGCC(lines, efifilepath, varnames):\r
     """ Parse map file generated by GCC linker """\r
     status = 0\r
index 4452fac0406460556197a3c4aa6ec09cf213f41d..fdad5a44dc3d25cfc0fa9e255f778140095754ad 100644 (file)
@@ -5,7 +5,7 @@
 #    PCD Name    Offset in binary\r
 #    ========    ================\r
 #\r
-# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -58,8 +58,25 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath):
     if (firstline.startswith("Archive member included ") and\r
         firstline.endswith(" file (symbol)")):\r
         return _parseForGCC(lines, efifilepath)\r
+    if firstline.startswith("# Path:"):\r
+        return _parseForXcode(lines, efifilepath)\r
     return _parseGeneral(lines, efifilepath)\r
 \r
+def _parseForXcode(lines, efifilepath):\r
+    status = 0\r
+    pcds = []\r
+    for index, line in enumerate(lines):\r
+        line = line.strip()\r
+        if status == 0 and line == "# Symbols:":\r
+            status = 1\r
+            continue\r
+        if status == 1 and len(line) != 0:\r
+            if '_gPcd_BinaryPatch_' in line:\r
+                m = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))', line)\r
+                if m != None:\r
+                    pcds.append((m.groups(0)[3], int(m.groups(0)[0], 16)))\r
+    return pcds\r
+\r
 def _parseForGCC(lines, efifilepath):\r
     """ Parse map file generated by GCC linker """\r
     status = 0\r