]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFsp2Pkg/Tools/PatchFv.py
MdePkg/Acpi62: Add type 7 NFIT Platform Capabilities Structure support
[mirror_edk2.git] / IntelFsp2Pkg / Tools / PatchFv.py
index 0c8d908063154babdee8d5575a5443a8f71a63f8..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
@@ -361,9 +362,11 @@ class Symbols:
         foundModHdr = False\r
         while (rptLine != "" ):\r
             if rptLine[0] != ' ':\r
-                #DxeIpl (Fixed Flash Address, BaseAddress=0x00fffb4310, EntryPoint=0x00fffb4958)\r
-                #(GUID=86D70125-BAA3-4296-A62F-602BEBBB9081 .textbaseaddress=0x00fffb4398 .databaseaddress=0x00fffb4178)\r
-                match = re.match("([_a-zA-Z0-9\-]+)\s\(.+BaseAddress=(0x[0-9a-fA-F]+),\s+EntryPoint=(0x[0-9a-fA-F]+)\)", rptLine)\r
+                #DxeIpl (Fixed Flash Address, BaseAddress=0x00fffb4310, EntryPoint=0x00fffb4958,Type=PE)\r
+                match = re.match("([_a-zA-Z0-9\-]+)\s\(.+BaseAddress=(0x[0-9a-fA-F]+),\s+EntryPoint=(0x[0-9a-fA-F]+),\s*Type=\w+\)", rptLine)\r
+                if match is None:\r
+                    #DxeIpl (Fixed Flash Address, BaseAddress=0x00fffb4310, EntryPoint=0x00fffb4958)\r
+                    match = re.match("([_a-zA-Z0-9\-]+)\s\(.+BaseAddress=(0x[0-9a-fA-F]+),\s+EntryPoint=(0x[0-9a-fA-F]+)\)", rptLine)\r
                 if match is not None:\r
                     foundModHdr = True\r
                     modName = match.group(1)\r
@@ -371,6 +374,7 @@ class Symbols:
                        modName = self.dictGuidNameXref[modName.upper()]\r
                     self.dictModBase['%s:BASE'  % modName] = int (match.group(2), 16)\r
                     self.dictModBase['%s:ENTRY' % modName] = int (match.group(3), 16)\r
+                #(GUID=86D70125-BAA3-4296-A62F-602BEBBB9081 .textbaseaddress=0x00fffb4398 .databaseaddress=0x00fffb4178)\r
                 match = re.match("\(GUID=([A-Z0-9\-]+)\s+\.textbaseaddress=(0x[0-9a-fA-F]+)\s+\.databaseaddress=(0x[0-9a-fA-F]+)\)", rptLine)\r
                 if match is not None:\r
                     if foundModHdr:\r
@@ -399,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
@@ -423,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
@@ -452,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
@@ -495,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