zig
zig copied to clipboard
Linker warning when compilng with x86_64-uefi-gnu target
Ever since 0.7.0 (though it added the warning(link): unexpected LLD stderr part in 0.7.1), I've been getting the following warning from zig when compiling with x86_64-uefi-gnu target:
warning(link): unexpected LLD stderr:
lld-link: warning: /align specified without /driver; image may not run
This doesn't seem to have an effect on my program, but not sure if this can cause issues. I know /ALIGN is set to 32 when zig calls out to LLD for UEFI, but not sure why (the fact that this overrides the default 4096 alignment has been a pain point in the past, but I've since worked around that): https://github.com/ziglang/zig/blob/ae3fd86dcc6f39601aa26ce1a6dc51a0db5cbf30/src/link/Coff.zig#L1042
The linker is right, here's a quote from MSVC's linker docs:
The /ALIGN option specifies the alignment of each section within the linear address space of the program. The number argument is in bytes and must be a power of two. The default is 4K (4096). The linker issues a warning if the alignment produces an invalid image.
Unless you are writing an application such as a device driver, you should not need to modify the alignment.
~I think the reason for putting that alignment value is detailed here:~
EFI ByteCode (EBC) files must be compiled using the /ALIGN:32 flag for processing to succeed.
Scrap that, we're not producing SBC.
Does this have anything to do? https://github.com/tianocore/edk2/blob/c6720db5ddffec747bb0b2830e528511b1a4bfb2/OvmfPkg/OvmfPkgIa32X64.dsc#L116