LD (I)                       3/15/72                       LD (I)





NAME            ld  --  link editor



SYNOPSIS        ld [ -sulxr ] name  ...
                                  1


DESCRIPTION     ld  combines several object programs into one;

                resolves external references; and searches li-

                braries.  In the simplest case the names of sev-

                eral object programs are given, and ld combines

                them, producing an object module which can be ei-

                ther executed or become the input for a further

                ld run.  In the latter case, the "-r" option must

                be given to preserve the relocation bits.



                The argument routines are concatenated in the or-

                der specified.  The entry point of the output is

                the beginning of the first routine.



                If any argument is a library, it is searched ex-

                actly once.  Only those routines defining an un-

                resolved external reference are loaded.  If a

                routine from a library references another routine

                in the library, the referenced routine must ap-

                pear after the referencing routine in the li-

                brary.  Thus the order of programs within li-

                braries is important.



                ld understands several flag arguments which are

                written preceded by a "-":



                   -s "squash" the output, that is, remove the

                      symbol table and relocation bits to save

                      space (but impair the usefulness of the de-

                      bugger).  This information can also be re-

                      moved by strip.



                   -u take the following argument as a symbol and

                      enter it as undefined in the symbol table.

                      This is useful for loading wholly from a

                      library, since initially the symbol table

                      is empty and an unresolved reference is

                      needed to force the loading of the first

                      routine.



                   -l This option is an abbreviation for a li-

                      brary name.  "-l" alone stands for

                      "/usr/lib/liba.a", which is the standard

                      system library for assembly language pro-

                      grams.  "-lx" stands for "/usr/lib/libx.a"

                      where x is any character.  There are li-

                      braries for Fortran (x="f"), C (x="c"), Ex-

                      plor (x="e") and B (x="b").



                   -x Do not preserve local (non-.globl) symbols

                      in the output symbol table; only enter ex-

                      ternal symbols.  This option saves some

                      space in the output file.



                   -r generate relocation bits in the output file

                      so that it can be the subject of another ld

                      run.



                The output of ld is left on a.out.  This file is

                executable only if no errors occurred during the

                load.



FILES           /usr/lib/lib?.a libraries

                a.out   output file



SEE ALSO        as(I), ar(I)



DIAGNOSTICS     "file not found"-- bad argument



                "bad format"-- bad argument



                "relocation error"-- bad argument (relocation

                bits corrupted)



                "multiply defined"-- same symbol defined twice in

                same load



                "un"-- stands for "undefined symbol"



                "symbol not found"--  loader bug



                "can't move output file"-- can't move temporary

                to a.out file



                "no relocation bits"-- an input file lacks relo-

                cation information



                "too many symbols"-- too many references to ex-

                ternal symbols in a given routine



                "premature EOF"



                "can't create l.out"-- cannot make temporary file



                "multiple entry point"-- more than one entry

                point specified (not possible yet).



BUGS            --