Rust UEFI

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
vlad9486
Posts: 14
Joined: Thu Jan 24, 2013 9:05 am

Rust UEFI

Post by vlad9486 »

Here http://wiki.osdev.org/Rust_Bare_Bones suggested to disable function sections in rustc. What does it mean and how can I do this?
User avatar
Rusky
Member
Member
Posts: 792
Joined: Wed Jan 06, 2010 7:07 pm

Re: Rust UEFI

Post by Rusky »

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
vlad9486
Posts: 14
Joined: Thu Jan 24, 2013 9:05 am

Re: Rust UEFI

Post by vlad9486 »

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.
User avatar
Rusky
Member
Member
Posts: 792
Joined: Wed Jan 06, 2010 7:07 pm

Re: Rust UEFI

Post by Rusky »

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.
Boris
Member
Member
Posts: 145
Joined: Sat Nov 07, 2015 3:12 pm

Re: Rust UEFI

Post by Boris »

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.
Post Reply