The Embedded Rust Book says:
Where are Flash memory and RAM mapped in the address space? e.g. RAM is commonly located at address
RAM is mapped into the address space the same as anything else! Mind blown 🤯 This never quite gelled in my mind until now.
Previously I had thought that RAM began at address
0x0000_0000 and that
non-RAM hardware was mapped into RAM (waves hands) somehow. I had imagined that
null pointers were also
0x0000_0000 and that everyone agreed that the first
addressable location in RAM was unused!
Update: Hilariously, I wasn’t entirely wrong. Read the following from Putting the “You” in CPU:
Aside: cursed ELF fact
In certain situations,
binfmt_elfhas to map the first page of memory to zeroes. Some programs written for UNIX System V Release 4.0 (SVr4), an OS from 1988 that was the first to support ELF, rely on null pointers being readable. And somehow, some programs still rely on that behavior.
It seems like the Linux kernel dev implementing this was a little disgruntled:
“Why this, you ask??? Well SVr4 maps page 0 as read-only, and some applications ‘depend’ upon this behavior. Since we do not have the power to recompile these, we emulate the SVr4 behavior. Sigh.”