GenPatchPcdTable.py revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
## @file
# Generate PCD table for 'Patchable In Module' type PCD with given .map file.
# The Patch PCD table like:
#
# PCD Name Offset in binary
# ======== ================
#
# Copyright (c) 2008 - 2010, 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#====================================== External Libraries ========================================
import optparse
import os
import re
import array
from Common.BuildToolError import *
# Version and Copyright
__copyright__ = "Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved."
#====================================== Internal Libraries ========================================
#============================================== Code ===============================================
secRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)
""" Parse map file to get binary patch pcd information
@param path Map file absolution path
@return a list which element hold (PcdName, Offset, SectionName)
"""
lines = []
try:
f.close()
except:
return None
return _parseForGCC(lines)
def _parseForGCC(lines):
""" Parse map file generated by GCC linker """
status = 0
imageBase = -1
lastSectionName = None
pcds = []
# status machine transection
status = 1
continue
status = 2
continue
# status handler:
if status == 1:
if m != None:
if status == 2:
if m != None:
if status == 2:
if m != None:
return pcds
""" For MSFT, ICC, EBC
@param lines line array for map file
@return a list which element hold (PcdName, Offset, SectionName)
"""
secs = [] # key = section name
bPcds = []
status = 1
continue
status = 2
continue
status = 3
continue
assert m != None, "Fail to parse the section in map file , line is %s" % line
assert m != None, "Fail to parse the symbol in map file, line is %s" % line
if m2 != None:
# fond a binary pcd entry in map file
# get section information from efi file
return None
pcds = []
index = 0
return pcds
try:
except:
pass
f.write('PCD Name Offset Section Name\r\n')
f.close()
#print 'Success to generate Binary Patch PCD table at %s!' % pcdpath
if __name__ == '__main__':
UsageString = "%prog -m <MapFile> -e <EfiFile> -o <OutFile>"
AdditionalNotes = "\nPCD table is generated in file name with .BinaryPcdTable.txt postfix"
help='Absolute path of module map file.')
help='Absolute path of EFI binary file.')
help='Absolute path of output file to store the got patchable PCD table.')
if list != None:
else:
else:
print 'Fail to generate Patch PCD Table based on map file and efi file'
else:
print 'Fail to generate Patch PCD Table for fail to find map file or efi file!'