BaseTools: Fix the bug to parse the new map file format
authorYonghong Zhu <yonghong.zhu@intel.com>
Wed, 30 Nov 2016 08:02:21 +0000 (16:02 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Fri, 2 Dec 2016 03:01:24 +0000 (11:01 +0800)
Current the variable and Pcd format save in the map file is changed, so
this patch is to support this new format.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
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 3be1f0f28b634c91f99cbd1108613168dc50cb2f..43d08183f7ebcba7bb935296f171aab087f2744b 100644 (file)
@@ -74,7 +74,7 @@ def _parseForGCC(lines, efifilepath, varnames):
     status = 0\r
     sections = []\r
     varoffset = []\r
-    for line in lines:\r
+    for index, line in enumerate(lines):\r
         line = line.strip()\r
         # status machine transection\r
         if status == 0 and line == "Memory Configuration":\r
@@ -88,14 +88,17 @@ def _parseForGCC(lines, efifilepath, varnames):
             continue\r
 \r
         # status handler\r
-        if status == 2:\r
+        if status == 3:\r
             m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$', line)\r
             if m != None:\r
                 sections.append(m.groups(0))\r
             for varname in varnames:\r
-                m = re.match("^([\da-fA-Fx]+) +[_]*(%s)$" % varname, line)\r
+                m = re.match(".data.(%s)$" % varname, line)\r
                 if m != None:\r
-                    varoffset.append((varname, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))\r
+                    if lines[index + 1]:\r
+                        m = re.match('^([\da-fA-Fx]+) +([\da-fA-Fx]+)', lines[index + 1].strip())\r
+                        if m != None:\r
+                            varoffset.append((varname, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))\r
 \r
     if not varoffset:\r
         return []\r
index f4fd51a256caefb65f4953184b6dde282d56a871..4452fac0406460556197a3c4aa6ec09cf213f41d 100644 (file)
@@ -66,7 +66,7 @@ def _parseForGCC(lines, efifilepath):
     imageBase = -1\r
     sections = []\r
     bpcds = []\r
-    for line in lines:\r
+    for index, line in enumerate(lines):\r
         line = line.strip()\r
         # status machine transection\r
         if status == 0 and line == "Memory Configuration":\r
@@ -80,14 +80,18 @@ def _parseForGCC(lines, efifilepath):
             continue\r
 \r
         # status handler\r
-        if status == 2:\r
+        if status == 3:\r
             m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$', line)\r
             if m != None:\r
                 sections.append(m.groups(0))\r
-        if status == 2:\r
-            m = re.match("^([\da-fA-Fx]+) +[_]+gPcd_BinaryPatch_([\w_\d]+)$", line)\r
+        if status == 3:\r
+            m = re.match('^.data._gPcd_BinaryPatch_([\w_\d]+)$', line)\r
             if m != None:\r
-                bpcds.append((m.groups(0)[1], int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))\r
+                if lines[index + 1]:\r
+                    PcdName = m.groups(0)[0]\r
+                    m = re.match('^([\da-fA-Fx]+) +([\da-fA-Fx]+)', lines[index + 1].strip())\r
+                    if m != None:\r
+                        bpcds.append((PcdName, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))\r
                 \r
     # get section information from efi file\r
     efisecs = PeImageClass(efifilepath).SectionHeaderList\r