rust-lang / unsafe-code-guidelines

Forum for discussion about what unsafe code can and can't do
https://rust-lang.github.io/unsafe-code-guidelines
Apache License 2.0
658 stars 57 forks source link

What about: Targets where NULL is a valid pointer #29

Open RalfJung opened 6 years ago

RalfJung commented 6 years ago

This recently came up in a discussion. To my knowledge, LLVM has a pretty hard-coded assumption that for address space 0, NULL is never inbounds (let alone dereferencable), so we cannot actually support such targets with the LLVM backend. But there may well be tricks I am not aware of.

RalfJung commented 3 years ago

I don't think all would be, necessarily—just those pointing to the high RAM area which is banked.

Sorry, I somehow understood that all memory is being switched on bank change. Yes, only references pointing to memory addresses that actually change from a bank switch are invalidated.

Sympatron commented 9 months ago

Is there any way to read or write from address 0 today with Rust? Since address 0 is valid on all ARM-Cortex-M microcontrollers I know of, I think this should be made possible. Optimizing access to 0 away should be disabled in general on theses targets IMO.

Lokathor commented 9 months ago

Inline assembly.