[net.unix-wizards] XMAGIC: a.out without a valid page 0?

jdb@mordor.UUCP (06/07/84)

We're running 4.2BSD on a VAX (750).  Too many times we have been bitten by
software that references through NULL pointers.  The evils of this have been
discussed from time to time in this newsgroup, so I won't go into them again.

We are considering the implementation of a new "a.out" format with a new magic
number (XMAGIC).  The text segment would start at 1024 rather than zero, and
the data segment would start at the next page boundary after the text segment.
Page 0 would be unmapped (i.e. a program which tries to touch it will get a
SIGSEGV).

Clearly it is easy to change "ld" to produce XMAGIC-format files.  My current
inclination is to simply start text relocation at 1024, set the a_entry field
of the "a.out" header to 1024, and fill page zero (in the "a.out" file) with
zeros.  Then the page offsets in the file are identical for XMAGIC and ZMAGIC
files, and--aside from the kernel keeping page 0 invalid--the load-on-demand
code for ZMAGIC files should work unchanged.

Has anyone done this (or something similar)?
-- 
  John Bruner (S-1 Project, Lawrence Livermore National Laboratory)
  MILNET: jdb@mordor.ARPA [jdb@s1-c]	(415) 422-0758
  UUCP: ...!ucbvax!dual!mordor!jdb 	...!decvax!decwrl!mordor!jdb

dave@elecvax.SUN (Dave Horsfall) (06/12/84)

Amusing - VMS does just that!
--
From the terminal of ...

Dave Horsfall			+61 2 662-3590
Computing Services Unit		 (02) 662-3590
University of New South Wales
Kensington  NSW  2033		UUCP: decvax!mulga!dave:csu60
AUSTRALIA			 SUN: dave:csu60

	"Vanity, vanity, all is vanity"

dave@elecvax.UUCP (06/12/84)

Amusing - VMS does just that!
--
>From the terminal of ...

Dave Horsfall			+61 2 662-3590
Computing Services Unit		 (02) 662-3590
University of New South Wales
Kensington  NSW  2033		UUCP: decvax!mulga!dave:csu60
AUSTRALIA			 SUN: dave:csu60

	"Vanity, vanity, all is vanity"

guy@rlgvax.UUCP (06/16/84)

So, according to an authoritative source, did a paging VAX-11 UNIX done
at BTL.  I don't think "well, it'll break lots of existing - but *incorrect* -
UNIX programs" is necessarily a reason to do something.  Correctly written
C programs have no problems with dereferencing null pointers (remember,
according to K&R, a null pointer doesn't point to anything).

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy

jdb@mordor.UUCP (John Bruner) (06/18/84)

Actually, I was proposing XMAGIC as an optional alternative to
ZMAGIC, not as a replacement for it.  We want XMAGIC to aid debugging
of locally-written programs.  I don't have the time to fix all of the
poorly-written utilities that try to reference through zero.  By
continuing to use ZMAGIC as the default I can sidestep the issue to
some extent.

Of course, any library routines which expect references through
(foo *)0 to work will need to be modified.  Does anyone have a feel
for the number of routines that may need modification?
-- 
  John Bruner (S-1 Project, Lawrence Livermore National Laboratory)
  MILNET: jdb@mordor.ARPA [jdb@s1-c]	(415) 422-0758
  UUCP: ...!ucbvax!dual!mordor!jdb 	...!decvax!decwrl!mordor!jdb