On Tue, 30 May 2023 at 07:54, Ni, Ray <ray...@intel.com> wrote: > > 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 >
Ok > 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. This function is not declared in a header, so any existing user would carry its own EXTERN declaration. So the compiler would not notice, and the linker does not verify protoype compatibility, so we would only notice this at runtime. I am not aware of any downstream platforms that do such a thing, so perhaps I am being overly cautious. But generally, functions should be STATIC unless there is a need for them to have external linkage, and changing the prototype is a reasonable justification IMHO for adding it at this point. > And if there is a reason for adding "static", why not add that to > CoreLoadPeImage as well? > This is added in the next patch. > > > -----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 (#105423): https://edk2.groups.io/g/devel/message/105423 Mute This Topic: https://groups.io/mt/99197133/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-