X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenPatchPcdTable%2FGenPatchPcdTable.py;h=dc2ceaf775d88c5a179930c4430ee74212aa5307;hp=59bc7c4c3e29f015620d8540c53dcb3bd63bb9ad;hb=1563349a967d7e02c43492ba853babb9c660a083;hpb=8b54f22f60d1ecdfc4beb1f0965b52f7063b93ad
diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
index 59bc7c4c3e..dc2ceaf775 100644
--- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
+++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
@@ -5,7 +5,7 @@
# PCD Name Offset in binary
# ======== ================
#
-# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
# 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
@@ -37,7 +37,7 @@ __copyright__ = "Copyright (c) 2008 - 2010, Intel Corporation. All rights reserv
#============================================== Code ===============================================
secRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)
-symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$]+) +([\da-fA-F]+)', re.UNICODE)
+symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$<>]+) +([\da-fA-F]+)', re.UNICODE)
def parsePcdInfoFromMapFile(mapfilepath, efifilepath):
""" Parse map file to get binary patch pcd information
@@ -58,15 +58,32 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath):
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 line in 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 is not 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 = []
bpcds = []
- for line in lines:
+ for index, line in enumerate(lines):
line = line.strip()
# status machine transection
if status == 0 and line == "Memory Configuration":
@@ -80,18 +97,22 @@ def _parseForGCC(lines, efifilepath):
continue
# status handler
- if status == 2:
+ if status == 3:
m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$', line)
- if m != None:
+ if m is not None:
sections.append(m.groups(0))
- if status == 2:
- m = re.match("^([\da-fA-Fx]+) +[_]+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 status == 3:
+ m = re.match('^.data._gPcd_BinaryPatch_([\w_\d]+)$', line)
+ if m is not None:
+ if lines[index + 1]:
+ PcdName = m.groups(0)[0]
+ m = re.match('^([\da-fA-Fx]+) +([\da-fA-Fx]+)', lines[index + 1].strip())
+ if m is not 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:
+ if efisecs is None or len(efisecs) == 0:
return None
#redirection
redirection = 0
@@ -131,18 +152,18 @@ def _parseGeneral(lines, efifilepath):
continue
if status == 1 and len(line) != 0:
m = secRe.match(line)
- assert m != None, "Fail to parse the section in map file , line is %s" % line
+ assert m is not None, "Fail to parse the section in map file , line is %s" % line
sec_no, sec_start, sec_length, sec_name, sec_class = m.groups(0)
secs.append([int(sec_no, 16), int(sec_start, 16), int(sec_length, 16), sec_name, sec_class])
if status == 2 and len(line) != 0:
m = symRe.match(line)
- assert m != None, "Fail to parse the symbol in map file, line is %s" % line
+ assert m is not None, "Fail to parse the symbol in map file, line is %s" % line
sec_no, sym_offset, sym_name, vir_addr = m.groups(0)
sec_no = int(sec_no, 16)
sym_offset = int(sym_offset, 16)
vir_addr = int(vir_addr, 16)
m2 = re.match('^[_]+gPcd_BinaryPatch_([\w]+)', sym_name)
- if m2 != None:
+ if m2 is not None:
# fond a binary pcd entry in map file
for sec in secs:
if sec[0] == sec_no and (sym_offset >= sec[1] and sym_offset < sec[1] + sec[2]):
@@ -152,7 +173,7 @@ def _parseGeneral(lines, efifilepath):
# get section information from efi file
efisecs = PeImageClass(efifilepath).SectionHeaderList
- if efisecs == None or len(efisecs) == 0:
+ if efisecs is None or len(efisecs) == 0:
return None
pcds = []
@@ -193,12 +214,12 @@ if __name__ == '__main__':
(options, args) = parser.parse_args()
- if options.mapfile == None or options.efifile == None:
+ if options.mapfile is None or options.efifile is None:
print parser.get_usage()
elif os.path.exists(options.mapfile) and os.path.exists(options.efifile):
list = parsePcdInfoFromMapFile(options.mapfile, options.efifile)
- if list != None:
- if options.outfile != None:
+ if list is not None:
+ if options.outfile is not None:
generatePcdTable(list, options.outfile)
else:
generatePcdTable(list, options.mapfile.replace('.map', '.BinaryPcdTable.txt'))