From: lionel@quark.enet.dec.com (Steve Lionel)
Newsgroups: comp.lang.fortran
Subject: Re: VMS shareable images q.- Please help
Date: 28 Sep 92 19:20:21 GMT
Reply-To: lionel@quark.enet.dec.com (Steve Lionel)
Distribution: comp.lang.fortran
Organization: Digital Equipment Corporation, Nashua NH


In article <1992Sep26.104531.28436@doug.cae.wisc.edu>, dafnioti@cae.wisc.edu 
(Petros Dafniotis) writes:
|>
|>
|>   We recently experienced a problem with our shareable images in the
|>VAX/VMS system. In my group we are writing applications for polymerization
|>reactors (using VAX FORTRAN); all of the low and middle level stuff is
|>organized in shareable images. A few months ago some of us added C
|>allocation/deallocation etc routines in the libraries of our package.
|>Creating shareable images for our libraries was still not a problem and
|>we were using the C rtl as a shareable when linking (i.e. the options
|>file for linking to produce a shareable was containing the line:
|>SYS$SHARE:VAXCRTL.EXE/SHARE
|>and everything was working fine... till I figured out that we cannot ship
|>our product to our sponsors since if they do not have the VAX C compiler
|>the references of our executables and shareables to the VAXCRTL.EXE will
|>crash the program. So we decided to use the library VAXCRTL.OLB instead.
|>
|> ... text omitted
|>
|>I get the error:
|>%LINK-E-OUTSIMG, attempted store location %X0000A024 is outside image binary
|>(%X00000000 to %X00000000)
|>     in psect STDIN module C$VAXCIO file SYS$COMMON:[SYSLIB]VAXCRTL.OLB
|>
|>

You were on the right track with your trying to change PSECT attributes to
LCL (this was mentioned in text I omitted.)  What happened is that in TEST2,
all of the various PSECTs with the OVR and GBL attributes, which C uses
for external variables, got turned into "shareable image sections" by the
linker when the TEST2 shareable image was linked.  But when the main program
was linked, and it contained references to these same PSECTs, it tried to
"match them up" so that both images were actually using the storage that had
been allocated in TEST2.  However, there were attempts to initialize that
storage in the contributions from the main program, and this is not allowed,
hence the error message.

One solution is to declare all such PSECTS as LCL when linking TEST2.  This
has the effect of separating the C Run-Time Library completely between
the TEST2 and main images, which may or may not be desireable.  I found that
by including the following linker option lines while linking TEST2 I could
get the image to link and run:
	PSECT_ATTR=STDIN,LCL
	PSECT_ATTR=STDERR,LCL
	PSECT_ATTR=STDOUT,LCL
	PSECT_ATTR=ENVIRON,LCL
	PSECT_ATTR=ERRNO,LCL
	PSECT_ATTR=RANDX,LCL
	PSECT_ATTR=VAXC$ERRNO,LCL
	PSECT_ATTR=_CTYPE_,LCL
	PSECT_ATTR=SYS_NERR,LCL
	PSECT_ATTR=SYS_ERRLIST,LCL

However, none of this ought to be necessary, as there is a mistaken assumption
that if the customers don't have the VAX C product that they won't have
the VAX C RTL.  This is not true; the VAX C RTL is included with the base
VMS kit.  The only thing to be careful of is that you link against the
oldest VMS version you're willing to support.

I hope this helps; if you have further questions, let me know.
--

Steve Lionel                    lionel@quark.enet.dec.com
SDT Languages Group
Digital Equipment Corporation
110 Spit Brook Road
Nashua, NH 03062