Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The GNU linker. - create a global symbol in the output file, containing the absolute http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
     Create a global symbol in the output file, containing the absolute
     address given by EXPRESSION.  You may use this option as many
     times as necessary to define multiple symbols in the command line.
     A limited form of arithmetic is supported for the EXPRESSION in
     this context: you may give a hexadecimal constant or the name of
     an existing symbol, or use `+' and `-' to add or subtract
     hexadecimal constants or symbols.  If you need more elaborate
     expressions, consider using the linker command language from a
     script (*note Assignment: Symbol Definitions: Assignment.).
     *Note:*  there should be no white space between SYMBOL, the equals
     sign ("="), and EXPRESSION.

`--dynamic-linker FILE'
     Set the name of the dynamic linker.  This is only meaningful when
     generating dynamically linked ELF executables.  The default dynamic
     linker is normally correct; don't use this unless you know what
     you are doing.

`-EB'
     Link big-endian objects.  This affects the default output format.

`-EL'
     Link little-endian objects.  This affects the default output
     format.

`-embedded-relocs'
     This option is only meaningful when linking MIPS embedded PIC code,
     generated by the -membedded-pic option to the GNU compiler and
     assembler.  It causes the linker to create a table which may be
     used at runtime to relocate any data which was statically
     initialized to pointer values.  See the code in testsuite/ld-empic
     for details.

`--help'
     Print a summary of the command-line options on the standard output
     and exit.

`-Map MAPFILE'
     Print to the file MAPFILE a link map--diagnostic information about
     where symbols are mapped by `ld', and information on global common
     storage allocation.

`--no-keep-memory'
     `ld' normally optimizes for speed over memory usage by caching the
     symbol tables of input files in memory.  This option tells `ld' to
     instead optimize for memory usage, by rereading the symbol tables
     as necessary.  This may be required if `ld' runs out of memory
     space while linking a large executable.

`--no-whole-archive'
     Turn off the effect of the `--whole-archive' option for subsequent
     archive files.

`--noinhibit-exec'
     Retain the executable output file whenever it is still usable.
     Normally, the linker will not produce an output file if it
     encounters errors during the link process; it exits without
     writing an output file when it issues any error whatsoever.

