[PATCH v3] IntelFsp2Pkg: PatchFv parseInfFile function modification


Ashraf Ali S
 

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3476

parseInfFile currently reading the EFI_BASE_ADDRESS from INF, once the
address found still it's continues to read the complete inf file which
is not required. once the EFI_BASE_ADDRESS read from the INF no need to
read the INF further.
MSFT compiler can generate the map file address 8 or 16 based on which
architecture the INF is compiler. currently it's support for IA32,
modified the patchfv to support for all.
modification of few typo errors in parseModMapFile, getCurr function
required

verification : Working Fine

Signed-off-by: Ashraf Ali S <ashraf.ali.s@...>
Cc: Ray Ni <ray.ni@...>
Cc: Chasel Chiu <chasel.chiu@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Star Zeng <star.zeng@...>
---
IntelFsp2Pkg/Tools/PatchFv.py | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/IntelFsp2Pkg/Tools/PatchFv.py b/IntelFsp2Pkg/Tools/PatchFv.py
index 112de4077a..eb130049b5 100644
--- a/IntelFsp2Pkg/Tools/PatchFv.py
+++ b/IntelFsp2Pkg/Tools/PatchFv.py
@@ -1,6 +1,6 @@
## @ PatchFv.py
#
-# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
@@ -304,10 +304,11 @@ class Symbols:
match = re.match("^EFI_BASE_ADDRESS\s*=\s*(0x[a-fA-F0-9]+)", rptLine)
if match is not None:
self.fdBase = int(match.group(1), 16) - fvOffset
+ break
rptLine = fdIn.readline()
fdIn.close()
if self.fdBase == 0xFFFFFFFF:
- raise Exception("Could not find EFI_BASE_ADDRESS in INF file!" % fvFile)
+ raise Exception("Could not find EFI_BASE_ADDRESS in INF file!" % infFile)
return 0

#
@@ -402,6 +403,7 @@ class Symbols:
#
# retval 0 Parsed MOD MAP file successfully
# retval 1 There is no moduleEntryPoint in modSymbols
+ # retval 2 There is no offset for moduleEntryPoint in modSymbols
#
def parseModMapFile(self, moduleName, mapFile):
#
@@ -426,7 +428,7 @@ class Symbols:
else:
#MSFT
#0003:00000190 _gComBase 00007a50 SerialPo
- patchMapFileMatchString = "^\s[0-9a-fA-F]{4}:[0-9a-fA-F]{8}\s+(\w+)\s+([0-9a-fA-F]{8}\s+)"
+ patchMapFileMatchString = "^\s[0-9a-fA-F]{4}:[0-9a-fA-F]{8}\s+(\w+)\s+([0-9a-fA-F]{8,16}\s+)"
matchKeyGroupIndex = 1
matchSymbolGroupIndex = 2
prefix = ''
@@ -455,7 +457,13 @@ class Symbols:
continue

if not moduleEntryPoint in modSymbols:
- return 1
+ if matchSymbolGroupIndex == 2:
+ if not '_ModuleEntryPoint' in modSymbols:
+ return 1
+ else:
+ moduleEntryPoint = "_ModuleEntryPoint"
+ else:
+ return 1

modEntry = '%s:%s' % (moduleName,moduleEntryPoint)
if not modEntry in self.dictSymbolAddress:
@@ -498,7 +506,7 @@ class Symbols:
#
# Get current character
#
- # retval elf.string[self.index]
+ # retval self.string[self.index]
# retval '' Exception
#
def getCurr(self):
--
2.30.2.windows.1


Chiu, Chasel
 

Reviewed-by: Chasel Chiu <chasel.chiu@...>

-----Original Message-----
From: S, Ashraf Ali <ashraf.ali.s@...>
Sent: Wednesday, July 7, 2021 2:42 AM
To: devel@edk2.groups.io
Cc: S, Ashraf Ali <ashraf.ali.s@...>; Ni, Ray <ray.ni@...>; Chiu,
Chasel <chasel.chiu@...>; Desimone, Nathaniel L
<nathaniel.l.desimone@...>; Zeng, Star <star.zeng@...>
Subject: [PATCH v3] IntelFsp2Pkg: PatchFv parseInfFile function modification

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3476

