[mod.computers.vax] Dereferencing NULL pointers

garry@TCGOULD.TN.CORNELL.EDU (Garry Wiegand) (02/04/86)

In a recent article RIZZI@USC-ISIB.ARPA wrote:
>	I am porting a UNIX application written in C to VAX/VMS.
>Aside from file name translation, the biggest problem I have
>is in dealing with code that blithely dereferences NULL pointers,
>...

To get legal memory at virtual address zero (one solution to your problem),
the trivial solution is add a 'Based image' linker option:

		$ link foo, baz, sys$input/options
		BASE = 0

This has the unfortunate side effect of nailing down everything in the image --
any shareable images you reference will not be allowed to change size.
The fancier solution is:

		$ link foo, baz, sys$input/options
		CLUSTER = CODE_CLUSTER, 0
		COLLECT = CODE_CLUSTER, $CODE

Which has the net effect of moving the $CODE program section down to virtual
address zero.

I know these tricks because I unfortunately ported Nroff once upon a time.

garry wiegand