> On Nov 4, 2014, at 5:48 AM, Laszlo Ersek <ler...@redhat.com> wrote:
> 
> diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c
> b/MdePkg/Library/BasePrintLib/PrintLibInternal.c
> index 8dc5ec7..fbb3726 100644
> --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c
> +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c
> @@ -680,10 +680,20 @@ BasePrintLibSPrintMarker (
>         if (TmpGuid == NULL) {
>           ArgumentString = "<null guid>";
>         } else {
> +          UINTN (EFIAPI * volatile PrintFunction) (
> +                                     OUT CHAR8        *StartOfBuffer,
> +                                     IN  UINTN        BufferSize,
> +                                     IN  UINTN        Flags,
> +                                     IN  CONST CHAR8  *FormatString,
> +                                     ...
> +                                     );
> +
> +          PrintFunction = BasePrintLibSPrint;
> +
>           GuidData1 = ReadUnaligned32 (&(TmpGuid->Data1));
>           GuidData2 = ReadUnaligned16 (&(TmpGuid->Data2));
>           GuidData3 = ReadUnaligned16 (&(TmpGuid->Data3));
> -          BasePrintLibSPrint (
> +          PrintFunction (
>             ValueBuffer,
>             MAXIMUM_VALUE_CHARACTERS,
>             0,
> ----------------
> 
> With this patch, GUIDs are printed okay with -Os.
> 
> (Of course it's not edk2 that needs to be fixed.)
> 

But pedantically you need change the definition of BasePrintLibSPrint() to 
include EFIAPI. 

If you look at BasePrintLibSPrintMarker() (and some of the other routines) you 
will notice a BASE_LIST and a VA_LIST. We had an API that exposed a VA_LIST 
(well code that was casting to VA_LIST) in the report status code stack and it 
forced use to use our own made up BASE_LIST concept to get it to work. I think 
you are going to hit similar issues mixing calling conventions. 

So my 1st question is why do you need to mix calling conventions, and depend on 
EFIAPI for interoperability. Why not just change the ABI on all functions?

Problems with the mixed calling convention:
1) All assembly routines must be marked as EFIAPI, or the C code will generate 
the wrong calling convention. Not an issue in the MdePkg, but potentially an 
issue in other packages. 
2) The var arg chain needs to be constant. I think for i386 you get lucky and 
the calling conventions are close enough it kind of works, but for X64 they are 
very different. Even if you force VA_LIST to be the Microsoft one, it is not 
clear to me that forces the compiler to treat every … the Microsoft way. 

Thanks,

Andrew Fish

------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to