Skip to content

Commit

Permalink
toolchain: bump rust toolchain version
Browse files Browse the repository at this point in the history
1. allow unexpected cfgs in lib.rs, in this case
   "no_global_oom_handling" is cause warnings [1]

2. for large code models the compiler (rust linkers) now put code and
   data in `.ltext`, `.ldata`, `.lbss`, `.lrodata` instead of the
   same `.text` , `.data` ... etc. We are adjusting accordingly in the
   linker script.

3. unsafe assertions identified undefined behaviours, in this case a repr(C)
   struct was not mared as repr(packed), therefore having an unexpected
   size. The unsafe assertions was not enabled by default in debug
   builds so the idt setup code with from_raw_parts_mut() has been
   working on UB. Glad we can catch this....

related: [1] rust-lang/rust#123501
related: [2] https://blog.rust-lang.org/2024/05/02/Rust-1.78.0.html#asserting-unsafe-preconditions
  • Loading branch information
shrik3 committed Jun 4, 2024
1 parent b985a5b commit a1f7aa8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions defs/x86_64-hm-linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,29 @@ SECTIONS
*(".text")
*(".text.*")
*(".text$")
*(".ltext")
*(".ltext.*")
*(".ltext$")
}

.data : AT(ADDR(.data) - KERNEL_OFFSET)
{
*(".data")
*(".data.*")
*(".data$")
*(".ldata")
*(".ldata.*")
*(".ldata$")
}

.bss : AT(ADDR(.bss) - KERNEL_OFFSET)
{
PROVIDE (___BSS_START__ = .);
*(".bss")
*(".lbss")
*(".bss.*")
*(".lbss.*")
*(".lbss$")
PROVIDE (___BSS_END__ = .);
}

Expand All @@ -104,6 +113,9 @@ SECTIONS
*(".rodata")
*(".rodata$")
*(".rodata.*")
*(".lrodata")
*(".lrodata$")
*(".lrodata.*")
}

PROVIDE (___KERNEL_PM_END__ = . - KERNEL_OFFSET);
Expand Down
1 change: 1 addition & 0 deletions src/arch/x86_64/interrupt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern "C" {
// [48:63] - addr[16:31]
// [64:95] - addr[32:63]
#[repr(C)]
#[repr(packed)]
pub struct GateDescriptor64 {
pub offset_1: u16,
pub selector: u16,
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unexpected_cfgs)]
#![no_std]
#![no_main]
#![feature(const_option)]
Expand Down

0 comments on commit a1f7aa8

Please sign in to comment.