Windows x86_64 ABI issue with va_list

I think I’m seeing some Windows ABI code gen issues. My guess is it is related to having the va_start key off an argument that is not in a register. Most of my EFI firmware code runs fine, but the new EFI shell crashes all over the place and prints out lots of garbage. Here is the gist of the print function:

ShellPrintHiiEx (
int Col,
int Row,
const char *Language,
const void *HiiFormatStringId,
const void *HiiFormatHandle,

VA_LIST Marker;
int Value;

VA_START (Marker, HiiFormatHandle);
Value = ReturnMarker (Marker);

return Value;

The Windows compiler spills the arguments passed in registers back to the the callers stack frame per the ABI. The clang version spills locally?

_ShellPrintHiiEx: ## @ShellPrintHiiEx


pushq %rbp
movq %rsp, %rbp
subq $80, %rsp
movq 48(%rbp), %rax
movl %ecx, -4(%rbp)
movl %edx, -8(%rbp)
movq %r8, -16(%rbp)
movq %r9, -24(%rbp)
movq %rax, -32(%rbp)
leaq -24(%rbp), %rax
movq %rax, -40(%rbp)
movq %rax, %rcx
callq _ReturnMarker
movl %eax, -44(%rbp)
movq $0, -40(%rbp)
movl -44(%rbp), %eax
addq $80, %rsp
popq %rbp

Also I can’t figure out what this code is doing in main()

movl $0, -4(%rbp)

Andrew Fish

clang -ccc-host-triple x86_64-pc-win32-macho -S v.c

v.c (2.94 KB)

v.s (5.1 KB)