Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!rpi!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!mimsy!mojo!stripes From: stripes@eng.umd.edu (Joshua Osborne) Newsgroups: comp.unix.wizards Subject: Re: What machines core dump on deref of NULL? Message-ID: <1990Jun29.202613.6815@eng.umd.edu> Date: 29 Jun 90 20:26:13 GMT References: <13226@smoke.BRL.MIL> <412@minya.UUCP> <1990Jun29.132304.12550@athena.mit.edu> Sender: news@eng.umd.edu (The News System) Organization: College of Engineering, Maryversity of Uniland, College Park Lines: 28 In article <1990Jun29.132304.12550@athena.mit.edu> jik@athena.mit.edu (Jonathan I. Kamens) writes: > It would seem to me that a simpler solution to the embedded processor >problem than requiring a non-standard C compiler in order to write code >for one would be to not have any physical memory at address 0, or to put >program memory there (since, unless the program is self-modifying, it >should never have to access its own memory, excluding perhaps function >pointers). Most processers treat the first N bytes of memmory diffrently. The 6510 uses the first 2 bytes as an I/O regester (which implments bank switching on the C=64). The 680x0 uses the first N bytes for address of traps, interupt vectors, and something else (is it the value of A7 after cold boot?). They are things that an OS would need to change, not a user. They are most likely things that standard system functions like malloc() never return pointers to. So NULL could still be returned as an error indicator from functions that return pointers. On systems with an OS only the OS should be able to write to NULL (the Atari ST only lets programs write to the first 2 or 4K when the S bit is on). If a system has no OS (non-hosted env) then a C program may well have to write to location 0, which may well be NULL, but it is still not a valid pointer to "normal" memmory. Also there may be *no* invalid addresses, a CPU with 16 bit address space, and 64K has no invalid addresses (unless it has alignment restrictions...). -- stripes@eng.umd.edu "Security for Unix is like Josh_Osborne@Real_World,The Mutitasking for MS-DOS" "The dyslexic porgramer" - Kevin Lockwood "Don't try to change C into some nice, safe, portable programming language with all sharp edges removed, pick another language." - John Limpert