BaseTools: Fix the bug to parse the new map file format
[mirror_edk2.git] / BaseTools / Source / Python / Common / Misc.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