`-oformat OUTPUT-FORMAT'
     `ld' may be configured to support more than one kind of object
     file.  If your `ld' is configured this way, you can use the
     `-oformat' option to specify the binary format for the output
     object file.  Even when `ld' is configured to support alternative
     object formats, you don't usually need to specify this, as `ld'
     should be configured to produce as a default output format the most
     usual format on each machine.  OUTPUT-FORMAT is a text string, the
     name of a particular format supported by the BFD libraries.  (You
     can list the available binary formats with `objdump -i'.)  The
     script command `OUTPUT_FORMAT' can also specify the output format,
     but this option overrides it.  BFD:.   

`-qmagic'
     This option is ignored for Linux compatibility.

`-Qy'
     This option is ignored for SVR4 compatibility.

`--relax'
     An option with machine dependent effects.  This option is only
     supported on a few targets.  `ld' and the H8/300: H8/300    
     `ld' and the Intel 960 family: i960    

     On some platforms, the `--relax' option performs global
     optimizations that become possible when the linker resolves
     addressing in the program, such as relaxing address modes and
     synthesizing new instructions in the output object file.

     On platforms where this is not supported, `-relax' is accepted, but
     ignored.

`--retain-symbols-file FILENAME'
     Retain *only* the symbols listed in the file FILENAME, discarding
     all others.  FILENAME is simply a flat file, with one symbol name
     per line.  This option is especially useful in environments (such
     as VxWorks) where a large global symbol table is accumulated
     gradually, to conserve run-time memory.

     `-retain-symbols-file' does *not* discard undefined symbols, or
     symbols needed for relocations.

     You may only specify `-retain-symbols-file' once in the command
     line.  It overrides `-s' and `-S'.

`-rpath DIR'
     Add a directory to the runtime library search path.  This is used
     when linking an ELF executable with shared objects.  All `-rpath'
     arguments are concatenated and passed to the runtime linker, which
     uses them to locate shared objects at runtime.  The `-rpath'
     option is also used when locating shared objects which are needed
     by shared objects explicitly included in the link; see the
     description of the `-rpath-link' option.  If `-rpath' is not used
     when linking an ELF executable, the contents of the environment
     variable `LD_RUN_PATH' will be used if it is defined.

     The `-rpath' option may also be used on SunOS.  By default, on
     SunOS, the linker will form a runtime search patch out of all the
     `-L' options it is given.  If a `-rpath' option is used, the
     runtime search path will be formed exclusively using the `-rpath'
     options, ignoring the `-L' options.  This can be useful when using
     gcc, which adds many `-L' options which may be on NFS mounted
     filesystems.

     For compatibility with other ELF linkers, if the `-R' option is
     followed by a directory name, rather than a file name, it is
     treated as the `-rpath' option.

`-rpath-link DIR'
     When using ELF or SunOS, one shared library may require another.
     This happens when an `ld -shared' link includes a shared library
     as one of the input files.

     When the linker encounters such a dependency when doing a
     non-shared, non-relocateable link, it will automatically try to
     locate the required shared library and include it in the link, if
     it is not included explicitly.  In such a case, the `-rpath-link'
     option specifies the first set of directories to search.  The
     `-rpath-link' option may specify a sequence of directory names
     either by specifying a list of names separated by colons, or by
     appearing multiple times.

     The linker uses the following search paths to locate required
     shared libraries.
       1. Any directories specified by `-rpath-link' options.

       2. Any directories specified by `-rpath' options.  The difference
          between `-rpath' and `-rpath-link' is that directories
          specified by `-rpath' options are included in the executable
          and used at runtime, whereas the `-rpath-link' option is only
          effective at link time.

       3. On an ELF system, if the `-rpath' and `rpath-link' options
          were not used, search the contents of the environment variable
          `LD_RUN_PATH'.

       4. On SunOS, if the `-rpath' option was not used, search any
          directories specified using `-L' options.

       5. For a native linker, the contents of the environment variable
          `LD_LIBRARY_PATH'.

       6. The default directories, normally `/lib' and `/usr/lib'.

     If the required shared library is not found, the linker will issue
     a warning and continue with the link.

`-shared'
`-Bshareable'
     Create a shared library.  This is currently only supported on ELF,
     XCOFF and SunOS platforms.  On SunOS, the linker will
     automatically create a shared library if the `-e' option is not
     used and there are undefined symbols in the link.

`--sort-common'
     This option tells `ld' to sort the common symbols by size when it
     places them in the appropriate output sections.  First come all
     the one byte symbols, then all the two bytes, then all the four
     bytes, and then everything else.  This is to prevent gaps between
     symbols due to alignment constraints.

`--split-by-file'
     Similar to `--split-by-reloc' but creates a new output section for
     each input file.

`--split-by-reloc COUNT'
     Trys to creates extra sections in the output file so that no single
     output section in the file contains more than COUNT relocations.
     This is useful when generating huge relocatable for downloading
     into certain real time kernels with the COFF object file format;
     since COFF cannot represent more than 65535 relocations in a
     single section.  Note that this will fail to work with object file
     formats which do not support arbitrary sections.  The linker will
     not split up individual input sections for redistribution, so if a
     single input section contains more than COUNT relocations one
     output section will contain that many relocations.

`--stats'
     Compute and display statistics about the operation of the linker,
     such as execution time and memory usage.

`-traditional-format'
     For some targets, the output of `ld' is different in some ways from
     the output of some existing linker.  This switch requests `ld' to
     use the traditional format instead.

     For example, on SunOS, `ld' combines duplicate entries in the
     symbol string table.  This can reduce the size of an output file
     with full debugging information by over 30 percent.
     Unfortunately, the SunOS `dbx' program can not read the resulting
     program (`gdb' has no trouble).  The `-traditional-format' switch
     tells `ld' to not combine duplicate entries.

`-Tbss ORG'
`-Tdata ORG'
`-Ttext ORG'
     Use ORG as the starting address for--respectively--the `bss',
     `data', or the `text' segment of the output file.  ORG must be a
     single hexadecimal integer; for compatibility with other linkers,
     you may omit the leading `0x' usually associated with hexadecimal
     values.

`-Ur'
     For anything other than C++ programs, this option is equivalent to
     `-r': it generates relocatable output--i.e., an output file that
     can in turn serve as input to `ld'.  When linking C++ programs,
     `-Ur' *does* resolve references to constructors, unlike `-r'.  It
     does not work to use `-Ur' on files that were themselves linked
     with `-Ur'; once the constructor table has been built, it cannot
     be added to.  Use `-Ur' only for the last partial link, and `-r'
     for the others.

`--verbose'
     Display the version number for `ld' and list the linker emulations
     supported.  Display which input files can and cannot be opened.
     Display the linker script if using a default builtin script.

`-warn-common'
     Warn when a common symbol is combined with another common symbol
     or with a symbol definition.  Unix linkers allow this somewhat
     sloppy practice, but linkers on some other operating systems do
     not.  This option allows you to find potential problems from
     combining global symbols.  Unfortunately, some C libraries use
     this practice, so you may get some warnings about symbols in the
     libraries as well as in your programs.

     There are three kinds of global symbols, illustrated here by C
     examples:

    `int i = 1;'
          A definition, which goes in the initialized data section of
          the output file.

    `extern int i;'
          An undefined reference, which does not allocate space.  There
          must be either a definition or a common symbol for the
          variable somewhere.

    `int i;'
          A common symbol.  If there are only (one or more) common
          symbols for a variable, it goes in the uninitialized data
          area of the output file.  The linker merges multiple common
          symbols for the same variable into a single symbol.  If they
          are of different sizes, it picks the largest size.  The
          linker turns a common symbol into a declaration, if there is
          a definition of the same variable.

     The `-warn-common' option can produce five kinds of warnings.  Each
     warning consists of a pair of lines: the first describes the
     symbol just encountered, and the second describes the previous
     symbol encountered with the same name.  One or both of the two
     symbols will be a common symbol.

       1. Turning a common symbol into a reference, because there is
          already a definition for the symbol.
               FILE(SECTION): warning: common of `SYMBOL'
                  overridden by definition
               FILE(SECTION): warning: defined here

       2. Turning a common symbol into a reference, because a later
          definition for the symbol is encountered.  This is the same
          as the previous case, except that the symbols are encountered
          in a different order.
               FILE(SECTION): warning: definition of `SYMBOL'
                  overriding common
               FILE(SECTION): warning: common is here

       3. Merging a common symbol with a previous same-sized common
          symbol.
               FILE(SECTION): warning: multiple common
                  of `SYMBOL'
               FILE(SECTION): warning: previous common is here

       4. Merging a common symbol with a previous larger common symbol.
               FILE(SECTION): warning: common of `SYMBOL'
                  overridden by larger common
               FILE(SECTION): warning: larger common is here

       5. Merging a common symbol with a previous smaller common
          symbol.  This is the same as the previous case, except that
          the symbols are encountered in a different order.
               FILE(SECTION): warning: common of `SYMBOL'
                  overriding smaller common
               FILE(SECTION): warning: smaller common is here

`-warn-constructors'
     Warn if any global constructors are used.  This is only useful for
     a few object file formats.  For formats like COFF or ELF, the
     linker can not detect the use of global constructors.

`-warn-multiple-gp'
     Warn if multiple global pointer values are required in the output
     file.  This is only meaningful for certain processors, such as the
     Alpha.  Specifically, some processors put large-valued constants
     in a special section.  A special register (the global pointer)
     points into the middle of this section, so that constants can be
     loaded efficiently via a base-register relative addressing mode.
     Since the offset in base-register relative mode is fixed and
     relatively small (e.g., 16 bits), this limits the maximum size of
     the constant pool.  Thus, in large programs, it is often necessary
     to use multiple global pointer values in order to be able to
     address all possible constants.  This option causes a warning to
     be issued whenever this case occurs.

`-warn-once'
     Only warn once for each undefined symbol, rather than once per
     module which refers to it.

`--whole-archive'
     For each archive mentioned on the command line after the
     `--whole-archive' option, include every object file in the archive
     in the link, rather than searching the archive for the required
     object files.  This is normally used to turn an archive file into
     a shared library, forcing every object to be included in the
     resulting shared library.  This option may be used more than once.

`--wrap SYMBOL'
     Use a wrapper function for SYMBOL.  Any undefined reference to
     SYMBOL will be resolved to `__wrap_SYMBOL'.  Any undefined
     reference to `__real_SYMBOL' will be resolved to SYMBOL.

     This can be used to provide a wrapper for a system function.  The
     wrapper function should be called `__wrap_SYMBOL'.  If it wishes
     to call the system function, it should call `__real_SYMBOL'.

     Here is a trivial example:

          void *
          __wrap_malloc (int c)

See Also: BFD H8/300 i960 Options (Cont.) 1

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson