Implementing NULL trapping on AT&T SVR3.2(.2)

Piercarlo Grandi pcg at cs.aber.ac.uk
Sun Jul 8 02:25:36 AEST 1990


   In article <1990Jul5.174608.17336 at eci386.uucp> clewis at eci386.UUCP
   (Chris Lewis) writes:
   
   On System V (I'm 386/ix 1.0.6), the memory layout of an executable
   program is controlled by a default loader control file ("ifile"),
   ...
   386 one uses the "defaults" built into "ld"'s binary, which I can't
   seem to be able to reconstruct from the 386/ix Guide entries for
   the loader.

You cannot. The example assumes a linker primtive that is not actually
there. This one is the one that tells you how long is the COFF header;
without this you must waste almost a pageful in the executable...

   	2) Has anybody got a working ifile for 386 UNIX systems
   	   that explicitly maps *out* at least the first couple
   	   of pages at virtual 0 so that null dereferences fault?
   	   Is this possible?  (does the 386/ix execution model
   	   memory requirements forbid this?)

That is pretty easy. All you have to do is to read as a preliminary the
Unix Papers (SAMS) article on the port of System V to the 386, as there
are a couple of non obvious tricks: you must make the data begin at the
same within the page offset where the code ends, and you must make the
code begin -- within the loadable file itself -- at a page boundary.

I had posted some months ago a full set of patches to g++ 1.36.x that
contained this ifile, and the ifile itself separately. If any kind soul
has saved, they might want to repost it (should go in the frequently
asked questions writeup) or send it to Chris Lewis (my copy is on my
home machine, i.e. not handy here).

Another alternative is to use the gdb patches that enable watchpoints,
and set a watchpoint on address 0.
--
Piercarlo "Peter" Grandi           | ARPA: pcg%cs.aber.ac.uk at nsfnet-relay.ac.uk
Dept of CS, UCW Aberystwyth        | UUCP: ...!mcsun!ukc!aber-cs!pcg
Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg at cs.aber.ac.uk



More information about the Comp.unix.i386 mailing list