Skip to content

Commit dcfa3bd

Browse files
committed
zero out bss section in _start
1 parent 7919692 commit dcfa3bd

File tree

1 file changed

+12
-1
lines changed
  • library/std/src/sys/pal/vexos

1 file changed

+12
-1
lines changed

library/std/src/sys/pal/vexos/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,29 @@ pub mod thread_local_key;
2424
#[path = "../unsupported/time.rs"]
2525
pub mod time;
2626

27-
use crate::arch::asm;
27+
use crate::{arch::asm, ptr::{self, addr_of_mut}};
2828

2929
#[cfg(not(test))]
3030
#[no_mangle]
3131
#[link_section = ".text.boot"]
3232
pub unsafe extern "C" fn _start() -> ! {
3333
extern "C" {
34+
static mut __bss_start: u8;
35+
static mut __bss_end: u8;
36+
3437
fn main() -> i32;
3538
}
3639

3740
asm!("ldr sp, =__stack_top", options(nostack));
3841

42+
ptr::slice_from_raw_parts_mut(
43+
addr_of_mut!(__bss_start),
44+
addr_of_mut!(__bss_end).offset_from(addr_of_mut!(__bss_start)) as usize,
45+
)
46+
.as_mut()
47+
.unwrap_unchecked()
48+
.fill(0);
49+
3950
main();
4051

4152
abort_internal()

0 commit comments

Comments
 (0)