blog_os
blog_os copied to clipboard
Consider switching to new `x86_64-unknown-none` target
Rust recently added a Tier-3 x86_64-unknown-none
target: https://github.com/rust-lang/rust/pull/89062
I believe it should be possible to use this target instead of the custom x86_64-blog_os.json
target. It's designed to support bare-metal x86_64 code (like operating systems), and the target definition looks almost identical to x86_64-blog_os.json
. It should be possible to address any differences via -C
flags.
Stablised today in 1.58
Awesome! I'll try to switch the blog to it when I have some time. I think we are still having some problems with loading PIC code in the bootloader crate (https://github.com/rust-osdev/bootloader/pull/206#issuecomment-1008446687), but this might be avoidable using -C
flags as @Aaron1011 mentioned.
I should note that I have tried using -C relocation-model=pie
with no success, and -C relocation-model=static
is a bit of a ridiculous idea IMO.
Why is -Crelocation-model=static
rediculous? That is the relocation model currently used by blog os.
@bjorn3 Really? I didn't know that. I assumed that it used PIE. No wonder my change to have it use PIE didn't work. As for it being ridiculous, I guess I look at it from a security standpoint: if the relocation model is static it means that once you know where the kernel has been loaded into memory, you instantly can determine where all the variables are and all that trivially. I didn't know that static was the relocation model that blog_os used though. PIC will be pretty nice to have, and same for ASLR once its added.
Quick update: This will be part of the upcoming third edition. It is now even a Tier 2 target, which means that it's installable through rustup
, so -Zbuild-std
is no longer necessary.