%%s 18/2/312 %%d D 1.6 21-Oct-83 14:13:43 sventek 6 5 %%c Modified ld.fmt to reflect the -xo switch. %%s 37/18/277 %%d D 1.5 20-Oct-83 09:44:09 sventek 5 4 %%c Modified cld, ld.r`main and ld.r`ldcmd to support RSX-specific loader %%c flag -xo, which permits additional TKB options for the %%c current task image to be specified. %%s 6/6/289 %%d D 1.4 16-Jun-83 11:55:10 sventek 4 3 %%c Replaced runtime calls to `impath' with static declaration of search %%c path using STD_PATH. %%s 6/6/289 %%d D 1.3 16-Jun-83 11:12:59 sventek 3 2 %%c Removed trailing period in quoted strings, as they are no longer needed. %%s 37/21/258 %%d D 1.2 16-Dec-81 22:05:57 sventek 2 1 %%c Added a "-m" switch to force generation of a load map. The "-d" option %%c continues to force a map to be generated. %%s 0/0/0 %%d D 1.1 26-Mar-82 12:31:43 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 328 asc 25-mar-82 07:30:27 v1.1 (sw-tools v1.1) #---------------------------------------------------------------- ## cld common block for 'ld' tool # put on a file named 'cld' common / cld / verbos, debug, task(FILENAMESIZE) %%E 2 %%I 2 %%D 5 #-h- cld 289 asc 16-dec-81 22:04:35 sventek (joseph sventek) %%E 5 %%I 5 #-h- cld 384 asc 20-oct-83 09:40:56 sventek (joseph sventek) %%E 5 ### CLd Common block for ``ld'' tool. %%D 5 common / cld / debug, ldmap, verbos, task(FILENAMESIZE) %%E 5 %%E 2 %%I 5 common / cld / debug, ldmap, verbos, task(FILENAMESIZE), option(MAXLINE) %%E 5 %%D 2 integer verbos # if verbose taskbuild; init = NO integer debug # if debugging aid desired in task; init=NO character task # task image name %%E 2 %%I 2 integer debug # if debugging aid desired in task; init=NO integer ldmap # if load map to be prosuced; init = NO integer verbos # if verbose load; init = NO character task # task image name %%E 2 %%I 5 character option # buffer to hold accumulated TKB option lines %%E 5 #-h- flist 277 asc 25-mar-82 07:30:27 v1.1 (sw-tools v1.1) #------------------------------------------------------ # flist - common block # should be put on a file named 'flist' common /flist/ flevel, ffiles(FILENAMESIZE, FLMAX) integer flevel #pointer to current file character ffiles #list of files to process %%D 2 #-h- ld.r 4634 asc 25-mar-82 07:30:30 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 3 #-h- ld.r 4848 asc 16-dec-81 22:04:36 sventek (joseph sventek) %%E 3 %%E 2 %%I 3 %%D 4 #-h- ld.r 4844 asc 16-jun-83 11:12:38 sventek (joseph sventek) %%E 4 %%E 3 %%I 4 %%D 5 #-h- ld.r 4838 asc 16-jun-83 11:50:54 sventek (joseph sventek) %%E 5 %%E 4 %%I 5 #-h- ld.r 5440 asc 20-oct-83 09:40:58 sventek (joseph sventek) %%E 5 #-h- defns 35 asc 25-mar-82 07:30:06 v1.1 (sw-tools v1.1) define(FLMAX,25) define(EXTSIZE,4) %%D 2 #-h- main 3072 asc 25-mar-82 07:30:07 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 3 #-h- main 3200 asc 16-dec-81 21:51:43 sventek (joseph sventek) %%E 3 %%E 2 %%I 3 %%D 4 #-h- main 3196 asc 16-jun-83 11:12:20 sventek (joseph sventek) %%E 4 %%E 3 %%I 4 %%D 5 #-h- main 3190 asc 16-jun-83 11:50:31 sventek (joseph sventek) %%E 5 %%E 4 %%I 5 #-h- main 3389 asc 20-oct-83 09:28:41 sventek (joseph sventek) %%E 5 DRIVER(ld) character arg(FILENAMESIZE), templ8(FILENAMESIZE), scrat(FILENAMESIZE), rlib(FILENAMESIZE), %%D 4 args(arith(FILENAMESIZE,*,3)), map(FILENAMESIZE) %%E 4 %%I 4 %%D 5 args(ARGBUFSIZE), map(FILENAMESIZE) %%E 5 %%E 4 %%I 5 args(ARGBUFSIZE), map(FILENAMESIZE), buf(MAXLINE) %%E 5 integer i, getarg, int, create, status, spawn, rlibdn, open, inp, loccom integer junk %%D 5 integer remove %%E 5 %%I 5 integer remove, getlin, equal %%E 5 include cld include flist string suffix NO_SUFFIX %%I 4 string spath STD_PATH %%E 4 %%D 5 string usestr "usage: ld [-dv] [-l[libr]] [-pproc] file ..." %%E 5 %%I 5 string usestr "usage: ld [-dv] [-l[libr]] [-pproc] [-xo] file ..." %%E 5 string tkb "tkb" string ext "tsk" string mapext "map" %%D 2 string debsw "/da," %%E 2 %%I 2 string debsw "/da" %%E 2 string lib "/lb" string rlibst "rlib.olb" string mainst ":.main." string infile "tools.tkb" string aout "a.out" ifelse(FLOAT_PT,YES,string imgsw "/fp/cp",string imgsw "/-fp/cp") call query(usestr) flevel = 0 task(1) = EOS verbos = NO debug = NO %%I 2 ldmap = NO %%E 2 rlibdn = NO %%I 5 option(1) = EOS %%E 5 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) } call scratf(tkb, scrat) int = create(scrat, WRITE) if (int == ERR) %%D 3 call error("Error creating TKB command file.") %%E 3 %%I 3 call error("Error creating TKB command file") %%E 3 %%D 4 call impath(args) 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, lib, rlib) %%D 4 if (loccom(infile, args, suffix, templ8) == ERR) %%E 4 %%I 4 if (loccom(infile, spath, suffix, templ8) == ERR) %%E 4 call error("Cannot locate tools.tkb") if (task(1) != EOS) call genfil(task, ext, arg) else call scopy(aout, arg) call genfil(task, mapext, args) call mklocl(arg, task) junk = remove(task) # delete most recent version of task image call putlin(task, int) call putlin(imgsw, int) %%I 2 ifdef(IAS) call putlin("/rw", int) # extra switch needed for IAS enddef %%E 2 if (debug == YES) %%I 2 call putlin(debsw, int) if (ldmap == YES) %%E 2 { call mklocl(args, map) junk = remove(map) # delete most recent version of map file %%D 2 call putlin(debsw, int) %%E 2 %%I 2 call putch(',', int) %%E 2 call putlin(map, int) } call putch('=', int) call putch('@n', int) 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 putch('@n', int) rlibdn = YES } else { call mklocl(ffiles(3,i), arg) call putlin(arg, int) call putlin(lib, int) call putch('@n', int) } } else { call mklocl(ffiles(1,i), arg) call putlin(arg, int) call putch('@n', int) } } call putlin(rlib, int) call putlin(mainst, int) call putch('@n', int) if (rlibdn == NO) { call putlin(rlib, int) call putch('@n', int) } inp = open(templ8, READ) if (inp == ERR) %%D 3 call error("Error opening tools.tkb template file.") %%E 3 %%I 3 call error("Error opening tools.tkb template file") %%E 3 %%D 5 call fcopy(inp, int) %%E 5 %%I 5 while (getlin(buf, inp) != EOF) { call putlin(buf, int) if (equal(buf, "/@n") == YES & option(1) != EOS) call putlnl(option, int) } %%E 5 call close(inp) call close(int) i = 1 call stcopy(tkb, 1, args, i) call chcopy(' ', args, i) call chcopy('@@', args, i) call scopy(scrat, 1, args, i) if (verbos == YES) { int = open(scrat, READ) if (int == ERR) %%D 3 call error("Error in opening TKB command file.") %%E 3 %%I 3 call error("Error in opening TKB command file") %%E 3 call fcopy(int, ERROUT) call close(int) } status = spawn("local", args, arg, WAIT) if (status == ERR) %%D 3 call remark("Error in spawning TKB.") %%E 3 %%I 3 call remark("Error in spawning TKB") %%E 3 junk = remove(scrat) DRETURN end #-h- fstack 330 asc 25-mar-82 07:30:09 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 458 asc 25-mar-82 07:30:09 v1.1 (sw-tools v1.1) ## genfil -- generates file name with extension ext from in subroutine genfil(in, ext, out) integer i, j integer length 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 374 asc 25-mar-82 07:30:10 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 5 #-h- ldcmd 452 asc 16-dec-81 21:51:45 sventek (joseph sventek) %%E 5 %%E 2 %%I 5 #-h- ldcmd 855 asc 20-oct-83 09:33:07 sventek (joseph sventek) %%E 5 subroutine ldcmd(arg) character arg(FILENAMESIZE) %%D 5 integer index %%E 5 %%I 5 integer n integer index, length %%E 5 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 5 else if (arg(2) == 'x') switch (arg(3)) { case 'o': { n = length(option) + 1 call stcopy(arg, 4, option, n) call chcopy('@n', option, n) } default: call badarg(arg) } %%E 5 else %%D 5 { if (index(arg, 'd') > 0) debug = YES %%E 5 %%I 2 %%D 5 if (index(arg, 'm') > 0) ldmap = YES %%E 5 %%E 2 %%D 5 if (index(arg, 'v') > 0) verbos = YES } %%E 5 %%I 5 { if (index(arg, 'd') > 0) debug = YES if (index(arg, 'm') > 0) ldmap = YES if (index(arg, 'v') > 0) verbos = YES } %%E 5 else call badarg(arg) %%I 2 if (debug == YES) ldmap = YES %%E 2 return end %%D 2 #-h- ld.fmt 1480 asc 25-mar-82 07:30:34 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 6 #-h- ld.fmt 1665 asc 16-dec-81 22:04:39 sventek (joseph sventek) %%E 6 %%E 2 %%I 6 #-h- ld.fmt 2033 asc 21-oct-83 14:12:57 sventek (joseph sventek) %%E 6 .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 [-dv] [-l[libname]] [-ptaskname] name ... %%E 2 %%I 2 %%D 6 ld [-dmv] [-l[libname]] [-ptaskname] name ... %%E 6 %%E 2 %%I 6 ld [-dmv] [-l[libname]] [-ptaskname] [-xo] name ... %%E 6 .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 %%D 2 alone stands for the ratfor system library, `rlib'. A library is searched when its name is %%E 2 %%I 2 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 %%E 2 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 %%D 2 extension is replaced by the appropriate extension for the given system (format.tsk for RSX/IAS). This is then the resulting %%E 2 %%I 2 extension is replaced by `.tsk' (format.tsk). This is then the resulting %%E 2 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 6 .ti -3 -x operating system specific loader options. The legal options are: .sp .in +2 .ti -2 o the string concatenated to the -xo flag is a TKB option line to be included in the TKB command file used to build the image. For example .ce -xoTASK=FOOBAR will cause the resulting task image to be built with the task name FOOBAR in the header. .in -2 %%E 6 .in -3 .sa rc, fc .au Joe Sventek wrote the interface of ld to the DEC linker. .bu %%E 1