Sujet : Re: Calling conventions (particularly 32-bit ARM)
De : johnl (at) *nospam* taugh.com (John Levine)
Groupes : comp.archDate : 10. Jan 2025, 16:17:29
Autres entêtes
Organisation : Taughannock Networks
Message-ID : <vlrdm9$964$1@gal.iecc.com>
References : 1 2 3 4
User-Agent : trn 4.0-test77 (Sep 1, 2010)
According to Anton Ertl <
anton@mips.complang.tuwien.ac.at>:
Such things happended many times in the past. AFAIK standard
setup on a VAX was that accessing data at address 0 gave you 0.
A lot of VAX programs needed fixes to run on different machines.
>
That case is interesting. It's certainly a benefit to programmers if
most uses of NULL produce a SIGSEGV, but for existing programs mapping
allowing to have accessible memory in page 0 is an advantage. So how
did we get from there to where we are now?
>
First, my guess is that the VAX is only called out because it was so
popular, and it was one of the first Unix machines where doing it
differently was possible. I am sure that earlier Unix tragets without
virtual memory used memory starting with address 1 because they would
otherwise have wasted precious memory.
It was a bug. As I recall, the first thing in the address space in Berkeley Unix
was a register save mask where the low byte happened to be zero, and a lot of
sloppy programs written by students accidentally depended on it, e.g.
if(*p == 0) /* no string */
For a while ports to 68K and other architectures ensured there was a zero byte at
location zero so the Berkeley programs wouldn't crash, but eventually people fixed
the code.
Location 0 on the PDP-11 had nothing memorable and we did our string tests correctly.
You could deferenence a null pointer but you got a string of junk.
-- Regards,John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",Please consider the environment before reading this e-mail. https://jl.ly