I really like the code simplification! Just 2 comments below:

1. Can you describe the calling flow explicitly in commit message:
  CoreLoadImage (public api) -> CoreLoadImageCommon -> CoreLoadPeImage

2. You added "static" to CoreLoadImageCommon but didn't add to CoreLoadPeImage.
I think you are trying to guarantee no lib implementation that silently calls 
to the
internal functions like CoreLoadImageCommon.
But, why?
Without adding "static", the linking still fails if there is such lib 
implementation because
of the function prototype change. An error such as "parameter mismatch" would 
appear.
And if there is a reason for adding "static", why not add that to 
CoreLoadPeImage as well?

Thanks,
Ray

> -----Original Message-----
> From: Ard Biesheuvel <a...@kernel.org>
> Sent: Monday, May 29, 2023 6:17 PM
> To: devel@edk2.groups.io
> Cc: Ard Biesheuvel <a...@kernel.org>; Ni, Ray <ray...@intel.com>; Yao, Jiewen
> <jiewen....@intel.com>; Gerd Hoffmann <kra...@redhat.com>; Taylor Beebe
> <t...@taylorbeebe.com>; Oliver Smith-Denny <o...@smith-denny.com>; Bi, Dandan
> <dandan...@intel.com>; Gao, Liming <gaolim...@byosoft.com.cn>; Kinney,
> Michael D <michael.d.kin...@intel.com>; Leif Lindholm
> <quic_llind...@quicinc.com>; Michael Kubacki <mikub...@linux.microsoft.com>
> Subject: [RFC PATCH 01/11] MdeModulePkg/DxeCore: Remove unused
> 'EntryPoint' argument to LoadImage
> 
> CoreLoadImageCommon's only user passes NULL for its EntryPoint argument,
> so it has no purpose and can simply be dropped. While at it, make
> CoreLoadImageCommon STATIC to prevent it from being accessed from other
> translation units.
> 
> Signed-off-by: Ard Biesheuvel <a...@kernel.org>
> ---
>  MdeModulePkg/Core/Dxe/Image/Image.c | 17 +++--------------
>  1 file changed, 3 insertions(+), 14 deletions(-)
> 
> diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c
> b/MdeModulePkg/Core/Dxe/Image/Image.c
> index 9dbfb2a1fad22ced..2f2dfe5d0496dc4f 100644
> --- a/MdeModulePkg/Core/Dxe/Image/Image.c
> +++ b/MdeModulePkg/Core/Dxe/Image/Image.c
> @@ -560,7 +560,6 @@ CoreIsImageTypeSupported (
>    @param  Pe32Handle              The handle of PE32 image
> 
>    @param  Image                   PE image to be loaded
> 
>    @param  DstBuffer               The buffer to store the image
> 
> -  @param  EntryPoint              A pointer to the entry point
> 
>    @param  Attribute               The bit mask of attributes to set for the 
> load
> 
>                                    PE image
> 
> 
> 
> @@ -577,7 +576,6 @@ CoreLoadPeImage (
>    IN VOID                       *Pe32Handle,
> 
>    IN LOADED_IMAGE_PRIVATE_DATA  *Image,
> 
>    IN EFI_PHYSICAL_ADDRESS       DstBuffer    OPTIONAL,
> 
> -  OUT EFI_PHYSICAL_ADDRESS      *EntryPoint  OPTIONAL,
> 
>    IN  UINT32                    Attribute
> 
>    )
> 
>  {
> 
> @@ -810,13 +808,6 @@ CoreLoadPeImage (
>      }
> 
>    }
> 
> 
> 
> -  //
> 
> -  // Fill in the entry point of the image if it is available
> 
> -  //
> 
> -  if (EntryPoint != NULL) {
> 
> -    *EntryPoint = Image->ImageContext.EntryPoint;
> 
> -  }
> 
> -
> 
>    //
> 
>    // Print the load address and the PDB file name if it is available
> 
>    //
> 
> @@ -1111,7 +1102,6 @@ CoreUnloadAndCloseImage (
>                                    this parameter contains the required 
> number.
> 
>    @param  ImageHandle             Pointer to the returned image handle that 
> is
> 
>                                    created when the image is successfully 
> loaded.
> 
> -  @param  EntryPoint              A pointer to the entry point
> 
>    @param  Attribute               The bit mask of attributes to set for the 
> load
> 
>                                    PE image
> 
> 
> 
> @@ -1134,6 +1124,7 @@ CoreUnloadAndCloseImage (
>                                    platform policy specifies that the image 
> should not be started.
> 
> 
> 
>  **/
> 
> +STATIC
> 
>  EFI_STATUS
> 
>  CoreLoadImageCommon (
> 
>    IN  BOOLEAN                   BootPolicy,
> 
> @@ -1144,7 +1135,6 @@ CoreLoadImageCommon (
>    IN  EFI_PHYSICAL_ADDRESS      DstBuffer           OPTIONAL,
> 
>    IN OUT UINTN                  *NumberOfPages      OPTIONAL,
> 
>    OUT EFI_HANDLE                *ImageHandle,
> 
> -  OUT EFI_PHYSICAL_ADDRESS      *EntryPoint         OPTIONAL,
> 
>    IN  UINT32                    Attribute
> 
>    )
> 
>  {
> 
> @@ -1375,9 +1365,9 @@ CoreLoadImageCommon (
>    }
> 
> 
> 
>    //
> 
> -  // Load the image.  If EntryPoint is Null, it will not be set.
> 
> +  // Load the image.
> 
>    //
> 
> -  Status = CoreLoadPeImage (BootPolicy, &FHand, Image, DstBuffer, EntryPoint,
> Attribute);
> 
> +  Status = CoreLoadPeImage (BootPolicy, &FHand, Image, DstBuffer, Attribute);
> 
>    if (EFI_ERROR (Status)) {
> 
>      if ((Status == EFI_BUFFER_TOO_SMALL) || (Status ==
> EFI_OUT_OF_RESOURCES)) {
> 
>        if (NumberOfPages != NULL) {
> 
> @@ -1559,7 +1549,6 @@ CoreLoadImage (
>               (EFI_PHYSICAL_ADDRESS)(UINTN)NULL,
> 
>               NULL,
> 
>               ImageHandle,
> 
> -             NULL,
> 
>               EFI_LOAD_PE_IMAGE_ATTRIBUTE_RUNTIME_REGISTRATION |
> EFI_LOAD_PE_IMAGE_ATTRIBUTE_DEBUG_IMAGE_INFO_TABLE_REGISTRATION
> 
>               );
> 
> 
> 
> --
> 2.39.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105405): https://edk2.groups.io/g/devel/message/105405
Mute This Topic: https://groups.io/mt/99197133/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: 
https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to