LD(I)                        8/16/73                        LD(I)



NAME
     ld  -  link editor

SYNOPSIS
     ld [ -sulxrdni ] name ...

DESCRIPTION
     Ld  combines  several object programs into one; resolves ex-
     ternal references; and searches libraries.  In the  simplest
     case  the names of several 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 output of ld is left on a.out.  This
     file is made executable only if no  errors  occurred  during
     the load.

     The  argument  routines are concatenated in the order speci-
     fied.  The entry point of the output is the beginning of the
     first routine.

     If any argument is a library, it is searched exactly once at
     the point it is encountered  in  the  argument  list.   Only
     those routines defining an unresolved external reference are
     loaded.  If a routine from a library references another rou-
     tine  in the library, the referenced routine must appear af-
     ter the referencing routine in the library.  Thus the  order
     of programs within libraries is important.

     Ld understands several flag arguments which are written pre-
     ceded by a `-'.  Except for -l, they  should  appear  before
     the file names.

     -s  `squash'  the  output,  that is, remove the symbol table
         and relocation bits to save space (but impair  the  use-
         fulness  of the debugger).  This information can also be
         removed by strip.

     -u  take the following argument as a symbol and enter it  as
         undefined in the symbol table.  This is useful for load-
         ing 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 library  name.   -l
         alone  stands  for  `/lib/liba.a', which is the standard
         system library  for  assembly  language  programs.   -lx
         stands  for  `/lib/libx.a'  where x is any character.  A
         library is searched when its name is encountered, so the
         placement of a -l is significant.

     -x  do not preserve local (non-.globl) symbols in the output
         symbol table; only enter external symbols.  This  option
         saves some space in the output file.



                              - 1 -




LD(I)                        8/16/73                        LD(I)


     -X  Save  local  symbols  except for those whose names begin
         with `L'.  This option is used by cc to  discard  inter-
         nally  generated labels while retaining symbols local to
         routines.

     -r  generate relocation bits in the output file so  that  it
         can  be  the  subject of another ld run.  This flag also
         prevents final definitions from being  given  to  common
         symbols,  and suppresses the `undefined symbol' diagnos-
         tics.

     -d  force definition of common storage even if the  -r  flag
         is present.

     -n  Arrange  that when the output file is executed, the text
         portion will be read-only and shared among all users ex-
         ecuting  the  file.  This involves moving the data areas
         up the the first possible 4K word boundary following the
         end of the text.

     -i  When  the  output file is executed, the program text and
         data areas will live in separate  address  spaces.   The
         only  difference between this option and -n is that here
         the data starts at location 0.

FILES
     /lib/lib?.a   libraries
     a.out   output file

SEE ALSO
     as(I), ar(I)

BUGS

























                              - 2 -