Print this page
7319 Need a way to turn off ld "multiple inclusion" warnings
Reviewed by: Martin Bochnig <opensxce@mail.ru>
Reviewed by: Kim Shrier <kshrier@racktopsystems.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>


   7 
   8 SYNOPSIS
   9        ld [-32 | -64] [-a | -r] [-b] [-Bdirect | nodirect]
  10        [-B dynamic | static] [-B eliminate] [-B group] [-B local]
  11        [-B reduce] [-B symbolic] [-c name] [-C] [-d y | n]
  12        [-D token,...] [-e epsym] [-f name | -F name] [-G] [-h name]
  13        [-i] [-I name] [-l x] [-L path] [-m] [-M mapfile]
  14        [-N string] [-o outfile] [-p auditlib] [-P auditlib]
  15        [-Q y | n] [-R path] [-s] [-S supportlib] [-t]
  16        [-u symname] [-V] [-Y P,dirlist] [-z absexec]
  17        [-z allextract | defaultextract | weakextract ] [-z altexec64]
  18        [-z assert-deflib ] [ -z assert-deflib=libname ]
  19        [-z combreloc | nocombreloc ] [-z defs | nodefs]
  20        [-z direct | nodirect] [-z endfiltee]
  21        [-z fatal-warnings | nofatal-warnings ] [-z finiarray=function]
  22        [-z globalaudit] [-z groupperm | nogroupperm]
  23        [-z guidance[=id1,id2...] [-z help ]
  24        [-z ignore | record] [-z initarray=function] [-z initfirst]
  25        [-z interpose] [-z lazyload | nolazyload]
  26        [-z ld32=arg1,arg2,...] [-z ld64=arg1,arg2,...]
  27        [-z loadfltr] [-z muldefs] [-z nocompstrtab] [-z nodefaultlib]
  28        [-z nodelete] [-z nodlopen] [-z nodump] [-z noldynsym]
  29        [-z nopartial] [-z noversion] [-z now] [-z origin]
  30        [-z preinitarray=function] [-z redlocsym] [-z relaxreloc]
  31        [-z rescan-now] [-z recan] [-z rescan-start ... -z rescan-end]]
  32        [-z target=sparc|x86] [-z text | textwarn | textoff]
  33        [-z verbose] [-z wrap=symbol] filename...
  34 
  35 
  36 DESCRIPTION
  37        The link-editor, ld, combines relocatable object files by resolving
  38        symbol references to symbol definitions, together with performing
  39        relocations.  ld operates in two modes, static or dynamic, as governed
  40        by the -d option. In all cases, the output of ld is left in the file
  41        a.out by default. See NOTES.
  42 
  43 
  44        In dynamic mode, -dy, the default, relocatable object files that are
  45        provided as arguments are combined to produce an executable object
  46        file. This file is linked at execution with any shared object files
  47        that are provided as arguments. If the -G option is specified,
  48        relocatable object files are combined to produce a shared object.
  49        Without the -G option, a dynamic executable is created.
  50 
  51 
  52        In static mode, -dn, relocatable object files that are provided as
  53        arguments are combined to produce a static executable file. If the -r
  54        option is specified, relocatable object files are combined to produce
  55        one relocatable object file. See Static Executables.
  56 
  57 
  58        Dynamic linking is the most common model for combining relocatable
  59        objects, and the eventual creation of processes within Solaris. This
  60        environment tightly couples the work of the link-editor and the runtime
  61        linker, ld.so.1(1).  Both of these utilities, together with their
  62        related technologies and utilities, are extensively documented in the
  63        Linker and Libraries Guide.
  64 
  65 
  66        If any argument is a library, ld by default searches the library
  67        exactly once at the point the library is encountered on the argument
  68        list. The library can be either a shared object or relocatable archive.
  69        See ar.h(3HEAD)).
  70 
  71 
  72        A shared object consists of an indivisible, whole unit that has been
  73        generated by a previous link-edit of one or more input files. When the
  74        link-editor processes a shared object, the entire contents of the
  75        shared object become a logical part of the resulting output file image.
  76        The shared object is not physically copied during the link-edit as its
  77        actual inclusion is deferred until process execution. This logical
  78        inclusion means that all symbol entries defined in the shared object
  79        are made available to the link-editing process.  See Chapter 4, Shared
  80        Objects, in Linker and Libraries Guide
  81 
  82 
  83        For an archive library, ld loads only those routines that define an
  84        unresolved external reference. ld searches the symbol table of the
  85        archive library sequentially to resolve external references that can be
  86        satisfied by library members. This search is repeated until no external
  87        references can be resolved by the archive. Thus, the order of members
  88        in the library is functionally unimportant, unless multiple library
  89        members exist that define the same external symbol. Archive libraries


 874 
 875        -z loadfltr
 876 
 877            Marks a filter to indicate that filtees must be processed
 878            immediately at runtime. Normally, filter processing is delayed
 879            until a symbol reference is bound to the filter. The runtime
 880            processing of an object that contains this flag mimics that which
 881            occurs if the LD_LOADFLTR environment variable is in effect. See
 882            the ld.so.1(1).
 883 
 884 
 885        -z muldefs
 886        --allow-multiple-definition
 887 
 888            Allows multiple symbol definitions. By default, multiple symbol
 889            definitions that occur between relocatable objects result in a
 890            fatal error condition. This option, suppresses the error condition,
 891            allowing the first symbol definition to be taken.
 892 
 893 










 894        -z nocompstrtab
 895 
 896            Disables the compression of ELF string tables. By default, string
 897            compression is applied to SHT_STRTAB sections, and to SHT_PROGBITS
 898            sections that have their SHF_MERGE and SHF_STRINGS section flags
 899            set.
 900 
 901 
 902        -z nodefaultlib
 903 
 904            Marks the object so that the runtime default library search path,
 905            used after any LD_LIBRARY_PATH or runpaths, is ignored. This option
 906            implies that all dependencies of the object can be satisfied from
 907            its runpath.
 908 
 909 
 910        -z nodelete
 911 
 912            Marks the object as non-deletable at runtime. This mode is similar
 913            to adding the object to the process by using dlopen(3C) with the


