]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmulatorPkg/Sec: Change scope of PpiArray[10]
authorAndrew Fish <afish@apple.com>
Thu, 15 Aug 2019 20:00:31 +0000 (13:00 -0700)
committerMichael D Kinney <michael.d.kinney@intel.com>
Mon, 19 Aug 2019 16:57:28 +0000 (09:57 -0700)
The local variable PpiArray[10] is declared in the middle
of the SEC module _ModuleEntryPoint() with its own scope.
However, PpiArray has a dangling reference to its location
on the stack after the scope is closed.  This causes issues
with some compilers (e.g. XCODE5).

The fix is to move the declaration of PpiArray[10] to
the beginning of the function, so it is scoped correctly
for all references to this local variable and references
to its location.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Andrew Fish <afish@apple.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Tested-by: Andrew Fish <afish@apple.com>
EmulatorPkg/Sec/Sec.c

index 701032233bac0e8c36959a310be8f350ccf6ed55..b734d2bb87995655df8e66262c258736715174fb 100644 (file)
@@ -75,6 +75,7 @@ _ModuleEntryPoint (
   EFI_PEI_PPI_DESCRIPTOR    *SecPpiList;\r
   UINTN                     SecReseveredMemorySize;\r
   UINTN                     Index;\r
   EFI_PEI_PPI_DESCRIPTOR    *SecPpiList;\r
   UINTN                     SecReseveredMemorySize;\r
   UINTN                     Index;\r
+  EFI_PEI_PPI_DESCRIPTOR    PpiArray[10];\r
 \r
   EMU_MAGIC_PAGE()->PpiList = PpiList;\r
   ProcessLibraryConstructorList ();\r
 \r
   EMU_MAGIC_PAGE()->PpiList = PpiList;\r
   ProcessLibraryConstructorList ();\r
@@ -104,16 +105,13 @@ _ModuleEntryPoint (
   SecCoreData->PeiTemporaryRamBase = (VOID *)((UINTN)SecCoreData->PeiTemporaryRamBase + SecReseveredMemorySize);\r
   SecCoreData->PeiTemporaryRamSize -= SecReseveredMemorySize;\r
 #else\r
   SecCoreData->PeiTemporaryRamBase = (VOID *)((UINTN)SecCoreData->PeiTemporaryRamBase + SecReseveredMemorySize);\r
   SecCoreData->PeiTemporaryRamSize -= SecReseveredMemorySize;\r
 #else\r
-  {\r
-    //\r
-    // When I subtrack from SecCoreData->PeiTemporaryRamBase PEI Core crashes? Either there is a bug\r
-    // or I don't understand temp RAM correctly?\r
-    //\r
-    EFI_PEI_PPI_DESCRIPTOR    PpiArray[10];\r
-\r
-    SecPpiList = &PpiArray[0];\r
-    ASSERT (sizeof (PpiArray) >= SecReseveredMemorySize);\r
-  }\r
+  //\r
+  // When I subtrack from SecCoreData->PeiTemporaryRamBase PEI Core crashes? Either there is a bug\r
+  // or I don't understand temp RAM correctly?\r
+  //\r
+\r
+  SecPpiList = &PpiArray[0];\r
+  ASSERT (sizeof (PpiArray) >= SecReseveredMemorySize);\r
 #endif\r
   // Copy existing list, and append our entries.\r
   CopyMem (SecPpiList, PpiList, sizeof (EFI_PEI_PPI_DESCRIPTOR) * Index);\r
 #endif\r
   // Copy existing list, and append our entries.\r
   CopyMem (SecPpiList, PpiList, sizeof (EFI_PEI_PPI_DESCRIPTOR) * Index);\r