parseInfFile currently reading the EFI_BASE_ADDRESS from INF, once the
address found still it's continues to read the complete inf file which is not
required. once the EFI_BASE_ADDRESS read from the INF no need to read the
INF further.
MSFT compiler can generate the map file address 8 or 16 based on which
architecture the INF is compiler. currently it's support for IA32, modified the
patchfv to support for all.
modification of few typo errors in parseModMapFile, getCurr function required

verification : Working Fine

Signed-off-by: Ashraf Ali S <ashraf.ali.s@...>
Cc: Ray Ni <ray.ni@...>
Cc: Chasel Chiu <chasel.chiu@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Star Zeng <star.zeng@...>
---
IntelFsp2Pkg/Tools/PatchFv.py | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/IntelFsp2Pkg/Tools/PatchFv.py b/IntelFsp2Pkg/Tools/PatchFv.py
index 112de4077a..eb130049b5 100644
--- a/IntelFsp2Pkg/Tools/PatchFv.py
+++ b/IntelFsp2Pkg/Tools/PatchFv.py
@@ -1,6 +1,6 @@
## @ PatchFv.py
#
-# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2014 - 2021, Intel Corporation. All rights
+reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -304,10 +304,11 @@
class Symbols:
match = re.match("^EFI_BASE_ADDRESS\s*=\s*(0x[a-fA-F0-9]+)", rptLine)
if match is not None:
self.fdBase = int(match.group(1), 16) - fvOffset
+ break
rptLine = fdIn.readline()
fdIn.close()
if self.fdBase == 0xFFFFFFFF:
- raise Exception("Could not find EFI_BASE_ADDRESS in INF file!" % fvFile)
+ raise Exception("Could not find EFI_BASE_ADDRESS in INF
+ file!" % infFile)
return 0

#
@@ -402,6 +403,7 @@ class Symbols:
#
# retval 0 Parsed MOD MAP file successfully
# retval 1 There is no moduleEntryPoint in modSymbols
+ # retval 2 There is no offset for moduleEntryPoint in modSymbols
#
def parseModMapFile(self, moduleName, mapFile):
#
@@ -426,7 +428,7 @@ class Symbols:
else:
#MSFT
#0003:00000190 _gComBase 00007a50 SerialPo
- patchMapFileMatchString = "^\s[0-9a-fA-F]{4}:[0-9a-fA-
F]{8}\s+(\w+)\s+([0-9a-fA-F]{8}\s+)"
+ patchMapFileMatchString = "^\s[0-9a-fA-F]{4}:[0-9a-fA-
F]{8}\s+(\w+)\s+([0-9a-fA-F]{8,16}\s+)"
matchKeyGroupIndex = 1
matchSymbolGroupIndex = 2
prefix = ''
@@ -455,7 +457,13 @@ class Symbols:
continue

if not moduleEntryPoint in modSymbols:
- return 1
+ if matchSymbolGroupIndex == 2:
+ if not '_ModuleEntryPoint' in modSymbols:
+ return 1
+ else:
+ moduleEntryPoint = "_ModuleEntryPoint"
+ else:
+ return 1

modEntry = '%s:%s' % (moduleName,moduleEntryPoint)
if not modEntry in self.dictSymbolAddress:
@@ -498,7 +506,7 @@ class Symbols:
#
# Get current character
#
- # retval elf.string[self.index]
+ # retval self.string[self.index]
# retval '' Exception
#
def getCurr(self):
--
2.30.2.windows.1


Chiu, Chasel
 

Patch pushed: b560e9d9b67450d3baea56d0e211066722643c57

Thanks,
Chasel

