I made disassembler of the program and found the follow:
This routine
----------
UINTN
EFIAPI
AsciiPrint (
  IN CONST CHAR8  *Format,
  ...
  )
{
  VA_LIST Marker;
  UINTN   Return;
  ASSERT (Format != NULL);

  VA_START (Marker, Format);

  Return = AsciiInternalPrint( Format, gST->ConOut, Marker);

  VA_END (Marker);

  return Return;
}

----------
compiled by clang as
---------
                                       ; Basic Block Input Regs: rcx -  Killed 
Regs: rax rdx rsp rbp r8
                                            sub_1a5d:
0000000000001a5d 55                              push       rbp                 
          ; XREF=0x1acc
0000000000001a5e 4889E5                          mov        rbp, rsp
0000000000001a61 4883EC30                        sub        rsp, 0x30
0000000000001a65 48894DF8                        mov        qword 
[ss:rbp-0x30+var_40], rcx
0000000000001a69 4C8D4500                        lea        r8, qword 
[ss:rbp-0x30+var_48]
0000000000001a6d 488B051C050000                  mov        rax, qword 
[ds:0x1f90]
0000000000001a74 488B5040                        mov        rdx, qword 
[ds:rax+0x40]
0000000000001a78 E86FFFFFFF                      call       sub_19ec
0000000000001a7d 4883C430                        add        rsp, 0x30
0000000000001a81 5D                              pop        rbp
0000000000001a82 C3                              ret        
                        ; endp

---------
This is wrong because value in rdx is dropped at addr 1a74 while it should 
contain the second argument.
I may propose that Clang see only one argument and doesn't bother about second.
What should we change to make c-sources to be compatible with Clang?

Sergey

On 04.09.2014, at 22:17, Sergey Isakov wrote:

