Subject: Random musings...
To: None <port-vax@NetBSD.ORG>
From: Matt Thomas <matt@lkg.dec.com>
List: port-vax
Date: 08/28/1996 21:03:17
Musing #1:

If I've read the gcc/ld stuff correctly, NetBSD/vax used a beginning
text address of 0.  (like most BSD systems).   I'd like to suggest that
this be changed to 1024 (or CLBYTES).  The current use 0 allows null
pointer dereferencing and that is evil.

Musing #2:

Anyone though of doing shared libraries?  I looked at binutils but
couldn't make much sense of it.  (Strange hardware I can deal with,
compilers, etc. I can't).  This should be easier for a VAX than for
most platforms since VAX code is, by nature, PIC.  In fact, most of
it should be able to be put into ld without changes to gcc and gas.
(Pardon the VMS MACRO ...)

	calls	#0, getpid

ld can see the external call (this works for data references as well)
and change the longword PC-relative displacement into an indirect
PC-relative displacement.

	calls	#0 @L^L_getpid_addr

L_getpid_addr would be in the data section and would contain the
absolute address of getpid in libc.so.  (Absoulte address?  Yep).
Note that the text in this instance will stay read-only and no
extra instructions have to be inserted.

The reason the address is absolute is because found the default
address for libc.so, computed the address for getpid and used that.
When ld.so resolves getpid, it checks to see if it has a different
address and so overwrite.  If it doesn't, it leaves it alone.  If 
all the symbols are at the same address, then pages be shared among
multiple processes even though they are not read-only.  This is
because they are copy on write and it happens that no one will have
written to them.  And this all can be done with the current a.out
format; all that's needed is new magic numbers to identify a shared
library.

The above doesn't allow lazy evaluation semantics.  I suppose you
could do so but I think that would involve more overhead than just
doing the fixups at the start.

If anyone is interested in doing the binutil changes, I'll
help with the ld.so stuff.

Cheers,

-- 
Matt Thomas               Internet:   matt@3am-software.com
3am Software Foundry      WWW URL:    http://www.3am-software.com/bio/matt.html
Westford, MA              Disclaimer: I disavow all knowledge of this message