Files
rust/library/std
Jonathan Brouwer b0c172e40d Rollup merge of #163960 - vexide:tropicaaal/asm-bss-clear, r=hanna-kruppe
vexos: clear .bss from assembly

On `target_os = "vexos"`, libstd is responsible for clearing the `.bss` section during runtime initialization. This PR moves that step from Rust (previously done via `core::ptr::write_bytes`) to some assembly that runs even earlier into execution.

The previous approach was sketchy at best when considering soundness, because:
- Pointer provenance (probably) makes this UB since `.bss` lives inside the bounds of the abstract machine and we'd be writing to memory that will eventually hold statics. I have no idea how this plays out in practice, especially because it's a linkerscript symbol which isn't an actual value.
- `core::ptr::write_bytes` gets lowered to a memclr intrinsic, which may access `.bss` depending on how its [implemented](7f5edc1fc0/compiler-builtins/src/arm.rs (L248)) in `compiler-rt`.
- On debug profiles, UB precondition checks might cause problems depending on what's being asserted before the runtime environment is sane.

Anyways, for peace-of-mind it's much better to do this from assembly. The compiler changes here are trivial, just a change to the linkerscript to ensure that `__bss_start` gets aligned to a 4-byte boundary.
2026-10-08 21:50:08 +02:00
..
…