I'm experimenting with programming bare-metal embedded systems in Rust. One of the things that is typically done in C startup code is zero-initializing the BSS segment for any global or static uninitialized variables.
However, in Rust, I can't figure out how to create any global or static uninitialized variables (even using unsafe
code). In other words, I can't figure out how to write any Rust code so the compiler will populate the BSS segment with something.
I tried...
static BSS_Data: i32 = unsafe { core::mem::uninitialized() };
....but the compiler rejected it.
Is there any way to write Rust code (unsafe
or otherwise) that will result in a populated BSS segment? Is the BSS segment guaranteed to always be empty in any program written entirely in Rust?