-----Original Message-----
From: S, Ashraf Ali <ashraf.ali.s@...>
Sent: Wednesday, July 7, 2021 2:42 AM
To: devel@edk2.groups.io
Cc: S, Ashraf Ali <ashraf.ali.s@...>; Ni, Ray <ray.ni@...>; Chiu,
Chasel <chasel.chiu@...>; Desimone, Nathaniel L
<nathaniel.l.desimone@...>; Zeng, Star <star.zeng@...>
Subject: [PATCH v3] IntelFsp2Pkg: PatchFv parseInfFile function modification

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3476

parseInfFile currently reading the EFI_BASE_ADDRESS from INF, once the
address found still it's continues to read the complete inf file which is not
required. once the EFI_BASE_ADDRESS read from the INF no need to read the
INF further.
MSFT compiler can generate the map file address 8 or 16 based on which
architecture the INF is compiler. currently it's support for IA32, modified the
patchfv to support for all.
modification of few typo errors in parseModMapFile, getCurr function required

verification : Working Fine

Signed-off-by: Ashraf Ali S <ashraf.ali.s@...>
Cc: Ray Ni <ray.ni@...>
Cc: Chasel Chiu <chasel.chiu@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Star Zeng <star.zeng@...>
---
IntelFsp2Pkg/Tools/PatchFv.py | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/IntelFsp2Pkg/Tools/PatchFv.py b/IntelFsp2Pkg/Tools/PatchFv.py
index 112de4077a..eb130049b5 100644
--- a/IntelFsp2Pkg/Tools/PatchFv.py
+++ b/IntelFsp2Pkg/Tools/PatchFv.py
@@ -1,6 +1,6 @@
## @ PatchFv.py
#
-# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2014 - 2021, Intel Corporation. All rights
+reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -304,10 +304,11 @@
class Symbols:
match = re.match("^EFI_BASE_ADDRESS\s*=\s*(0x[a-fA-F0-9]+)", rptLine)
if match is not None:
self.fdBase = int(match.group(1), 16) - fvOffset
+ break
rptLine = fdIn.readline()
fdIn.close()
if self.fdBase == 0xFFFFFFFF:
- raise Exception("Could not find EFI_BASE_ADDRESS in INF file!" % fvFile)
+ raise Exception("Could not find EFI_BASE_ADDRESS in INF
+ file!" % infFile)
return 0

#
@@ -402,6 +403,7 @@ class Symbols:
#
# retval 0 Parsed MOD MAP file successfully
# retval 1 There is no moduleEntryPoint in modSymbols
+ # retval 2 There is no offset for moduleEntryPoint in modSymbols
#
def parseModMapFile(self, moduleName, mapFile):
#
@@ -426,7 +428,7 @@ class Symbols:
else:
#MSFT
#0003:00000190 _gComBase 00007a50 SerialPo
- patchMapFileMatchString = "^\s[0-9a-fA-F]{4}:[0-9a-fA-
F]{8}\s+(\w+)\s+([0-9a-fA-F]{8}\s+)"
+ patchMapFileMatchString = "^\s[0-9a-fA-F]{4}:[0-9a-fA-
F]{8}\s+(\w+)\s+([0-9a-fA-F]{8,16}\s+)"
matchKeyGroupIndex = 1
matchSymbolGroupIndex = 2
prefix = ''
@@ -455,7 +457,13 @@ class Symbols:
continue

if not moduleEntryPoint in modSymbols:
- return 1
+ if matchSymbolGroupIndex == 2:
+ if not '_ModuleEntryPoint' in modSymbols:
+ return 1
+ else:
+ moduleEntryPoint = "_ModuleEntryPoint"
+ else:
+ return 1

modEntry = '%s:%s' % (moduleName,moduleEntryPoint)
if not modEntry in self.dictSymbolAddress:
@@ -498,7 +506,7 @@ class Symbols:
#
# Get current character
#
- # retval elf.string[self.index]
+ # retval self.string[self.index]
# retval '' Exception
#
def getCurr(self):
--
2.30.2.windows.1