Skip to content

Commit a1f7aa8

Browse files
committed
toolchain: bump rust toolchain version
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
1 parent b985a5b commit a1f7aa8

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

defs/x86_64-hm-linker.ld

+12
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,29 @@ SECTIONS
8282
*(".text")
8383
*(".text.*")
8484
*(".text$")
85+
*(".ltext")
86+
*(".ltext.*")
87+
*(".ltext$")
8588
}
8689

8790
.data : AT(ADDR(.data) - KERNEL_OFFSET)
8891
{
8992
*(".data")
9093
*(".data.*")
9194
*(".data$")
95+
*(".ldata")
96+
*(".ldata.*")
97+
*(".ldata$")
9298
}
9399

94100
.bss : AT(ADDR(.bss) - KERNEL_OFFSET)
95101
{
96102
PROVIDE (___BSS_START__ = .);
97103
*(".bss")
104+
*(".lbss")
98105
*(".bss.*")
106+
*(".lbss.*")
107+
*(".lbss$")
99108
PROVIDE (___BSS_END__ = .);
100109
}
101110

@@ -104,6 +113,9 @@ SECTIONS
104113
*(".rodata")
105114
*(".rodata$")
106115
*(".rodata.*")
116+
*(".lrodata")
117+
*(".lrodata$")
118+
*(".lrodata.*")
107119
}
108120

109121
PROVIDE (___KERNEL_PM_END__ = . - KERNEL_OFFSET);

src/arch/x86_64/interrupt/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ extern "C" {
2727
// [48:63] - addr[16:31]
2828
// [64:95] - addr[32:63]
2929
#[repr(C)]
30+
#[repr(packed)]
3031
pub struct GateDescriptor64 {
3132
pub offset_1: u16,
3233
pub selector: u16,

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![allow(dead_code)]
22
#![allow(unused_imports)]
3+
#![allow(unexpected_cfgs)]
34
#![no_std]
45
#![no_main]
56
#![feature(const_option)]

0 commit comments

Comments
 (0)