Thanks for the reply, Octocontrabass.
In fact, I'm seeing this issue in QEMU (qemu-system-x86_64 with an OMVF-pure-efi.fd from August 2021), but not on my motherboard's UEFI firmware.
I've been mucking about with my build system a bit and am unable to reproduce exactly what I described above, but I've got a simpler failure case now:
Code:
#include <uefi.h>
int main(int argc, char** argv) {
exit_bs();
return 0;
}
In QEMU's "serial0" output, I see "#UD - Invalid Opcode". I saw a previous thread in which someone mentioned this could be due to the use of SSE instructions that are emitted when dealing with variadics, but neither the lack of any printf() usage, nor ensuring -mno-sse and -mno-sse2 were added, have resolved this issue. I do have hope, though, since it's only in QEMU, though admittedly I'm a bit confused.
Here's QEMU's exception output:
https://ibb.co/z4rWtF9Here's an affected binary built in my environment with code pasted above:
https://ufile.io/fh0oiho0Here's a sample compiler invocation when building POSIX-UEFI itself:
Code:
gcc -g -fshort-wchar -fno-strict-aliasing -ffreestanding -fno-stack-protector -fno-stack-check -I. -I./uefi -I/usr/include -I/usr/include/efi -I/usr/include/efi/protocol -I/usr/include/efi/x86_64 -D__x86_64__ -DHAVE_USE_MS_ABI -mno-red-zone -maccumulate-outgoing-args -Wno-builtin-declaration-mismatch -fpic -fPIC -c stdlib.c -o stdlib.o
Here's the invocation when building my subproject:
Code:
gcc -g -fshort-wchar -fno-strict-aliasing -ffreestanding -fno-stack-protector -fno-stack-check -I. -I./uefi -I/usr/include -I/usr/include/efi -I/usr/include/efi/protocol -I/usr/include/efi/x86_64 -D__x86_64__ -DHAVE_USE_MS_ABI -mno-red-zone -maccumulate-outgoing-args -Wno-builtin-declaration-mismatch -fpic -fPIC -c main.c -o main.o
ld -nostdlib -shared -Bsymbolic -Luefi uefi/crt_x86_64.o main.o -o BOOTX64.EFI.so -luefi -T uefi/elf_x86_64_efi.lds
Thanks once again for your time and input =)