public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Yonghong Zhu <yonghong.zhu@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>
Subject: [Patch] BaseTools: Fix the bug to parse the new map file format
Date: Wed, 30 Nov 2016 16:23:17 +0800	[thread overview]
Message-ID: <1480494197-16156-1-git-send-email-yonghong.zhu@intel.com> (raw)

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>
---
 BaseTools/Source/Python/Common/Misc.py                     | 11 +++++++----
 .../Source/Python/GenPatchPcdTable/GenPatchPcdTable.py     | 14 +++++++++-----
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 3be1f0f..43d0818 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -72,11 +72,11 @@ def GetVariableOffset(mapfilepath, efifilepath, varnames):
 def _parseForGCC(lines, efifilepath, varnames):
     """ Parse map file generated by GCC linker """
     status = 0
     sections = []
     varoffset = []
-    for line in lines:
+    for index, line in enumerate(lines):
         line = line.strip()
         # status machine transection
         if status == 0 and line == "Memory Configuration":
             status = 1
             continue
@@ -86,18 +86,21 @@ def _parseForGCC(lines, efifilepath, varnames):
         elif status ==2 and line == 'START GROUP':
             status = 3
             continue
 
         # status handler
-        if status == 2:
+        if status == 3:
             m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$', line)
             if m != None:
                 sections.append(m.groups(0))
             for varname in varnames:
-                m = re.match("^([\da-fA-Fx]+) +[_]*(%s)$" % varname, line)
+                m = re.match(".data.(%s)$" % varname, line)
                 if m != None:
-                    varoffset.append((varname, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))
+                    if lines[index + 1]:
+                        m = re.match('^([\da-fA-Fx]+) +([\da-fA-Fx]+)', lines[index + 1].strip())
+                        if m != None:
+                            varoffset.append((varname, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))
 
     if not varoffset:
         return []
     # get section information from efi file
     efisecs = PeImageClass(efifilepath).SectionHeaderList
diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
index f4fd51a..4452fac 100644
--- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
+++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
@@ -64,11 +64,11 @@ def _parseForGCC(lines, efifilepath):
     """ Parse map file generated by GCC linker """
     status = 0
     imageBase = -1
     sections = []
     bpcds = []
-    for line in lines:
+    for index, line in enumerate(lines):
         line = line.strip()
         # status machine transection
         if status == 0 and line == "Memory Configuration":
             status = 1
             continue
@@ -78,18 +78,22 @@ def _parseForGCC(lines, efifilepath):
         elif status ==2 and line == 'START GROUP':
             status = 3
             continue
 
         # status handler
-        if status == 2:
+        if status == 3:
             m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$', line)
             if m != None:
                 sections.append(m.groups(0))
-        if status == 2:
-            m = re.match("^([\da-fA-Fx]+) +[_]+gPcd_BinaryPatch_([\w_\d]+)$", line)
+        if status == 3:
+            m = re.match('^.data._gPcd_BinaryPatch_([\w_\d]+)$', line)
             if m != None:
-                bpcds.append((m.groups(0)[1], int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))
+                if lines[index + 1]:
+                    PcdName = m.groups(0)[0]
+                    m = re.match('^([\da-fA-Fx]+) +([\da-fA-Fx]+)', lines[index + 1].strip())
+                    if m != None:
+                        bpcds.append((PcdName, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))
                 
     # get section information from efi file
     efisecs = PeImageClass(efifilepath).SectionHeaderList
     if efisecs == None or len(efisecs) == 0:
         return None
-- 
2.6.1.windows.1



             reply	other threads:[~2016-11-30  8:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-30  8:23 Yonghong Zhu [this message]
2016-12-02  2:31 ` [Patch] BaseTools: Fix the bug to parse the new map file format Gao, Liming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1480494197-16156-1-git-send-email-yonghong.zhu@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox