We think the customer is more interested in figuring out how to locate
the the linkage section in order to feed the right addresses to $LKWSET
(shouldn't that be $LCKPAG for elevated IPL?). The customer doesn't
say what language they're using. Does "&" in C and/or
%LOC() in FORTRAN return the address of the code or the
address of the procedure descriptor? In either case you've got to also
figure out the address of the other.
Assume we want to know the virtual address range of the linkage section for
the world's most famous program:
#include
int main (void) {
printf ("hello world\n");
}
I'd start by wasting a bit of memory and add 2 dummy variables:
$ type t.c
#include
int $$$lnk_dummy;
int ___lnk_dummy;
int main (void) {
printf ("hello world\n");
}
In C, these variablkes will end up in their own psects that can then be
used in a linker option file to be arranged around the target psect:
$ link/map/full t,sys$input:/opt
psect_attr=$link$,nopic,con,rel,lcl,noshr,noexe,nowrt,novec,mod
psect_attr=$$$lnk_dummy,nopic,con,rel,lcl,noshr,noexe,nowrt,novec,mod
psect_attr=___lnk_dummy,nopic,con,rel,lcl,noshr,noexe,nowrt,novec,mod
collect=linkage_section,-
$$$lnk_dummy,-
$link$,-
___lnk_dummy
The result of this can be validated in the map:
+--------------------------+
! Program Section Synopsis !
+--------------------------+
Psect Name Module Name Base End Length Align Attributes
---------- ----------- ---- --- ------ ----- ----------
$$$LNK_DUMMY 00010000 00010003 00000004 ( 4.) OCTA 4 NOPIC,CON,REL,GBL,NOSHR,NOEXE,NOWRT,NOVEC, MOD
T 00010000 00010003 00000004 ( 4.) OCTA 4
$LINK$ 00010010 0001008F 00000080 ( 128.) OCTA 4 NOPIC,CON,REL,GBL,NOSHR,NOEXE,NOWRT,NOVEC, MOD
T 00010010 0001008F 00000080 ( 128.) OCTA 4
___LNK_DUMMY 00010090 00010093 00000004 ( 4.) OCTA 4 NOPIC,CON,REL,GBL,NOSHR,NOEXE,NOWRT,NOVEC, MOD
T 00010090 00010093 00000004 ( 4.) OCTA 4
We can now use the addresses of $$$lnk_dummy and ___lnk_dummy to locate the
linkage section. The disadvantage of this is that we cannot locate any
specific pieces of the linkage section that we might want to lock down;
it's an all-or-nothing approach. However, linkage sections for most images
are reasonably sized and locking down a bit more shouldn't really hurt all
that much.
In all the cases I've ever seen (except where routines get optimized away),
the address of the routine is the linkage section. Add 8, and that's the code
address.
Are there exceptions that would be generated by HLL's?