[comp.os.vms] shareable-image

ras%hep.nrc.CDN@ean.ubc.ca (Rudolph Shally) (05/07/88)

The problem is how to override a routine in a shareable image.
The image contains several routines, say 1000 and many of those
call another routine (say QNEXTE) in the same image. QNEXTE 
in turn, calls another routine, say, QNEXT. In VAX macro the call is
(in QNEXTE):

       CALLS   #0,QNEXT

The trouble is that QNEXT is supposed to be a user supplied routine
while I had to include a dummy routine QNEXT in the shareable image
since everything must be linked. When the user links his main program
and his own QNEXT with the shareable image the linker won't accept
the user supplied routine QNEXT since a dummy version is already
in the shareable image. How can one owerride the dummy routine?

Please reply to: 
                 ras@hep.nrc.cdn    (Rudolph Shally)
                

LEICHTER@Venus.YCC.Yale.EDU ("Jerry Leichter ", LEICHTER-JERRY@CS.YALE.EDU) (05/15/88)

	The problem is how to override a routine in a shareable image.  The
	image contains several routines, say 1000 and many of those call
	another routine (say QNEXTE) in the same image. QNEXTE  in turn, calls
	another routine, say, QNEXT. In VAX macro the call is (in QNEXTE):

	       CALLS   #0,QNEXT

	The trouble is that QNEXT is supposed to be a user supplied routine
	while I had to include a dummy routine QNEXT in the shareable image
	since everything must be linked. When the user links his main program
	and his own QNEXT with the shareable image the linker won't accept the
	user supplied routine QNEXT since a dummy version is already in the
	shareable image. How can one owerride the dummy routine?

There is no automatic way to do this.  What you are asking for is essentially
the converse of the usual shareable image mechanism:  A shareable image
provides a table of entry points, and when an image starts up, its indirect
pointers to entry points within the shareable image are resolved into actual
addresses, based on where the shareable image was loaded.  What you want is
for indirect pointers within the shareable image to be fixed up.  This would
require an entirely different mechanism; for one thing, the pointers TO the
shareable image can be, and are, fixed up in place - but the shareable image
itself can't be changed - other processes may be using it.

You'll have to do this yourself:  Within your main code, provide a "transfer
vector table", just like the transfer vector table used in the shareable
image, and handled automatically.  During initialization, provide the address
of the table to the shareable image and have it store it.  Then have the
shareable image, when it wants to call something like QNEXT, actually use
an indirect reference into the "transfer vector table".

The cleanest way to do this may be make the dummy QNEXT contain the code
that finds the appropriate "transfer vector table" entry and calls it.  (Of
course, what it probably does is load the index into R0 and transfer to some
common access code.) Then as far as the rest of the shareable image is
concerned, QNEXT is just a normal function.  If you do this, QNEXT should NOT
be a universal symbol (to avoid complaints from the Linker when the "real"
QNEXT gets defined).

							-- Jerry

ZWARTS@HGRRUG51.BITNET (05/19/88)

>The problem is how to override a routine in a shareable image.
>The image contains several routines, say 1000 and many of those
>call another routine (say QNEXTE) in the same image. QNEXTE
>in turn, calls another routine, say, QNEXT. In VAX macro the call is
>(in QNEXTE):
>
>       CALLS   #0,QNEXT
>
>The trouble is that QNEXT is supposed to be a user supplied routine
>while I had to include a dummy routine QNEXT in the shareable image
>since everything must be linked. When the user links his main program
>and his own QNEXT with the shareable image the linker won't accept
>the user supplied routine QNEXT since a dummy version is already
>in the shareable image. How can one owerride the dummy routine?

The easiest way to do this is by passing the routine QNEXT as a argument,
instead of using it as a global defined routine. However, this solution is not
always possible.

What I once did was the following:

1) I created a shareable image with only the dummy routine QNEXT (using
transfer vectors etc.).

2) I rebuilt the original shareable image by linking it against the dummy QNEXT
in the shareable image from step 1).

3) The user links his program, except his QNEXT against both shareable images.

4) I wrote a procedure for the user to create a shareable image with his QNEXT,
using exactly the same transfer vectors as in case 1) of the dummy QNEXT.

5) The user defines a logical name so that the image-activator uses the user's
QNEXT, not the dummy one.

        F. Zwarts                               Phone:          (+31)50-633619
        Kernfysisch Versneller Instituut        Bitnet/Earn:    ZWARTS@HGRRUG51
        Zernikelaan 25                          Surfnet:        KVIANA::ZWARTS
        9747 AA  Groningen                      Telefax:        (+31)50-634003
        The Netherlands                         Telex:          53410 rugro nl