Sync BaseTool trunk (version r2610) into EDKII BaseTools.

Signed-off-by: Liming Gao <liming.gao@intel.com>


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14856 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Liming Gao
2013-11-18 07:41:21 +00:00
committed by lgao4
parent fddbbc661e
commit e8a47801a1
65 changed files with 3487 additions and 1302 deletions

View File

@ -5,7 +5,7 @@
# PCD Name Offset in binary
# ======== ================
#
# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.<BR>
# 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
@ -54,39 +54,54 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath):
if len(lines) == 0: return None
if lines[0].strip().find("Archive member included because of file (symbol)") != -1:
return _parseForGCC(lines)
return _parseForGCC(lines, efifilepath)
return _parseGeneral(lines, efifilepath)
def _parseForGCC(lines):
def _parseForGCC(lines, efifilepath):
""" Parse map file generated by GCC linker """
status = 0
imageBase = -1
lastSectionName = None
pcds = []
status = 0
imageBase = -1
sections = []
bpcds = []
for line in lines:
line = line.strip()
# status machine transection
if status == 0 and line == "Linker script and memory map":
if status == 0 and line == "Memory Configuration":
status = 1
continue
elif status == 1 and line == 'START GROUP':
elif status == 1 and line == 'Linker script and memory map':
status = 2
continue
# status handler:
if status == 1:
m = re.match('^[\da-fA-FxhH]+ +__image_base__ += +([\da-fA-FhxH]+)', line)
if m != None:
imageBase = int(m.groups(0)[0], 16)
elif status ==2 and line == 'START GROUP':
status = 3
continue
# status handler
if status == 2:
m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)', line)
m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$', line)
if m != None:
lastSectionName = m.groups(0)[0]
sections.append(m.groups(0))
if status == 2:
m = re.match("^([\da-fA-Fx]+) +[_]+gPcd_BinaryPatch_([\w_\d]+)", line)
m = re.match("^([\da-fA-Fx]+) +[_]+gPcd_BinaryPatch_([\w_\d]+)$", line)
if m != None:
assert imageBase != -1, "Fail to get Binary PCD offsest for unknown image base address"
pcds.append((m.groups(0)[1], int(m.groups(0)[0], 16) - imageBase, lastSectionName))
bpcds.append((m.groups(0)[1], 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
#redirection
redirection = 0
for efisec in efisecs:
for section in sections:
if section[0].strip() == efisec[0].strip() and section[0].strip() == '.text':
redirection = int(section[1], 16) - efisec[1]
pcds = []
for pcd in bpcds:
for efisec in efisecs:
if pcd[1] >= efisec[1] and pcd[1] < efisec[1]+efisec[3]:
#assert efisec[0].strip() == pcd[3].strip() and efisec[1] + redirection == pcd[2], "There are some differences between map file and efi file"
pcds.append([pcd[0], efisec[2] + pcd[1] - efisec[1] - redirection, efisec[0]])
return pcds
def _parseGeneral(lines, efifilepath):