Rust UEFI
Re: Rust UEFI
Linkers work at the level of sections when deciding what to include in their output. "Function sections" (-ffunction-sections) is an option that Rust enables in LLVM to put each function in its own section, enabling the linker (with another option, --gc-sections) to leave out unused functions in the final binary.
This is mostly helpful in userspace applications that link large libraries they only need part of, and is only supported by some linkers (e.g. not MSVC's link.exe, if you happen to be using that for UEFI). You can disable it by passing this to rustc: -C llvm-args=-fno-function-sections
This is mostly helpful in userspace applications that link large libraries they only need part of, and is only supported by some linkers (e.g. not MSVC's link.exe, if you happen to be using that for UEFI). You can disable it by passing this to rustc: -C llvm-args=-fno-function-sections
Re: Rust UEFI
Thanks for the answer. I don't use link.exe, I link with x86_64-efi-pe-ld from binutils. So, I should not care about this issue.
Re: Rust UEFI
Well, you will be able to use --gc-sections with that linker, but you're still using the PE format so you may still run into the limit depending on how much you try to do in your bootloader. I would just keep that in mind for the future and leave -ffunction-sections on for now.
Re: Rust UEFI
UEFI apps are executables in PE format, which can contain up to 64k sections. If you plan to have more functions than that, you have to enable that option.