Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ld(1) — IRIX 6.5.3f

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cc(1)

pc(1)

f77(1)

as(1)

uld(1)

ar(1)

end(3)

collide(1)

rqs(1)

dso(5)



LD(1)                                                                    LD(1)



NAME
     ld - link editor

SYNOPSIS
     ld [ option ] ... file ...

DESCRIPTION
     Ld, the link editor, links Elf object files. The archive format ld uses
     is the one created by the archiver ar(1).

     ld is normally invoked by cc(1), although it can be run separately.  When
     ld is used as part of a cc compilation, the ld options must be passed via
     the -Wl mechanism.  See cc(1) for details of -Wl.

     The ld command combines several object files into one, performs
     relocation, resolves external symbols, builds tables and relocation
     information for run-time linkage in case of shared linking, and supports
     symbol table information for symbolic debugging.  In the simplest case,
     the names of several object files are given.  ld combines them, producing
     an object module that can be executed or used as input for a subsequent
     ld run.  (In the latter case, the -r option must be given to preserve the
     relocation entries.)  The output of ld is left in a.out.  By default,
     this file is a dynamic executable if no errors occurred during the link.

     Usually, ld is invoked by the compiler driver as the final step in
     compilation.  Only under special circumstances is it necessary to run it
     separately.

     The sections within the argument object files are combined, some by
     merging and others by concatenation. The order in which this is done may
     be specified.  The entry point of the output is the first instruction in
     the text segment (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.  There are two kinds of libraries,
     archives and dynamic shared objects.  When linking with archives, only
     those routines defining an unresolved external reference are loaded.
     Shared objects are used only if the output is to be dynamic. In that
     case, only the name is used for external resolution, no object is
     included as part of the output object file.  Note, unresolved symbols are
     not considered an error when linking -shared.  The library (archive)
     symbol table (see ar(1)) is a hash table and is searched to resolved
     external references that can be satisfied by library members.  The
     ordering of library members is NOT important.

     Linking against a dynamic shared object will normally cause that object
     to be loaded at runtime (see rld(1) and dso(5)) whenever the object being
     created is loaded, thus resolving the symbols supplied by that object.
     The loading of a dynamic shared object can be delayed using the
     -delayload option.  In this case the object is not loaded until a symbol
     supplied by the object is actually referenced.  Symbols from a delay
     loaded object do not preempt symbols from other libraries; they are



                                                                        Page 1





LD(1)                                                                    LD(1)



     resolved as if the object was last on the link line.

     When searching for ucode libraries the default directories searched are
     /usr/lib/, /lib/ and /usr/local/lib/.  Note that, although archives will
     be found in /usr/local/lib/, shared objects should not be installed
     there, as they will not be found by rld(1).  When searching for 64bit
     libraries the default directories searched are /usr/lib64/, /lib64/ and
     /usr/local/lib64/.  When searching for n32 libraries the default
     directories searched are /usr/lib32/, /lib32/ and /usr/local/lib32/.

Reserved Symbols
     The symbols `.bss', `.comment', `.data', `.fini', `.init', `.lit4',
     `.lit8', `.rdata', `.sbss', `.sdata', `.text', `_BASE_ADDRESS',
     `_DYNAMIC', `_DYNAMIC_LINK', `_DYNAMIC_LINKING', `_GOT_OFFSET',
     `__dso_displacement', `__elf_header', `__fstart', `__istart',
     `__lcldta_address', `__lcldta_size', `__program_header_table',
     `__rld_obj_head', `__start', `__unwind', `_data_init_table', `_edata',
     `_end', `_etext', `_fbss', `_fdata', `_ftext', `_gp', `_gp_disp',
     `_lib_version', `_procedure_string_table', `_procedure_table',
     `_procedure_table_size', `_rld_new_interface', `_rt_symbol_string_table',
     `_rt_symbol_table', `_rt_symbol_table_size', and all symbols beginning
     with the prefixes `__elf_vaddr' and `__elf_size' are reserved.  It is
     erroneous to define these symbols.  In ANSI C the symbols `end', `edata',
     and `etext' may be user defined. (see the description of -std below.)  If
     they are not defined (but only referenced) they are assigned the same
     values as `_end', `_edata', and `_etext' respectively.  More information
     on these symbols is available in end(3C).


Symbol Resolution / Input Searchpath Options
     -lx  Search a library libx.{so,a}, where x is a string.  A shared object
          or an archive is searched when its name is encountered, so the
          placement of a -l is significant.


     -L  dir
          Change the algorithm of searching for libx.{so,a} or libx.b to look
          in dir before looking in the default directories.  This option is
          effective only if it precedes the -l options on the command line.
          Repeating for emphasis: dir must be a directory.


     -Ldir
          The same as -L  dir.


     -L   Change the algorithm of searching for libx.{so,a} or libx.b to never
          look in the default directories.  This is useful when the default
          directories for libraries should not be searched and only the
          directories specified by -Ldir are to be searched.  This option may
          be dropped from some future release in favor of the -nostdlib
          option.



                                                                        Page 2





LD(1)                                                                    LD(1)



     -nostdlib
          Change the algorithm of searching for libx.a or libx.b to never look
          in the default directories.  This is useful when the default
          directories for libraries should not be searched and only the
          directories specified by -L  dir are to be searched.


     -B [static|dynamic|symbolic]
          In dynamic mode (the default), ld searches each directory specified
          in the library search path for a file libx.so, and if not available
          then libx.a. When -B static is specified, ld selects only the files
          ending in .a (except for libc).  If it is desired to link with
          static libraries, but not all of the needed .a files are available:
          cc prog.o -o prog -B static -lXm -lXt -B dynamic -lX11 -lgen

          When -B symbolic is specified, ld inserts the element DT_SYMBOLIC
          into the .dynamic section of a shared object library and this alters
          the dynamic linker's symbol resolution algorithm for references
          within the library. Instead of starting a symbol search with the
          executable file, the dynamic linker starts from the shared object
          itself.  If the shared object fails to supply the referenced symbol,
          the dynamic linker then searches the executable file and other
          shared objects as usual.


     -u symname
          Enter symname as an undefined in the symbol table.  This is useful
          for loading entirely from a library, since initially the symbol
          table is empty and an unresolved reference is needed to force the
          loading of the first routine.


     -std Specifies that the linker should not define certain symbol names,
          e.g.  `end`, `edata`, and `etext`.


     -cckr
          Specifies that the linker should set the value of the variable
          `_lib_version` to specify non-ansi semantics to see end(3).


     -cxx Specifies special handling of certain symbols needed for proper
          linkage and execution of C++ programs.





Input Specification Options
     -from optionlistfile
          This allows one to specify arguments to ld in a file.  Read the file
          optionlistfile as if it appeared on the command line in the same



                                                                        Page 3





LD(1)                                                                    LD(1)



          position as the -from option.  Newlines in optionlistfile are
          treated as if they were ordinary spaces.


     -objectlist objectlistfile
          Read the file objectlistfile to obtain a list of files.  By putting
          the list of files in objectlistfile instead of on the command line
          one avoids exceeding the limit on the length of a command line.
          This is primarily useful when linking very large programs with many
          objects and long filenames.  The objectlistfile is  a list of file
          or archive names, one file per line.  Blank lines are silently
          ignored.  Leading white space is ignored.  A filename is considered
          ended by the next whitespace character.  Characters after the
          filename are ignored.  Any leading ``-'' in an objectlistfile line
          is considered part of a filename: nothing in the file is taken as an
          option.  Lines are in the file are limited to BUFSIZ*2 characters
          (16K bytes) each.


     -all Link in all of the objects from all archives following this flag.
          This option is commonly used in conjunction with -shared option to
          create a shared object out of an existing archive.


     -notall
          Turns off -all. This still allows objects to be pulled out of the
          archive into a DSO if these objects resolve unresolved symbols in
          the already included object, but these objects are included without
          exporting their symbols by default.


     -exclude object
          Used in conjunction with -all and -shared. The object specified will
          be excluded in making the shared object.


     -noarchive
          Requires that -l references must resolve to shared objects.
          Normally, if the shared object as specified by the -l is not found,
          the linker attempts to find the corresponding archive to resolve
          undefines. This option disallow using those archives. This is a
          synonym of -Bdynamic.




Debugging Options
     -aoutkeep
          By default, ld removes the output file if there are link errors.
          But when this flag is set, the output file will be rename to a.out .





                                                                        Page 4





LD(1)                                                                    LD(1)



     -m   Produce a map or listing of the input/output sections on the
          standard output (UNIX system V-like map).


     -M   Produce a primitive load map, listing the names of the files that
          will be loaded (UNIX 4.3bsd-like map).


     -gpinfo
          Produce a listing of short data section components (page pointers,
          GOT pointers, small data, and small literals). This may be useful in
          identifying modules with large gp relative sections. In cases where
          -multigot won't work, recompiling these modules with -G0 may allow a
          successful link.


     -v   Set verbose mode.  Print the name of each file as it is processed.


     -quickstartinfo
          Prints extra information regarding the quickstart status of the
          executable file created, including a full list of conflict symbols
          and their objects of origin.


     -ysym
          Indicate each file in which sym appears, sym's type and whether the
          file defines or references sym.  Many such options may be given to
          trace many symbols.  Each -ysym applies to those files listed after
          this option on the command line.


     -V   Print a message giving information about the version of ld being
          used.


     -f fill
          Set the fill pattern for ``holes'' within an output section.  The
          argument fill is a four-byte hexadecimal constant.


     -showunref
          Defined but unreferenced symbols will be listed.  This flag is
          useful for finding out "dead code" in a program.  Note that it is
          normal behavior for many library routines to define symbols that
          might not be referenced by all programs.  Also, in the case of weak
          and strong symbol pair where two different symbols point to the same
          virtual address, if only one of them is referenced, the other symbol
          is still listed.  This does not necessarily mean the specified
          function is never used.





                                                                        Page 5





LD(1)                                                                    LD(1)



Message Options
     -LDMSG:[msgtype=numlist][:msgtype=numlist]..
          General message handling interface for ld that allows the user to
          select the message type of the specified message numbers.  The
          numlist is a comma (',') or dash ('-') separated list of message
          numbers.

          error=numlist
               Treat each message on the numlist as an error.

          warning=numlist
               Treat each message on the numlist as a warning.

          info=numlist
               Treat each message on the numlist as an info message.

          verbose=numlist
               Treat each message on the numlist as a verbose message.

          off=numlist
               Ignore each message on the numlist.

          For example, -LDMSG:warning=33 tells the linker to treat message
          33, which by default is an error, as a warning.  Similarly,
          -LDMSG:warning=33:off=47-68 tells the linker to treat message 33 as
          a warning and to ignore all messages from 47 to 68 inclusive.

          Fatal errors can not be modified by -LDMSG:


     -U   Undefined symbols are not considered an error when this is supplied.
          As a result, one can create an executable with undefined symbols.
          Referencing an undefined symbol during execution may cause a
          segmentation fault and a core dump.


     -woff numlist
          This allows a user to specify a comma-separated list of numbers of
          warnings which the linker is to suppress.  For example, -woff
          5,17,23 turns off warnings numbered 5, 17 and 23.  If you are
          linking using the cc(1) command, this flag should be passed to the
          linker with, -Wl,-woff,5 -Wl,-woff,17 -Wl,-woff,23.


     -w   This flag specifies that all warnings are to be suppressed.


     -info
          Enable the linker to print out messages of an informational nature
          which might highlight unusual, but not illegal situations.  This is
          on by default.




                                                                        Page 6





LD(1)                                                                    LD(1)



     -noinfo
          Disable the -info level of error messages as described above.


     -demangle
          Specifies that demangling of C++ names should take place when
          printing other messages.


     -ignoreunresolved
          This option causes an executable or DSO to be produced and ld to
          exit with zero status even if there are unresolved symbols;
          resolution of these symbols will be completed by rld . If linking
          -call_shared, a list of the unresolved symbols will be output (as it
          always is for -call_shared).  If linking -shared, no such list will
          be output.  If linking -non_shared, this option is ignored (and
          -no_unresolved is used, as it always is for -non_shared).  This
          option is the default for -shared linking, but not for -call_shared
          or -non_shared.


     -nounresolved
          Unresolved symbols will be listed.  If linking -shared, a DSO will
          still be produced (as it always is for -shared) and ld will exit
          with zero status.  If linking -call_shared or -non_shared, ld will
          exit with nonzero status and no executable will be produced.  This
          option is the default for -call_shared and -non_shared link, but not
          for -shared.


     -warnunused
          This flag specifies that the linker should issue a warning if it
          finds that some object has not been used in a link.  The semantics
          of dynamic linking dictate that this cannot be determined absolutely
          at static link time, but it is usually quite reliable. This is the
          default.


     -dontwarnunused
          Turns off the warning specified by -warnunused.


     -allowmissing
          When using an ELF layout specification file with the



Stripping Options
     -s   Strip the symbolic information from the output object file.






                                                                        Page 7





LD(1)                                                                    LD(1)



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



Output Object Format Options
     -r   Retain relocation entries in the output file.  Relocation entries
          must be saved if the output file is to become an input file in a
          subsequent ld run.  This option also prevents final definitions from
          being given to common symbols, and suppresses the `undefined symbol'
          diagnostics.


     -elf Produce ELF output object file.  This is the default and currently
          the only file format supported.


     -nonshared
          Produce a static executable. The output object created will not use
          any shared objects during execution. This declares that you are
          doing non-PIC loading.


     -shared
          Produce a dynamic shared object. This includes creating all of the
          tables for run-time linking and resolving references to other
          specified shared objects.  The object created may be used by the
          linker to make dynamic executables.


     -callshared
          Produce a dynamic executable. The object created may use shared
          objects at run-time. This is the default.


     -o32 or -32
          Specifies that the object to be linked (and the input objects) are
          to be 32-bit ucode objects.


     -n32 Specifies that the object to be linked (and the input objects) are
          to be 32-bit n32 objects.


     -64  Specifies that the object to be linked (and the input objects) are
          to be 64-bit objects.


     -mips1
          Specifies that the linker should try to produce a binary that
          conforms to the MIPS 1 ISA.  If ld finds object files that are MIPS



                                                                        Page 8





LD(1)                                                                    LD(1)



          2, the resulting binary will silently be marked as being a -mips2
          binary.  ( NOTE: Because all -o32 format object files shipped by SGI
          are built -mips2 , it may not be possible to produce a -mips1
          executable.)


     -mips2
          Specifies that the linker should try to produce a binary that
          conforms to the MIPS 2 ISA.


     -mips3
          Specifies that the linker should try to produce a binary that
          conforms to the MIPS 3 ISA.  If ld finds object files that are MIPS
          4, the resulting binary will silently be marked as being a -mips4
          binary.


     -mips4
          Specifies that the linker should try to produce a binary that
          conforms to the MIPS 4 ISA.


Layout Options
     -LDLAYOUT:[type=arg][:type=arg]..
          Commands that affect object layout.

          seglign=alignval
               Defines the minimum segment alignment to be alignval. This
               value needs to be both 0x1000 or greater and a power of 2.


     -d        Force definition of common storage and define loader defined
               symbols even if -r is present.


     -z        Arrange that the process pages are loaded on demand from the
               resulting executable file rather than preloaded, and that the
               text pages are shared among all users.  This is the default.


     -multigot Create multiple Global Offset Tables. All entries in the GOT
               need to be accessible from a 16 bit offset from a common GP
               (Global Pointer). If the GOT grows too big you may get a "gp
               out of range" error at link time. This option will allow the
               linker to create multiple GOTs and GPs thus avoiding the error.
               This is position dependent and should appear before any objects
               on the command line. Having multiple GOTs will neither increase
               code size nor affect performance. This option is only usable
               with PIC code: it is not appropriate or useful with code
               compiled or linked -non_shared.




                                                                        Page 9





LD(1)                                                                    LD(1)



     -n        Arrange that when the output file is executed, the entire text
               and data portions of the executables are preloaded.  This
               involves moving the data areas up to the first possible
               pagesize byte boundary following the end of the text.  User
               must specify -non_shared when -n is used.


     -N        Place the data segment immediately after the text and do not
               make the text portion read only or sharable. Only objects
               compiled -nonshared can be linked with -N.


     -T num    Set the text segment origin.  The argument num is a hexadecimal
               number.


     -D num    Set the data segment origin.  The argument num is a hexadecimal
               number.  Please note that this switch is non-standard, and may
               not be supported across product lines.


     -B num    Set the bss segment origin.  The argument num is a hexadecimal
               number.  Please note that this switch is non-standard, and may
               not be supported across product lines.


     -G num    If the flag -_SYSTYPE_SVR4 has been specified, this flag is a
               synonym for -shared, and takes no numerical argument.
               Otherwise, The argument num is taken to be a decimal number
               that is the largest size in bytes of a .comm item that is to be
               allocated in the small bss section for reference off the global
               pointer.  The default is 8 bytes.  Please note that this switch
               is non-standard, and may not be supported across product lines.


     -rdatawritable
               Puts .rodata into the "data" segment, which has the "WRITE"
               permission.  This is the default.


     -rdatashared
               Puts .rodata into the "text" segment, where it will be shared
               across processes, and will be read-only.


     -ivpad    Improves cache behavior by causing the linker to perform
               intervariable padding of some large variables.


     -noivpad  Turns off -ivpad.





                                                                       Page 10





LD(1)                                                                    LD(1)



     -Xlocal   name,...
               Assigns the named global bss (uninitialized data) symbols to a
               special local data section in the a.out. This is useful for
               hand-parallelized Fortran programs that require this symbol to
               be private for each thread.

               A symbol assigned to the small bss or small data section of an
               object file cannot be moved to the special section. If the
               symbol gets assigned to one of small bss/data section, then
               either recompile with a smaller -G number or use the following
               pragma in your source code:
                #pragma section_non_gp(name) in C or
                c*$*section_non_gp(name) in Fortran.


     -elspec  elsfile
               This flag specifies a file to serve as an ELF layout
               specification file.  This file and its syntax are described in
               elspec(5).


     -elsmap   This flag specifies that the linker should emit a layout map in
               the form of an ELF layout specification.  The output from this
               specification can be used with the -elspec flag without
               modification.


     -checkregistry location_file
               Check the location of this shared object's segments and make
               sure they stay out of the way of others in the location_file.
               A single registry file, either with -checkregistry or
               -updateregistry is allowed.  This option is used with -shared.


     -updateregistry location_file
               Register the location of this shared object's segments and make
               sure they stay out of the way of others in the location_file.
               Location_file is updated if it is writable.  A single registry
               file, either with -checkregistry or -updateregistry is
               allowed.  This option is used with -shared. The default
               registry file is /usr/lib{,32,64}/so_locations.  See the dso(5)
               manpage for details on so_locations.




Dynamic Options
     -e epsym
          Set the default entry point address for the output file to be that
          of the symbol epsym.





                                                                       Page 11





LD(1)                                                                    LD(1)



     -I  pathname
          The path_name is a path name for the system to invoke as a program
          interpreter.  This option writes the path name into the .interp
          section.


     -defaultdelayload
          When creating a dynamic shared object using -shared, it marks that
          shared object as default delay load.


     -delayload
          Indicates that the next specified object, if it is a dynamic shared
          object, should be delay loaded.


     -forceload
          Forces the normal loading of the next specified object, overriding
          any default delay load attribute associated with that object.

          This flag is used when creating a dynamic object ( -shared or
          -callshared). It indicates that symbols from the next object,
          archive, or dynamic shared object will be exported by the object
          being created. This is the default behavior for linking in an object
          but not for archives or dynamic shared objects.


     -hides
          This flag is used when creating a dynamic object ( -shared or
          -callshared). It indicates that symbols from the next object,
          archive, or dynamic shared object will be hidden by the object being
          created. This is the default behavior for linking in archives or
          dynamic shared objects, but not for objects.


     -exportedsymbol name,...
          Used in conjunction with -shared or -callshared. This marks the
          symbol given by the list of names as exported.  If you specify any
          exported symbols, then all unspecified symbols are automatically
          hidden.


     -exportsfile filename
          Used in conjunction with -shared or -callshared. The file given by
          filename contains a list of symbols that should be exported.  The
          list is space separated (including newlines).  Any symbols not
          specifically exported will be automatically hidden.


     -hiddensymbolname,...
          Used in conjunction with -shared or -callshared. This marks the
          symbol given by the list of names as hidden.  This is ignored if any



                                                                       Page 12





LD(1)                                                                    LD(1)



          symbols are specifically marked as exported using the
          -exportedsymbol or -exportsfile options.


     -hiddensfile filename
          Used in conjunction with -shared or -callshared. The file given by
          filename contains a list of symbols that should be hidden.  The list
          is space separated (including newlines).  This list is ignored if
          any symbols are specifically marked as exported using
          -exportedsymbol or -exportsfile options.


     -transitivelink
          Normally, every shared object and every executable has a dependency
          list of shared objects which are needed for correct execution.  The
          runtime linker rld(1) will load these objects, when any process is
          run. If the depended-upon shared objects have more objects which
          they in turn depend upon, rld will add them at the end of the list,
          and so on, performing a transitive closure.

          By default a similar operation is performed at static (ld) link
          time. Any shared object which is listed on the command line is put
          on a.out's dependency list.  Then any new shared objects from the
          dependency lists of the already-processed shared objects are also
          processed and checked for conflicting definitions of symbols, but
          are not added to the list of shared objects needed by the object
          being built.  This is the default behavior.


     -notransitivelink
          Some applications may find it desirable to hide some of their
          dependent libraries.  This flag cancels the upward propagation of
          libraries to facilitate such hiding.  Executables and shared objects
          built in this way may experience slightly slower startup. If you are
          linking using the cc(1) command, this flag should be passed both to
          the driver and the linker, e.g. both -notransitivelink and
          -Wl,-notransitivelink should be used.


     -setversion version_string
          Sets the value of DT_MIPS_IVERSION field in the dynamic section of
          the shared object to "version_string".  The version string is a
          series of version strings separated by colons(:).


     -exactversion
          Set the LL_EXACT_MATCH flag in .liblist flags field. This indicates
          to rld that this shared object must match the timestamp and checksum
          from the .liblist section in addition to the interface version.
          This means that all DSOs run against must match, exactly, the
          version, timestamp, and checksum against which the app was linked
          (or rqs-d).  This means that if the object is copied to another



                                                                       Page 13





LD(1)                                                                    LD(1)



          machine it will not run unless the object is first rqs-d (because
          the other machine will surely have a different checksum/timestamp
          for things on the liblist of this object. Such as libc.so.1).  Even
          more surprising: on a mips4 machine (such as R10000) cc t.c -n32
          -mips3 -Wl,-exact_version ; ./a.out will not execute. rld will
          report a fatal error because the mips3 libc.so.1 linked against is
          not the same as the mips4 libc.so.1 against which the executable
          will run on that machine.


     -ignoreversion
          Sets the LL_IGNORE_VERSION flag in the liblist flags field. For
          subsequent shared objects in the liblist.  rld will not try to match
          the interface version as specified at link time.


     -requireminor
          Set the LL_REQUIRE_MINOR flag in the .liblist flags field for shared
          objects listed subsequently on the link line.  This indicates to rld
          that the shared object used at runtime must have the exact same
          minor (and major) version number as that at static link time.
          Otherwise, execution will abort.  See the dso(5) manpage for details
          on major and minor version numbers.


     -ignoreminor
          Clear the LL_REQUIRE_MINOR flag in the .liblist flags field for
          shared objects listed subsequently on the link line.  This allows
          rld to use a shared object at runtime which has a different minor
          version number.  This is the default behavior.  See the dso(5)
          manpage for details on major and minor version numbers.


     -nolibraryreplacement
          Turns on a flag in the dynamic section so that rld does not allow
          execution time or runtime changing of the path (except for super
          user) to find the shared objects. Typically, used for security
          purposes on system utilities.


     -rpath  librarypath
          Sets the rpath (see the generic abi ) to the specified string.
          Meaningful only for shared linkage.


     -soname shared_object_name
          Sets DT_SONAME for a shared object. Use in conjunction with -shared
          option. The name may be a single component name (e.g. libc.a), a
          full (starting with a slash), or relative pathname (containing a
          slash).  Single component name use rpath, LD_LIBRARY_PATH and the
          default paths to resolve their locations.




                                                                       Page 14





LD(1)                                                                    LD(1)



     -init ifuncsymbol
          Put a call to ifuncsymbol in the code rld will exercise before the
          main program begins.  This contains initialization code to be called
          before control is passed to main.  In the case of a dlopen'd  or
          sgidladd'd DSO, this initialization function is called after the DSO
          is loaded but before it is referenced.  Only a single -init option
          is effective in a given DSO or executable (if multiple are provided,
          the last is used).  -init is only meaningful when creating a DSO or
          creating a call-shared executable.  -init has no affect on non-
          shared links.



     -fini ffuncsymbol
          Put a call to ffuncsymbol in the code rld will exercise after the
          main program exits.  This contains termination code to be called
          after the main program exits. In the case of a dlclose'd DSO which
          is no longer referenced, this function is called before the DSO is
          unmapped.  Only a single -fini option is effective in a given DSO or
          executable (if multiple are provided, the last is used).  -fini is
          only meaningful when creating a DSO or creating a call-shared
          executable.  -fini has no affect on non-shared links.



I/O Options
     -mmap
          This specifies that the linker will use mmap(2) as its preferred
          mode for reading object files. This usually results in better I/O
          performances, except when using NFS mounted files with high network
          latencies. This is the default.


     -read
          This specifies that the linker is to use the open(2) , lseek(2) ,
          and read(2) as its preferred mode for reading object files.  Setting
          this option when many object files are remotely mounted with high
          network latency often improves performance.






Hardware Patch Options
     -nor5kjumpateop
          Works around an R5000 bug present in 1.1 silicon.  This option tries
          to prevent certain classes of branch instructions from being the
          second to last instruction on an even page of virtual memory.  This
          option is on by default.  The hinv(1) command can be used to
          determine what rev of R5000 is present in the system.




                                                                       Page 15





LD(1)                                                                    LD(1)



     -allowr5kjumpateop
          Disables the work around for the R5000 bug.  When this flag is
          present, no adjustment is attempted.  The work around is enabled by
          default, the presence of this flag before any object files will turn
          it off.  Turning off this option will result in code that is not
          compatible across platforms and may also result in a performance
          penalty some R5000 systems.


     -nojumpateop
          Works around an R4000 bug present in 2.1 and 2.2 silicon.  This
          option tries to prevent certain classes of branch instructions from
          being the last instruction on a page of virtual memory.  This option
          is on by default for links of MIPS3 or lower programs.  The hinv(1)
          command can be used to determine what rev of R4000 is present in the
          system.


     -allowjumpateop
          Disables the work around for the R4000 bug.  When this flag is
          present, no adjustment is attempted.  The work around is enabled by
          default, the presence of this flag before any object files will turn
          it off.  Turning off this option will result in code that is not
          compatible across platforms and may also result in a performance
          penalty on some R4000 systems.



Miscellaneous Options
     -o outfile
          Produce an output object file by the name outfile. The name of the
          default object file is a.out.  In the event that outfile has
          undefined references at the end of the link editor run, and the -r
          option was not used, and the -aoutkeep option was used outfile will
          be renamed a.out.  If there are undefined references and the
          -aoutkeep option was not used there will be no output from ld.


     -VS num
          Use num as the decimal version stamp to identify the a.out file that
          is produced.  The version stamp is stored in the optional and
          symbolic headers.


     -SYSTYPESVR4
          This flag alters the meaning of the -G flag to conform to the Unix
          System V Release 4 usage.  See the description below.








                                                                       Page 16





LD(1)                                                                    LD(1)



Synonym Options
     -ajeop
          This is a synonym for -allowjumpateop


     -Ldir
          The same as -L  dir.


     -L   Change the algorithm of searching for libx.{so,a} or libx.b to never
          look in the default directories.  This is useful when the default
          directories for libraries should not be searched and only the
          directories specified by -Ldir are to be searched.  This option may
          be dropped from some future release in favor of the -nostdlib
          option.


     -G   If the flag -_SYSTYPE_SVR4 has been specified, this flag is a
          synonym for -shared, and takes no numerical argument.


     -Wx,-G  num
          This is a synonym for the non-SVR4 meaning of -G


     -h   This is a synonym for -soname


     -dy  This is a synonym for -callshared


     -dn  This is a synonym for -nonshared


     -a   This is a synonym of -nonshared.


     -hidesfile filename
          This is the obsolete version of the -hiddensfile option and will
          disappear in future releases of the linker. Please change your
          makefiles to reflect this change.


     -none
          Same as -notall



FILES
     /lib/lib*.so
     /lib/lib*.a
     /usr/lib/lib*.so



                                                                       Page 17





LD(1)                                                                    LD(1)



     /usr/lib/lib*.a
     /usr/lib/so_locations
     /usr/local/lib/lib*.a   libraries

     /lib32/lib*.so
     /lib32/lib*.a
     /usr/lib32/lib*.so
     /usr/lib32/lib*.a
     /usr/lib32/so_locations
     /usr/local/lib32/lib*.a   libraries

     /lib64/lib*.so
     /lib64/lib*.a
     /usr/lib64/lib*.so
     /usr/lib64/lib*.a
     /usr/lib64/so_locations
     /usr/local/lib64/lib*.a   libraries

     a.out   output file

SEE ALSO
     cc(1), pc(1), f77(1), as(1), uld(1), ar(1), end(3), collide(1), rqs(1),
     dso(5)

NOTES
     An object's segments must not overlap and all of the object's addresses
     must be less than 0x80000000.  The stack starts at 0x80000000 and grows
     down through lower addresses therefore space should be left for it.  The
     default text segment address is 0x10000000 with the data segment
     immediately following the text segment.  The default is that the bss
     segment follows the data segment.

     When creating an executable object runnable on Unix, a.out,
     /usr/lib/crt1.o Should be the first object loaded and /usr/lib/crtn.o
     should be last following any libraries.  The compiler drivers (cc(1),
     f77(1), and pc(1)) automatically load these object files in the proper
     order. Note that if ld is invoked directly, those two objects will not be
     loaded automatically. It is the user's responsibility to specify them
     explicitly.

     A single registry file, either with -checkregistry or -updateregistry
     is allowed.  If multiple registry files are provided, all except the last
     one are silently ignored.

     Be careful when using -delayload or when linking against an object that
     was built -defaultdelayload as the symbol preemption rules are
     different: symbols are resolved from the delay loaded object as if the
     object were last on the link line.

     Archives that are built with -C produce COFF style archive headers.  The
     linker will no longer recognize such archives.




                                                                       Page 18





LD(1)                                                                    LD(1)



     The following group of options have been superseded by the -elspec
     functionality:  -Xnobsschange, -Xnosortbss, -Xsortbss, -Xndblock,
     -Xblock, -Xblockrange, -Xndlocaldata, -Xalignbss, -Xnoalignbss,
     -Xcachemisalign, -Xcachesize, -Xcachelinesize, -Xdefmovemax, -Xsetalign,
     -Xdebug. The flag -Xlocaldata has been replaced by the flag -Xlocal.


















































                                                                       Page 19



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