%%s 16/2/327 %%d D 1.8 21-Oct-83 13:36:25 tools 8 7 %%c Updated ld.fmt to reflect addition of the -xs option. %%s 15/7/314 %%d D 1.7 27-Sep-83 17:31:44 tools 7 6 %%c Modified cld, ld.r`main and ld.r`ldcmd to support VMS-specific loader %%c flag -xs, which indicates that the shared library image RLIBSHARE is %%c NOT to be used in the linking process. %%s 6/3/315 %%d D 1.6 07-Aug-83 22:27:46 tools 6 5 %%c Added extra assign to link command file to cause linker warning messages %%c to appear on the user's screen. %%s 3/2/315 %%d D 1.5 28-Jul-83 22:24:47 tools 5 4 %%c Modified main to fold the resultant string from translating RLIBSHARE. %%s 26/14/291 %%d D 1.4 28-Jul-83 22:19:09 tools 4 3 %%c Modified main to check for RLIBSHARE, and include it in the options part %%c of the command file if found. Also changed impath reference to static %%c declaration of STD_PATH string, as well as eliminating trailing periods %%c from quoted strings. %%s 5/2/300 %%d D 1.3 21-Dec-82 16:03:48 tools 3 2 %%c Modified ld.r`main to cause images to be linked /notrace when the debug %%c option is NOT enabled. This prevents a security hole when a tool is installed %%c with privilege, such that it cannot be run/debug. %%s 29/13/273 %%d D 1.2 13-Dec-82 14:47:50 dpm 2 1 %%c Added a "-m" switch to force generation of a load map. The "-d" option %%c no longer forces a map to be generated. %%s 0/0/0 %%d D 1.1 27-Mar-82 14:59:07 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 %%D 2 #-h- cld 227 asc 25-mar-82 09:34:53 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 7 #-h- cld 289 asc 13-dec-82 13:40:06 dpm (dave martin) %%E 7 %%E 2 %%I 7 #-h- cld 382 asc 27-sep-83 16:42:46 tools (lblh csam sventek) %%E 7 ### CLd Common block for ``ld'' tool. %%D 2 common / cld / verbos, debug, task(FILENAMESIZE) %%E 2 %%I 2 %%D 7 common / cld / debug, ldmap, verbos, task(FILENAMESIZE) %%E 7 %%E 2 %%I 7 common / cld / debug, ldmap, verbos, shared, task(FILENAMESIZE) %%E 7 %%D 2 integer verbos # if verbose load; init = NO %%E 2 integer debug # if debugging aid desired in task; init=NO %%I 2 integer ldmap # if load map to be prosuced; init = NO integer verbos # if verbose load; init = NO %%E 2 %%I 7 integer shared # if shared image to be used ; init = YES # negated by -xs switch %%E 7 character task # task image name #-h- flist 185 asc 25-mar-82 09:34:54 v1.1 (sw-tools v1.1) ### FList Common block for list of files. common /flist/ flevel, ffiles(FILENAMESIZE, FLMAX) integer flevel # pointer to current file character ffiles # list of files to process %%D 2 #-h- ld.r 4803 asc 25-mar-82 09:34:55 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 3 #-h- ld.r 4915 asc 10-nov-82 18:51:21 dpm (dave martin) %%E 3 %%E 2 %%I 3 %%D 4 #-h- ld.r 4981 asc 21-dec-82 16:02:38 tools (lblh csam sventek) %%E 4 %%E 3 %%I 4 %%D 5 #-h- ld.r 5405 asc 28-jul-83 22:17:41 tools (lblh csam sventek) %%E 5 %%E 4 %%I 5 %%D 6 #-h- ld.r 5422 asc 28-jul-83 22:23:32 tools (lblh csam sventek) %%E 6 %%E 5 %%I 6 %%D 7 #-h- ld.r 5594 asc 07-aug-83 22:24:46 tools (lblh csam sventek) %%E 7 %%E 6 %%I 7 #-h- ld.r 5716 asc 27-sep-83 16:42:47 tools (lblh csam sventek) %%E 7 #-h- defns 35 asc 25-mar-82 09:34:41 v1.1 (sw-tools v1.1) define(FLMAX,25) define(EXTSIZE,4) %%D 2 #-h- main 3158 asc 25-mar-82 09:34:43 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 3 #-h- main 3231 asc 10-nov-82 18:50:29 dpm (dave martin) %%E 3 %%E 2 %%I 3 %%D 4 #-h- main 3289 asc 21-dec-82 15:57:11 tools (lblh csam sventek) %%E 4 %%E 3 %%I 4 %%D 5 #-h- main 3713 asc 28-jul-83 22:15:50 tools (lblh csam sventek) %%E 5 %%E 4 %%I 5 %%D 6 #-h- main 3730 asc 28-jul-83 22:22:11 tools (lblh csam sventek) %%E 6 %%E 5 %%I 6 %%D 7 #-h- main 3902 asc 07-aug-83 22:21:10 tools (lblh csam sventek) %%E 7 %%E 6 %%I 7 #-h- main 3936 asc 27-sep-83 16:39:56 tools (lblh csam sventek) %%E 7 DRIVER(ld) character arg(FILENAMESIZE), templ8(FILENAMESIZE) character scrat(FILENAMESIZE), rlib(FILENAMESIZE) character args( arith(FILENAMESIZE,*,3) ), map(FILENAMESIZE) %%I 4 character getch # function(s) %%E 4 filedes create, open # function(s) integer i, inp, int, rlibdn, status, junk %%D 4 integer getarg, loccom, spawn, remove # function(s) %%E 4 %%I 4 integer getarg, loccom, spawn, remove, trnlog, equal # function(s) %%E 4 include cld include flist string suffix NO_SUFFIX %%D 2 string usestr "usage: ld [-dv] [-l[libr]] [-pproc] file ..." %%E 2 %%I 2 %%D 7 string usestr "usage: ld [-dmv] [-l[libr]] [-pproc] file ..." %%E 7 %%E 2 %%I 7 string usestr "usage: ld [-dmv] [-l[libr]] [-pproc] [-xs] file ..." %%E 7 string tkb "tkb" string ext "exe" string mapext "map" string lib "/libr" string rdbgst "rdbg.olb" string rlibst "rlib.olb" string mainst "/incl=(tools$main)" %%D 4 string blmins " -@n" %%E 4 string commin ",-" string linkst "$ link/exe=" %%D 2 string dbgst "/debug/map=" %%E 2 %%I 2 string dbgst "/debug" %%I 3 string tracst "/notrace" %%E 3 string maps "/map=" %%E 2 string nomaps "/nomap" %%I 4 string spath STD_PATH string rlibshare "RLIBSHARE" %%E 4 call query(usestr) flevel = 0 task(1) = EOS verbos = NO debug = NO %%I 2 ldmap = NO %%E 2 %%I 7 shared = YES %%E 7 rlibdn = NO for( i = 1 ; getarg( i, arg, FILENAMESIZE) != EOF ; i = i + 1 ) { if( arg(1) == '-' | arg(1) == '+' ) call ldcmd(arg) else call fstack(arg) } if( task(1) == EOS ) { for( i = 1 ; i <= flevel ; i = i + 1 ) if( ffiles( 1, i) != '-' )break if( i <= flevel ) call scopy( ffiles( 1, i), 1, task, 1) } if( task(1) == EOS ) call error(usestr) call scratf( tkb, scrat) int = create( scrat, WRITE) if( int == ERR ) %%D 4 call error( "Error creating LINK command file." ) call impath(args) %%E 4 %%I 4 call error( "Error creating LINK command file" ) %%E 4 if( debug == YES ) # Use debugging library, if present (dpm 13-Jul-81) %%D 4 andif( loccom( rdbgst, args, suffix, rlib) != ERR ) %%E 4 %%I 4 andif( loccom( rdbgst, spath, suffix, rlib) != ERR ) %%E 4 call strcpy( rdbgst, rlibst) %%D 4 if( loccom( rlibst, args, suffix, rlib) == ERR ) %%E 4 %%I 4 if( loccom( rlibst, spath, suffix, rlib) == ERR ) %%E 4 call error( "Cannot locate rlib.olb" ) call concat( rlib, mainst, templ8) call concat( rlib, lib, rlib) call genfil( task, ext, arg) call genfil( task, mapext, args) call mklocl( arg, task) junk = remove(task) # delete most recent version of task image call mklocl( args, map) junk = remove(map) # delete most recent version of map file %%I 4 call putlin("$ deassign/user sys$input@n", int) %%E 4 %%I 6 call putlin("$ if f$mode() .eqs. @"INTERACTIVE@" then assign 'f$logical(@"TT@")' sys$error@n", int) %%E 6 call putlin( linkst, int) call putlin( task, int) if( debug == YES ) %%D 2 { %%E 2 call putlin( dbgst, int) %%I 2 %%I 3 else call putlin( tracst, int) %%E 3 if( ldmap == YES ) { call putlin( maps, int) %%E 2 call putlin( map, int) } else call putlin( nomaps, int) %%D 4 call putlin( blmins, int) %%E 4 %%I 4 call putlin(" sys$input/options@n", int) %%E 4 for( i = 1 ; i <= flevel ; i = i + 1 ) { if( ffiles( 1, i) == '-' ) { if( ffiles( 3, i) == EOS ) # desires rlib in odd place { call putlin( rlib, int) call putlin( commin, int) call putch( '@n', int) rlibdn = YES } else { call mklocl( ffiles( 3, i), arg) call putlin( arg, int) call putlin( lib, int) call putlin( commin, int) call putch( '@n', int) } } else { call mklocl( ffiles( 1, i), arg) call putlin( arg, int) call putlin( commin, int) call putch( '@n', int) } } call putlin( templ8, int) %%I 4 junk = trnlog(rlibshare, arg) %%D 7 if (equal(rlibshare, arg) == NO) # use shared image %%E 7 %%I 7 if (equal(rlibshare, arg) == NO & shared == YES) # use shared image %%E 7 { call putlin(commin, int) call putch('@n', int) %%I 5 call fold(arg) %%E 5 call putlin(arg, int) call putlin("/share", int) } %%E 4 if( rlibdn == NO ) { call putlin( commin, int) call putch( '@n', int) call putlin( rlib, int) } call putch( '@n', int) call close(int) i = 1 call chcopy( '@@', args, i) %%D 4 call scopy( scrat, 1, args, i) %%E 4 %%I 4 call stcopy( scrat, 1, args, i) %%D 6 call stcopy("/out=nla0:", 1, args, i) %%E 6 %%E 4 %%I 6 #call stcopy("/out=nla0:", 1, args, i) %%E 6 if( verbos == YES ) { int = open( scrat, READ) if( int == ERR ) %%D 4 call error( "Error in opening LINK command file." ) %%E 4 %%I 4 call error( "Error in opening LINK command file" ) while (getch(c, int) != '@n') # don't display deassign garbage ; %%E 4 %%I 6 while (getch(c, int) != '@n') # don't display deassign garbage ; %%E 6 call fcopy( int, ERROUT) call close(int) } status = spawn( "local", args, arg, WAIT) if( status == ERR ) %%D 4 call remark( "Error in spawning LINK." ) %%E 4 %%I 4 call remark( "Error in spawning LINK" ) %%E 4 junk = remove(scrat) DRETURN end #-h- fstack 330 asc 25-mar-82 09:34:45 v1.1 (sw-tools v1.1) ## fstack - generate stack of input files subroutine fstack (iarg) integer i character iarg(FILENAMESIZE) include flist if (flevel < FLMAX) { flevel = flevel + 1 for (i=1; i<=FILENAMESIZE; i=i+1) ffiles(i,flevel) = iarg(i) call fold(ffiles(1, flevel)) } return end #-h- genfil 512 asc 25-mar-82 09:34:46 v1.1 (sw-tools v1.1) ### GenFil Generate file name with extension `ext' from `in'. subroutine genfil( in, ext, out) integer i, j integer index, length # function(s) character in(FILENAMESIZE), ext(EXTSIZE), out(FILENAMESIZE) string trmchr "/]" for( i = length(in) ; i > 0 ; i = i - 1 ) if( index( trmchr, in(i) ) > 0 ) break for( j = i + 1 ; in(j) != EOS ; j = j + 1 ) if( in(j) == '.' ) break for( i = 1 ; i < j ; i = i + 1 ) out(i) = in(i) call chcopy( '.', out, i) call scopy( ext, 1, out, i) return end %%D 2 #-h- ldcmd 403 asc 25-mar-82 09:34:47 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 7 #-h- ldcmd 448 asc 10-nov-82 17:53:58 dpm (dave martin) %%E 7 %%E 2 %%I 7 #-h- ldcmd 528 asc 27-sep-83 16:36:42 tools (lblh csam sventek) %%E 7 ### LdCmd Process `ld' commands. subroutine ldcmd(arg) character arg(FILENAMESIZE) integer index # function(s) include cld call fold(arg) if( arg(1) == '-' ) if( arg(2) == 'p' ) call scopy( arg, 3, task, 1) else if( arg(2) == 'l' ) call fstack(arg) %%I 7 else if ( arg(2) == 'x' ) { if ( index( arg, 's') > 0 ) shared = NO } %%E 7 else { if( index( arg, 'd') > 0 ) debug = YES %%I 2 if( index( arg, 'm') > 0 ) ldmap = YES %%E 2 if( index( arg, 'v') > 0 ) verbos = YES } else call badarg(arg) return end %%D 2 #-h- ld.fmt 1481 asc 25-mar-82 09:34:57 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 8 #-h- ld.fmt 1665 asc 13-dec-82 14:31:03 dpm (dave martin) %%E 8 %%E 2 %%I 8 #-h- ld.fmt 2102 asc 21-oct-83 13:35:40 tools (lblh csam sventek) %%E 8 .so ~bin/manhdr %%D 2 .hd Ld (1) 12-Aug-81 %%E 2 %%I 2 .hd Ld (1) 13-Dec-82 %%E 2 loader .sy %%D 2 ld [-d] [-l[libname]] [-ptaskname] name ... %%E 2 %%I 2 %%D 8 ld [-dmv] [-l[libname]] [-ptaskname] name ... %%E 8 %%E 2 %%I 8 ld [-dmv] [-l[libname]] [-ptaskname] [-xs] name ... %%E 8 .ds ld links together the named modules in the order given, searches the system libraries to resolve global references and generates an executable process. %%D 2 ld understands three flags: %%E 2 %%I 2 ld understands the following flags: %%E 2 .in +3 .ti -3 -d causes `ld' to do whatever is necessary to incorporate a system-specific debugger into the image. .ti -3 -l signifies that the filename concatenated to the flag is a library name. -l alone stands for the ratfor system library, `rlib'. The default extension for a library file is `.olb'. A library is searched when its name is encountered, so the placement of -l is significant. If the ratfor system library is not explicitly mentioned, it is searched after all other files have been linked. The fortran system library is searched at the very end. .ti -3 %%I 2 -m causes `ld' to do whatever is necessary to generate a system-specific load map. .ti -3 %%E 2 -p signifies that the file name concatenated to the flag is to be the process name. If this option is not specified, the process name is determined in one of two ways: .in +3 .ti -3 1. The first non-library file name (eg. format.obj) is found, and the file's extension is replaced by `.exe' (format.exe). This is then the resulting process name. .ti -3 2. Failing 1 (implying that all files listed in the argument list are libraries), the process image is placed on the file a.out, overwriting the previous contents of that file. .in -3 %%I 2 .ti -3 -v verbose option; output additional information about the loading process. %%E 2 %%I 8 .ti -3 -x operating system specific loader options are appended to the `-x' flag. Legal sub-obtions are: .sp .in +2 .ti -2 s indicates that linkage to the ratfor shared library image RLIBSHARE is NOT to be performed. This permits images to be generated for use on systems where the shared library image will not reside, as well as permitting debugging of new versions of the routines which are in the shared library image. .in -2 %%E 8 .in -3 .sa rc, fc .au Joe Sventek wrote the interface of ld to the DEC linker. .bu %%E 1