1293        accessing the old file contents to continue running. If the old file
1294        has no other links, the disk space of the removed file is freed when
1295        the last process referencing the file terminates.
1296 
1297 
1298        The behavior of ld when the file being created already exists was
1299        changed with SXCE build 43. In older versions, the existing file was
1300        rewritten in place, an approach with the potential to corrupt any
1301        running processes that is using the file. This change has an
1302        implication for output files that have multiple hard links in the file
1303        system. Previously, all links would remain intact, with all links
1304        accessing the new file contents. The new ld behavior breaks such links,
1305        with the result that only the specified output file name references the
1306        new file. All the other links continue to reference the old file. To
1307        ensure consistent behavior, applications that rely on multiple hard
1308        links to linker output files should explicitly remove and relink the
1309        other file names.
1310 
1311 
1312 
1313                               September 10, 2013                         LD(1)


   7 
   8 SYNOPSIS
   9        ld [-32 | -64] [-a | -r] [-b] [-Bdirect | nodirect]
  10        [-B dynamic | static] [-B eliminate] [-B group] [-B local]
  11        [-B reduce] [-B symbolic] [-c name] [-C] [-d y | n]
  12        [-D token,...] [-e epsym] [-f name | -F name] [-G] [-h name]
  13        [-i] [-I name] [-l x] [-L path] [-m] [-M mapfile]
  14        [-N string] [-o outfile] [-p auditlib] [-P auditlib]
  15        [-Q y | n] [-R path] [-s] [-S supportlib] [-t]
  16        [-u symname] [-V] [-Y P,dirlist] [-z absexec]
  17        [-z allextract | defaultextract | weakextract ] [-z altexec64]
  18        [-z assert-deflib ] [ -z assert-deflib=libname ]
  19        [-z combreloc | nocombreloc ] [-z defs | nodefs]
  20        [-z direct | nodirect] [-z endfiltee]
  21        [-z fatal-warnings | nofatal-warnings ] [-z finiarray=function]
  22        [-z globalaudit] [-z groupperm | nogroupperm]
  23        [-z guidance[=id1,id2...] [-z help ]
  24        [-z ignore | record] [-z initarray=function] [-z initfirst]
  25        [-z interpose] [-z lazyload | nolazyload]
  26        [-z ld32=arg1,arg2,...] [-z ld64=arg1,arg2,...]
  27        [-z loadfltr] [-z muldefs] [-z mulincl] [-z nocompstrtab] [-z nodefaultlib]
  28        [-z nodelete] [-z nodlopen] [-z nodump] [-z noldynsym]
  29        [-z nopartial] [-z noversion] [-z now] [-z origin]
  30        [-z preinitarray=function] [-z redlocsym] [-z relaxreloc]
  31        [-z rescan-now] [-z recan] [-z rescan-start ... -z rescan-end]]
  32        [-z target=sparc|x86] [-z text | textwarn | textoff]
  33        [-z verbose] [-z wrap=symbol] filename...
  34 
  35 
  36 DESCRIPTION
  37        The link-editor, ld, combines relocatable object files by resolving
  38        symbol references to symbol definitions, together with performing
  39        relocations.  ld operates in two modes, static or dynamic, as governed
  40        by the -d option. In all cases, the output of ld is left in the file
  41        a.out by default. See NOTES.
  42 
  43 
  44        In dynamic mode, -dy, the default, relocatable object files that are
  45        provided as arguments are combined to produce an executable object
  46        file. This file is linked at execution with any shared object files
  47        that are provided as arguments. If the -G option is specified,
  48        relocatable object files are combined to produce a shared object.
  49        Without the -G option, a dynamic executable is created.
  50 
  51 
  52        In static mode, -dn, relocatable object files that are provided as
  53        arguments are combined to produce a static executable file. If the -r
  54        option is specified, relocatable object files are combined to produce
  55        one relocatable object file. See Static Executables.
  56 
  57 
  58        Dynamic linking is the most common model for combining relocatable
  59        objects, and the eventual creation of processes within Solaris. This
  60        environment tightly couples the work of the link-editor and the runtime
  61        linker, ld.so.1(1).  Both of these utilities, together with their
  62        related technologies and utilities, are extensively documented in the
  63        Linker and Libraries Guide.
  64 
  65 
  66        If any argument is a library, ld by default searches the library
  67        exactly once at the point the library is first encountered on the
  68        argument list. The library can be either a shared object or relocatable
  69        archive. See ar.h(3HEAD)).
  70 
  71 
  72        A shared object consists of an indivisible, whole unit that has been
  73        generated by a previous link-edit of one or more input files. When the
  74        link-editor processes a shared object, the entire contents of the
  75        shared object become a logical part of the resulting output file image.
  76        The shared object is not physically copied during the link-edit as its
  77        actual inclusion is deferred until process execution. This logical
  78        inclusion means that all symbol entries defined in the shared object
  79        are made available to the link-editing process.  See Chapter 4, Shared
  80        Objects, in Linker and Libraries Guide
  81 
  82 
  83        For an archive library, ld loads only those routines that define an
  84        unresolved external reference. ld searches the symbol table of the
  85        archive library sequentially to resolve external references that can be
  86        satisfied by library members. This search is repeated until no external
  87        references can be resolved by the archive. Thus, the order of members
  88        in the library is functionally unimportant, unless multiple library
  89        members exist that define the same external symbol. Archive libraries


 874 
 875        -z loadfltr
 876 
 877            Marks a filter to indicate that filtees must be processed
 878            immediately at runtime. Normally, filter processing is delayed
 879            until a symbol reference is bound to the filter. The runtime
 880            processing of an object that contains this flag mimics that which
 881            occurs if the LD_LOADFLTR environment variable is in effect. See
 882            the ld.so.1(1).
 883 
 884 
 885        -z muldefs
 886        --allow-multiple-definition
 887 
 888            Allows multiple symbol definitions. By default, multiple symbol
 889            definitions that occur between relocatable objects result in a
 890            fatal error condition. This option, suppresses the error condition,
 891            allowing the first symbol definition to be taken.
 892 
 893 
 894        -z mulincl
 895 
 896            Allows multiple inclusion of the same file. By default, a warning
 897            is generated for libraries that are passed multiple times on the
 898            command line.  This option suppresses that warning, allowing -z
 899            fatal-warnings to be used when compiling code that makes multiple
 900            inclusions.  Note: When a file is specified more than once, only
 901            the first instance is included.
 902 
 903 
 904        -z nocompstrtab
 905 
 906            Disables the compression of ELF string tables. By default, string
 907            compression is applied to SHT_STRTAB sections, and to SHT_PROGBITS
 908            sections that have their SHF_MERGE and SHF_STRINGS section flags
 909            set.
 910 
 911 
 912        -z nodefaultlib
 913 
 914            Marks the object so that the runtime default library search path,
 915            used after any LD_LIBRARY_PATH or runpaths, is ignored. This option
 916            implies that all dependencies of the object can be satisfied from
 917            its runpath.
 918 
 919 
 920        -z nodelete
 921 
 922            Marks the object as non-deletable at runtime. This mode is similar
 923            to adding the object to the process by using dlopen(3C) with the


1303        accessing the old file contents to continue running. If the old file
1304        has no other links, the disk space of the removed file is freed when
1305        the last process referencing the file terminates.
1306 
1307 
1308        The behavior of ld when the file being created already exists was
1309        changed with SXCE build 43. In older versions, the existing file was
1310        rewritten in place, an approach with the potential to corrupt any
1311        running processes that is using the file. This change has an
1312        implication for output files that have multiple hard links in the file
1313        system. Previously, all links would remain intact, with all links
1314        accessing the new file contents. The new ld behavior breaks such links,
1315        with the result that only the specified output file name references the
1316        new file. All the other links continue to reference the old file. To
1317        ensure consistent behavior, applications that rely on multiple hard
1318        links to linker output files should explicitly remove and relink the
1319        other file names.
1320 
1321 
1322 
1323                                 August 24, 2016                          LD(1)