> Hi Andrew,
> One more problem with Clang compilation.
> I modified MdeModulePkg/Application/HelloWorld/HelloWorld.c with two lines
> ———
> 
>   Index = 1234;
>   AsciiPrint("Index=%d\n", Index);
> 
> ——
> 
> And compile it with GCC49 and with Clang.
> First printed 1234, second printed address instead of value
> 
> <Screen Shot 2014-09-04 at 22.12.43.png>
> Sergey
> 
> On 01 сент. 2014 г., at 21:43, Sergey Isakov <[email protected]> wrote:
> 
>> Hi,
>> QvmfPkg compiled by XCODE5 to RELEASE works with Qemu 2.1.0 !
>> Great!
>> Sergey
>> 
>> 
>> On 01 сент. 2014 г., at 11:09, Sergey Isakov <[email protected]> wrote:
>> 
>>> Hi Andrew,
>>> your patches are good. I tested CpuExceptionHandler.lib and Thunk16.nasm in 
>>> Ovmf+Qemu2.0 compiled by GCC49. Works fine!
>>> But with XCLANG (Xcode 4.4.1) I got an error
>>> ------
>>> qemu: fatal: Trying to execute code outside RAM or ROM at 0x00000000000a0000
>>> 
>>> RAX=0000000000000000 RBX=00000000fffcc0e4 RCX=800000000000000e 
>>> RDX=000000007ff95df8
>>> RSI=00000000fffd6104 RDI=0000000000005042 RBP=000000007ff5b9a0 
>>> RSP=000000007ff5b930
>>> R8 =000000007fe75d70 R9 =000000007fe75d88 R10=0000000000000000 
>>> R11=0000000000000000
>>> R12=0000000000000000 R13=0000000000000000 R14=0000000000000000 
>>> R15=0000000000000000
>>> RIP=000000000009ffbe RFL=00000046 [---Z-P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
>>> ES =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
>>> CS =0018 0000000000000000 ffffffff 00af9b00 DPL=0 CS64 [-RA]
>>> SS =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
>>> DS =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
>>> FS =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
>>> GS =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
>>> LDT=0000 0000000000000000 0000ffff 00008200 DPL=0 LDT
>>> TR =0000 0000000000000000 0000ffff 00008b00 DPL=0 TSS64-busy
>>> GDT=     00000000ffffff80 0000001f
>>> IDT=     000000007c01fd58 0000021f
>>> CR0=80000033 CR2=0000000000000000 CR3=000000007fefa000 CR4=00000660
>>> DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 
>>> DR3=0000000000000000 
>>> DR6=00000000ffff0ff0 DR7=0000000000000400
>>> CCS=0000000000000000 CCD=0000000000000000 CCO=ADDB    
>>> EFER=0000000000000500
>>> FCW=037f FSW=0000 [ST=0] FTW=00 MXCSR=00001f80
>>> FPR0=0000000000000000 0000 FPR1=0000000000000000 0000
>>> FPR2=0000000000000000 0000 FPR3=0000000000000000 0000
>>> FPR4=0000000000000000 0000 FPR5=0000000000000000 0000
>>> FPR6=0000000000000000 0000 FPR7=0000000000000000 0000
>>> XMM00=00000000000000000000000000000000 
>>> XMM01=00000000000000000000000000000000
>>> XMM02=00000000000000000000000000000000 
>>> XMM03=00000000000000000000000000000000
>>> XMM04=00000000000000000000000000000000 
>>> XMM05=00000000000000000000000000000000
>>> XMM06=00000000000000000000000000000000 
>>> XMM07=00000000000000000000000000000000
>>> XMM08=00000000000000000000000000000000 
>>> XMM09=00000000000000000000000000000000
>>> XMM10=00000000000000000000000000000000 
>>> XMM11=00000000000000000000000000000000
>>> XMM12=00000000000000000000000000000000 
>>> XMM13=00000000000000000000000000000000
>>> XMM14=00000000000000000000000000000000 
>>> XMM15=00000000000000000000000000000000
>>> Abort trap: 6
>>> 
>>> -------
>>> I will debug the issue and it will take me a time.
>>> Just an error with GCC
>>> -----
>>> X64/ExceptionHandlerAsm.iii:32: Error: alignment not a power of 2
>>> -----
>>> Should be there align32?
>>> ---------
>>>  #EXTRN ASM_PFX(mDoFarReturnFlag):QWORD  # Do far return flag
>>>  .text
>>> +.align 3
>>>  
>>>  #
>>> ---------
>>> 
>>> After that I may recommend these patches to be committed into trunk.
>>> 
>>> Thanks for the great work!
>>> Sergey
>>> 
>>> 
>>> On 30.08.2014, at 3:53, Andrew Fish wrote:
>>> 
>>>> With these 3 patches you can boot the EFI shell X64 Ovmf on Mac OS X using 
>>>> Xcode 5.
>>>> [edk2] [OvmfPkg][Review] Use XCODE5 toolchain for current and future OS X 
>>>> versions
>>>> [edk2] [SourceLevelDebugPkg] Code review: Compile/link with clang/Xcode 5
>>>> [UefiCpuPkg][CpuExceptionHandlerLib] Make self modifying code work with 
>>>> Xcode
>>>> 
>>>> OvmfPkg/build.sh -a X64
>>>> OvmfPkg/build.sh -a X64 qemu -debugcon file:debug.log -global 
>>>> isa-debugcon.iobase=0x402  -monitor stdio -no-reboot -no-shutdown -s 
>>>> -singlestep
>>>> 
>>>> I was forced to install nasm, and you MUST set NASM_PREFIX to the install 
>>>> location of nasm. Xcode ships with a very old version of nasm in 
>>>> /usr/bin/nasm.
>>>> 
>>>> You get errors trying to assemble the SEC with the Xcode nasm (It looks 
>>>> like it is missing some needed features).
>>>> Ia32/Flat32ToFlat64.asm:38: warning: numeric constant 0x100000000 does not 
>>>> fit in 32 bits
>>>> Ia32/Flat32ToFlat64.asm:39: error: `64' is not a valid segment size; must 
>>>> be 16 or 32
>>>> Ia16/Real16ToFlat32.asm:40: warning: numeric constant 0x100000000 does not 
>>>> fit in 32 bits
>>>> Ia16/Real16ToFlat32.asm:62: warning: numeric constant 0x100000000 does not 
>>>> fit in 32 bits
>>>> Main.asm:78: error: `64' is not a valid segment size; must be 16 or 32
>>>> 
>>>> Thanks,
>>>> 
>>>> Andrew Fish
>>>> 
>>>> PS. Sorry I omitted Contributed-under, and Signed-off-by from some of the 
>>>> patch mails. It has been a long week.
>>>> 
>>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>>> Signed-off-by: Anderw Fish <[email protected]>
>>>> 
>>>> ------------------------------------------------------------------------------
>>>> Slashdot TV.  
>>>> Video for Nerds.  Stuff that matters.
>>>> http://tv.slashdot.org/_______________________________________________
>>>> edk2-devel mailing list
>>>> [email protected]
>>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>>> 
>>> ------------------------------------------------------------------------------
>>> Slashdot TV.  
>>> Video for Nerds.  Stuff that matters.
>>> http://tv.slashdot.org/_______________________________________________
>>> edk2-devel mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>> 
>> ------------------------------------------------------------------------------
>> Slashdot TV.  
>> Video for Nerds.  Stuff that matters.
>> http://tv.slashdot.org/_______________________________________________
>> edk2-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
> 
> ------------------------------------------------------------------------------
> Slashdot TV.  
> Video for Nerds.  Stuff that matters.
> http://tv.slashdot.org/_______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to