Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>

 

- Bret

 


From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Ard Biesheuvel via groups.io <ard.biesheuvel=arm.com@groups.io>
Sent: Thursday, April 9, 2020 9:09:47 AM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: jian.j.wang@intel.com <jian.j.wang@intel.com>; hao.a.wu@intel.com <hao.a.wu@intel.com>; Ard Biesheuvel <ard.biesheuvel@arm.com>
Subject: [EXTERNAL] [edk2-devel] [PATCH 1/2] MdeModulePkg/DxeCore/Image: make local functions STATIC
 
Use static linkage for functions that are only used locally, to help
the compiler optimize away unused code in non-LTO builds.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
---
 MdeModulePkg/Core/Dxe/Image/Image.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c
index d86da89ee704..aae2c1eaa516 100644
--- a/MdeModulePkg/Core/Dxe/Image/Image.c
+++ b/MdeModulePkg/Core/Dxe/Image/Image.c
@@ -86,6 +86,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED MACHINE_TYPE_INFO  mMachineTypeInfo[] = {
 
 UINT16 mDxeCoreImageMachineType = 0;
 
+#ifndef MDEPKG_NDEBUG
 /**
  Return machine type name.
 
@@ -93,6 +94,7 @@ UINT16 mDxeCoreImageMachineType = 0;
 
  @return machine type name
 **/
+STATIC
 CHAR16 *
 GetMachineTypeName (
   UINT16 MachineType
@@ -108,6 +110,7 @@ GetMachineTypeName (
 
   return L"<Unknown>";
 }
+#endif
 
 /**
   Notification event handler registered by CoreInitializeImageServices () to
@@ -286,6 +289,7 @@ CoreInitializeImageServices (
                                  into buffer.
 
 **/
+STATIC
 EFI_STATUS
 EFIAPI
 CoreReadImageFile (
@@ -334,6 +338,7 @@ CoreReadImageFile (
   @retval EFI_SUCCESS              The memory range the image will be loaded in is available
   @retval EFI_NOT_FOUND            The memory range the image will be loaded in is not available
 **/
+STATIC
 EFI_STATUS
 CheckAndMarkFixLoadingMemoryUsageBitMap (
   IN  EFI_PHYSICAL_ADDRESS          ImageBase,
@@ -407,6 +412,7 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
   @retval EFI_NOT_FOUND             The image has no assigned fixed loading address.
 
 **/
+STATIC
 EFI_STATUS
 GetPeCoffImageFixLoadingAssignedAddress(
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext
@@ -552,6 +558,7 @@ CoreIsImageTypeSupported (
   @retval EFI_BUFFER_TOO_SMALL    Buffer for image is too small
 
 **/
+STATIC
 EFI_STATUS
 CoreLoadPeImage (
   IN BOOLEAN                     BootPolicy,
@@ -877,6 +884,7 @@ CoreLoadPeImage (
   @return Return the image private data associated with ImageHandle.
 
 **/
+STATIC
 LOADED_IMAGE_PRIVATE_DATA *
 CoreLoadedImageInfo (
   IN EFI_HANDLE  ImageHandle
@@ -909,6 +917,7 @@ CoreLoadedImageInfo (
   @param  FreePage                Free allocated pages
 
 **/
+STATIC
 VOID
 CoreUnloadAndCloseImage (
   IN LOADED_IMAGE_PRIVATE_DATA  *Image,
@@ -1105,6 +1114,7 @@ CoreUnloadAndCloseImage (
                                   platform policy specifies that the image should not be started.
 
 **/
+STATIC
 EFI_STATUS
 CoreLoadImageCommon (
   IN  BOOLEAN                          BootPolicy,
--
2.17.1