blog_os icon indicating copy to clipboard operation
blog_os copied to clipboard

Consider switching to new `x86_64-unknown-none` target

Open Aaron1011 opened this issue 2 years ago • 6 comments

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.

Aaron1011 avatar Dec 29 '21 22:12 Aaron1011

Stablised today in 1.58

thejpster avatar Jan 13 '22 17:01 thejpster

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.

phil-opp avatar Jan 13 '22 18:01 phil-opp

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.

ethindp avatar Jan 14 '22 23:01 ethindp

Why is -Crelocation-model=static rediculous? That is the relocation model currently used by blog os.

bjorn3 avatar Jan 14 '22 23:01 bjorn3

@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.

ethindp avatar Jan 15 '22 02:01 ethindp

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.

phil-opp avatar Apr 10 '22 11:04 phil-opp