]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFsp2Pkg: PatchFv parseInfFile function modification
authorS, Ashraf Ali <ashraf.ali.s@intel.com>
Tue, 6 Jul 2021 18:42:04 +0000 (02:42 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 8 Jul 2021 06:49:09 +0000 (06:49 +0000)
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@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
IntelFsp2Pkg/Tools/PatchFv.py

index 112de4077a18eb95679d9e18fec75508d949993e..eb130049b5177b0a914f657f850bed84f75d5295 100644 (file)
@@ -1,6 +1,6 @@
 ## @ PatchFv.py\r
 #\r
-# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
@@ -304,10 +304,11 @@ class Symbols:
             match = re.match("^EFI_BASE_ADDRESS\s*=\s*(0x[a-fA-F0-9]+)", rptLine)\r
             if match is not None:\r
                 self.fdBase = int(match.group(1), 16) - fvOffset\r
+                break\r
             rptLine  = fdIn.readline()\r
         fdIn.close()\r
         if self.fdBase == 0xFFFFFFFF:\r
-            raise Exception("Could not find EFI_BASE_ADDRESS in INF file!" % fvFile)\r
+            raise Exception("Could not find EFI_BASE_ADDRESS in INF file!" % infFile)\r
         return 0\r
 \r
     #\r
@@ -402,6 +403,7 @@ class Symbols:
     #\r
     #  retval      0           Parsed MOD MAP file successfully\r
     #  retval      1           There is no moduleEntryPoint in modSymbols\r
+    #  retval      2           There is no offset for moduleEntryPoint in modSymbols\r
     #\r
     def parseModMapFile(self, moduleName, mapFile):\r
         #\r
@@ -426,7 +428,7 @@ class Symbols:
         else:\r
             #MSFT\r
             #0003:00000190       _gComBase                  00007a50     SerialPo\r
-            patchMapFileMatchString =  "^\s[0-9a-fA-F]{4}:[0-9a-fA-F]{8}\s+(\w+)\s+([0-9a-fA-F]{8}\s+)"\r
+            patchMapFileMatchString =  "^\s[0-9a-fA-F]{4}:[0-9a-fA-F]{8}\s+(\w+)\s+([0-9a-fA-F]{8,16}\s+)"\r
             matchKeyGroupIndex = 1\r
             matchSymbolGroupIndex  = 2\r
             prefix = ''\r
@@ -455,7 +457,13 @@ class Symbols:
                         continue\r
 \r
         if not moduleEntryPoint in modSymbols:\r
-            return 1\r
+            if matchSymbolGroupIndex == 2:\r
+                if not '_ModuleEntryPoint' in modSymbols:\r
+                    return 1\r
+                else:\r
+                    moduleEntryPoint = "_ModuleEntryPoint"\r
+            else:\r
+                return 1\r
 \r
         modEntry = '%s:%s' % (moduleName,moduleEntryPoint)\r
         if not modEntry in self.dictSymbolAddress:\r
@@ -498,7 +506,7 @@ class Symbols:
     #\r
     #  Get current character\r
     #\r
-    #  retval      elf.string[self.index]\r
+    #  retval      self.string[self.index]\r
     #  retval      ''                       Exception\r
     #\r
     def getCurr(self):\r