[comp.sys.dec] Runtime loading of shareable images

Prodas@cup.portal.com (Henry Lewis Feldman) (03/09/90)

I have a question about run-time dynamic linking.

I am working on a C program that during run-time must choose between
several different subroutines.  Ideally these run-time subroutines
should be "shareable images".  But is there a program callable routine
that will dynamically load an image, my reading of the linker is that
link to the shareable image is fixed at link time.  My program must choose
between one of many images after the program has started.

Can anyone point me to the proper routines?

Thanks in advance.

Henry Feldman

sun!cup.portal.com!prodas

(713) 667-4222

....................

gjc@paradigm.com (03/11/90)

In article <27705@cup.portal.com>, Prodas@cup.portal.com (Henry Lewis Feldman) writes:
> I have a question about run-time dynamic linking.
> 
> Can anyone point me to the proper routines?
> 

LIB$FIND_IMAGE_SYMBOL

An example of its use in VMS: $ SET HOST/DTE=(MODEM:FOO)
will LIB$FIND_IMAGE_SYMBOL on SYS$LIBRARY:DTE_FOO.EXE, or something
like that.

-gjc

marbru@auto-trol.UUCP (Martin Brunecky) (03/12/90)

In article <27705@cup.portal.com> Prodas@cup.portal.com (Henry Lewis Feldman) writes:
>I have a question about run-time dynamic linking.
>
>I am working on a C program that during run-time must choose between
>several different subroutines.  Ideally these run-time subroutines
>should be "shareable images".  But is there a program callable routine
>that will dynamically load an image, my reading of the linker is that
>link to the shareable image is fixed at link time.  My program must choose
>between one of many images after the program has started.
>
>Can anyone point me to the proper routines?

	What about operating system ???

	Assuming VMS, look at LIB$FIND_IMAGE_SYMBOL. Does everything you need.
	Be carefull about logical name for the loaded shareable image.
	Must always be the same, otherwise you may end up with the same image
	loaded multiple times.

	I have a Macro module, acting as a dynamic loader, and a set of tools
	that allow us to build images with "stub" rerferences to dynamically
	called shareable images. At runtime, those stubs are re-built on the
	first request to a particular entry, so that subsequent call overhead 
	on call to an entry in shareable image is 1 JMP instruction, i.e. the
	same as if you bind to shareable image at link time.
-- 
=*= Opinions presented here are solely of my own and not those of Auto-trol =*=
Martin Brunecky                   marbru@auto-trol.COM
(303) 252-2499                    {...}ncar!ico!auto-trol!marbru
Auto-trol Technology Corp. 12500 North Washington St., Denver, CO 80241-2404 

mikes@rtech.UUCP (Mike Schilling) (03/13/90)

From article <27705@cup.portal.com>, by Prodas@cup.portal.com (Henry Lewis Feldman):
> I have a question about run-time dynamic linking.
> 
> I am working on a C program that during run-time must choose between
> several different subroutines.  Ideally these run-time subroutines
> should be "shareable images".  But is there a program callable routine
> that will dynamically load an image, my reading of the linker is that
> link to the shareable image is fixed at link time.  My program must choose
> between one of many images after the program has started.
> 
> Can anyone point me to the proper routines?
> 
I'm posting this, rather than mailing it, because the technique is so generally
useful:

Use LIB$FIND_IMAGE_SYMBOL.  It will, at run-time, map a shareable image and
return the value of any universal symbol which that image defines. 
----------------------------------------------------------------------------
"I want the right to urinate in different colors"  -- Tom Stoppard, "Travesties"
mikes@rtech.com = Mike Schilling, Ingres Corporation, Alameda, CA