![]() | Note |
---|---|
Paths used in $ZROUTINES to locate routines must not include embedded spaces, as $ZROUTINES uses spaces as delimiters. |
Commands or functions such as DO, GOTO, ZGOTO, ZBREAK, ZPRINT, and $TEXT may auto-ZLINK and thereby indirectly use $ZROUTINES. If their argument does not specify a directory, ZEDIT and explicit ZLINK use $ZROUTINES. ZPRINT and $TEXT use $ZROUTINES to locate a source file if GT.M cannot find the source file pointed to by the object file. For more information on ZLINK and auto-ZLINK, see the a??Development Cyclea?? and a??Commandsa?? chapters.
GTM>s $zroutines=".(../src) $gtm_dist"
$ gtmroutines="/usr/jones /usr/smith" $ export gtmroutines $ gtm GTM>write $zroutines "/usr/jones /usr/smith" GTM>set $zro="/usr/jones/utl /usr/smith/utl" GTM>write $zroutines "/usr/jones/utl /usr/smith/utl" GTM>halt $ echo $gtmroutines /usr/jones /usr/smith
GTM>SET $ZRO=". /usr/smith"
This example sets $zroutines to a list containing two directories.
GTM>set $zro="/usr/smith(/usr/smith/tax /usr/smith/fica)"
GTM>set $zro="/usr/smith(/usr/smith /usr/smith/tax /usr/smith/fica)"
GTM>set $zro="/usr/smith /usr/smith/tax() /usr/smith/fica"
GT.M uses $ZRO[UTINES] to perform three types of searches:
GTM>s $zro=". /usr/smi/utl() /usr/jon/utl (/usr/jon/utl/so /usr/smi/utl)"
The following table illustrates the matrix view of this $ZROUTINES.
$ZROUTINES Search Matrix | |||
---|---|---|---|
SEARCH FOR |
Column 1 |
Column 2 |
Column 3 |
OBJECTS |
. |
/usr/smi/utl |
/usr/jon/utl |
SOURCE |
. | A |
/usr/jon/utl/so |
A | A | A |
/usr/smi/utl |
Once the object-source match search is done, GT.M now has either the object-file or source-file or both available. GT.M then recompiles the source-file based on certain conditions, before linking the object-file into the current image. See a??ZLinka?? for more information on those conditions.
If auto-ZLINK or ZLINK determines that the source file requires [re]compilation, GT.M places the object file in the above object directory in the same column as the source file. For example, if GT.M locates the source file in /usr/smi/utl in column three, GT.M places the resultant object file in /usr/jon/utl.
$ZROUTINES syntax contains a file-specification indicating shared library file path. GT.M does not require any designated extension for the shared library component of $ZROUTINES. Any file specification that does not name a directory is treated as shared library. However, it is recommended that the extension commonly used on a given platform for shared library files be given to any GT.M shared libraries. See a??Linking GT.M Shared Imagesa??. A shared library component cannot specify source directories. GT.M reports an error at an attempt to associate any source directory with a shared library in $ZROUTINES.
The following traits of $ZROUTINES help support shared libraries:
The $ZROUTINES search continues to find objects in the first place, processing from left to right, that holds a copy; it ignores any copies in subsequent locations. However, now for auto-ZLINK, shared libraries are accepted as object repositories with the same ability to supply objects as directories.
Explicit ZLINK, never searches Shared Libraries. This is because explicit ZLINK is used to link a newly created routine or re-link a modified routine and there is no mechanism to load new objects into an active shared library.
ZPRINT and $TEXT() of the routines in a shared library, read source file path from the header of the loaded routine. If the image does not contain the routine, an auto-ZLINK is initiated. If the source file path recorded in the routine header when the module was compiled cannot be located, ZPRINT and $TEXT() initiate a search from the beginning of $ZROUTINES, skipping over the shared library file specifications. If the located source does not match the code in image (checked via checksum), ZPRINT generates an object-source mismatch status and $TEXT() returns a null string.
ZEDIT, when searching $ZROUTINES, skips shared libraries like explicit ZLINK for the same reasons. $ZSOURCE ISV is implicitly set to the appropriate source file.
For example, if libshare.so is built with foo.o compiled from ./shrsrc/foo.m, the following commands specify that GT.M should search the library ./libshare.so for symbol foo when do ^foo is encountered.
GTM>SET $ZROUTINES="./libshare.so ./obj(./shrsrc)" GTM>DO ^foo;auto-ZLINK foo - shared GTM>ZEDIT "foo";edit ./shrsrc/foo.m GTM>W $ZSOURCE,!;prints foo GTM>ZPRINT +0^foo;issues a source-object mismatch status TXTSRCMAT error message GTM>ZLINK "foo";re-compile ./shrsrc/foo.m to generate ./obj/foo.o. GTM>W $TEXT(+0^foo);prints foo
Note that ZPRINT reports an error, as foo.m does not match the routine already linked into image. Also note that, to recompile and re-link the ZEDITed foo.m, its source directory needs to be attached to the object directory [./obj] in $ZROUTINES. The example assumes the shared library (libshare.so) has been built using shell commands. For the procedure to build a shared library from a list of GT.M generated object (.o) files, see a??Linking GT.M Shared Imagesa??.
To create a shared library, use the following syntax:
ld -brtl -G -bexpfull -bnoentry -b64 -o libshr.so file1.o file2.o (on AIX) ld -shared -o libshr.so file1.o file2.o (on Linux)
![]() | Notes |
---|---|
|