Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ld(1) — UTek W2.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

as(1)

ar(1)

cc(1)

ranlib(1)



LD(1)                   COMMAND REFERENCE                   LD(1)



NAME
     ld - link editor

SYNOPSIS
     ld [ -d ] [ -e ] [ -n ] [ -o ] [ -r ] [ -s ] [ -t ] [ -u ] [
     -x ] [ -y sym ] [ -z ] [ -A ] [ -D ] [ -G ] [ -M ] [ -N ] [
     -P pagesize ] [ -S ] [ -T ] [ -X ] filename... [ -lx ]

DESCRIPTION
     Ld combines several object programs into one, resolves
     external references, and searches libraries.  In the
     simplest case several object files are given, and ld
     combines them, producing an object module which can be
     either 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
     specified. The entry point of the output is the beginning of
     the first routine (unless the -e option is specified).

     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
     routine in the library, and the library has not been
     processed by ranlib(1), the referenced routine must appear
     after the referencing routine in the library.  Thus the
     order of programs within libraries may be important.  The
     first member of a library should be a file named
     `__.SYMDEF', which is understood to be a dictionary for the
     library as produced by ranlib(1); the dictionary is searched
     iteratively to satisfy as many references as possible.

     The symbols `_etext', `_edata' and `_end' (`etext', `edata'
     and `end' in C) are reserved, and if referred to, are set to
     the first location above the program, the first location
     above initialized data, and the first location above all
     data respectively.  It is erroneous to define these symbols.

OPTIONS
     Ld understands several options.  Except for -l, they should
     appear before the file names.

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

     -e  The following argument is taken to be the name of the
         entry point of the loaded program; location 0 is the
         default.



Printed 10/17/86                                                1





LD(1)                   COMMAND REFERENCE                   LD(1)



     -lx This option is an abbreviation for the library name
         "libx.a", where x is a string.  Ld finds this library by
         looking in the directories named in the environment
         variable LIBPATH.  If LIBPATH has not been set, it takes
         the default value of "/lib /usr/lib /usr/local/lib".  A
         library is searched when its name is encountered, so the
         placement of a -l is significant.

     -n  Arrange (by giving the output file a 0410 "magic
         number") that when the output file is executed, the text
         portion will be read-only and shared among all users
         executing the file.  This involves moving the data areas
         up to the first possible "page size" boundary following
         the end of the text.

     -o  The name argument after -o is used as the name of the ld
         output file, instead of a.out.

     -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'
         diagnostics.

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

     -t  execution trace. Probably only useful for debugging the
         loader.

     -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.

     -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.

     -ysym
         Indicate each file in which sym appears, its type and
         whether the file defines or references it.  Many such
         options may be given to trace many symbols.  (It is
         usually necessary to begin sym with an `_', as external
         C, FORTRAN and Pascal variables begin with underscores.)

     -z  Arrange for the process to be loaded on demand from the
         resulting executable file (413 format) rather than
         preloading by default.  Results in a "page size" byte



Printed 10/17/86                                                2





LD(1)                   COMMAND REFERENCE                   LD(1)



         header on the output file followed by a text and data
         segment each of which have size a multiple of "page
         size" (being padded out with nulls in the file if
         necessary).  With this format the first few BSS segment
         symbols may actually appear (from the output of size(1))
         to live in the data segment; this to avoid wasting the
         space resulting from data segment size roundup.

     -A  This option specifies incremental loading, i.e.  linking
         is to be done in a manner so that the resulting object
         may be read into an already executing program.  The next
         argument is the name of a file whose symbol table will
         be taken as a basis on which to define additional
         symbols.  Only newly linked material will be entered
         into the text and data portions of a.out, but the new
         symbol table will reflect every symbol defined before
         and after the incremental load.  This argument must
         appear before any other object file in the argument
         list.  The -T option may be used as well, and will be
         taken to mean that the newly linked segment will
         commence at the corresponding address (which must be a
         multiple of "page size").  The default value is the old
         value of _end.

     -D  Take the next argument as a hexadecimal number and pad
         the data segment with zero bytes to the indicated
         length.

     -G  Take the next argument as a hexadecimal number and use
         it as the base address of the bss segment. (Useful for
         ROM based code).

     -M  produce a primitive load map, listing the names of the
         files which will be loaded.

     -N  Do not make the text portion read only or sharable. (Use
         "magic number" 0407.)

     -P  The next argument is a decimal number which sets the
         page size of target system.  If this flag is not used,
         the page size will be set to that of the host system,
         normally 1024.

     -S  `Strip' the output by removing all symbols except locals
         and globals.

     -T  The next argument is a hexadecimal number which sets the
         text segment origin.  The default origin is 0.

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



Printed 10/17/86                                                3





LD(1)                   COMMAND REFERENCE                   LD(1)



         local to routines.

VARIABLES
     LIBPATH        The -l search path,  an ordered list of
                    directories, separated by colons and/or
                    whitespace.

FILES
     /lib/lib*.a              libraries

     /usr/lib/lib*.a          more libraries

     /usr/local/lib/lib*.a    still more libraries

     a.out                    output file

CAVEATS
     There is no way to force data to be page aligned.

SEE ALSO
     as(1), ar(1), cc(1), ranlib(1).


































Printed 10/17/86                                                4





































































%%index%%
na:72,52;
sy:124,553;
de:677,1976;
op:2653,440;3237,2795;6176,2614;8934,29;
fi:9192,296;
va:8963,229;
ca:9488,106;
se:9594,151;
%%index%%000000000161

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026