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. - <b>option commands</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Option Commands
===============

   The command language includes a number of other commands that you can
use for specialized purposes.  They are similar in purpose to
command-line options.

`CONSTRUCTORS'
     When linking using the `a.out' object file format, the linker uses
     an unusual set construct to support C++ global constructors and
     destructors.  When linking object file formats which do not support
     arbitrary sections, such as `ECOFF' and `XCOFF', the linker will
     automatically recognize C++ global constructors and destructors by
     name.  For these object file formats, the `CONSTRUCTORS' command
     tells the linker where this information should be placed.  The
     `CONSTRUCTORS' command is ignored for other object file formats.

     The symbol `__CTOR_LIST__' marks the start of the global
     constructors, and the symbol `__DTOR_LIST' marks the end.  The
     first word in the list is the number of entries, followed by the
     address of each constructor or destructor, followed by a zero
     word.  The compiler must arrange to actually run the code.  For
     these object file formats GNU C++ calls constructors from a
     subroutine `__main'; a call to `__main' is automatically inserted
     into the startup code for `main'.  GNU C++ runs destructors either
     by using `atexit', or directly from the function `exit'.

     For object file formats such as `COFF' or `ELF' which support
     multiple sections, GNU C++ will normally arrange to put the
     addresses of global constructors and destructors into the `.ctors'
     and `.dtors' sections.  Placing the following sequence into your
     linker script will build the sort of table which the GNU C++
     runtime code expects to see.

                __CTOR_LIST__ = .;
                LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
                *(.ctors)
                LONG(0)
                __CTOR_END__ = .;
                __DTOR_LIST__ = .;
                LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
                *(.dtors)
                LONG(0)
                __DTOR_END__ = .;

     Normally the compiler and linker will handle these issues
     automatically, and you will not need to concern yourself with
     them.  However, you may need to consider this if you are using C++
     and writing your own linker scripts.

`FLOAT'
`NOFLOAT'
     These keywords were used in some older linkers to request a
     particular math subroutine library.  `ld' doesn't use the
     keywords, assuming instead that any necessary subroutines are in
     libraries specified using the general mechanisms for linking to
     archives; but to permit the use of scripts that were written for
     the older linkers, the keywords `FLOAT' and `NOFLOAT' are accepted
     and ignored.

`FORCE_COMMON_ALLOCATION'
     This command has the same effect as the `-d' command-line option:
     to make `ld' assign space to common symbols even if a relocatable
     output file is specified (`-r').

`INPUT ( FILE, FILE, ... )'
`INPUT ( FILE FILE ... )'
     Use this command to include binary input files in the link, without
     including them in a particular section definition.  Specify the
     full name for each FILE, including `.a' if required.

     `ld' searches for each FILE through the archive-library search
     path, just as for files you specify on the command line.  See the
     description of `-L' in Command Line Options: Options    

     If you use `-lFILE', `ld' will transform the name to `libFILE.a'
     as with the command line argument `-l'.

`GROUP ( FILE, FILE, ... )'
`GROUP ( FILE FILE ... )'
     This command is like `INPUT', except that the named files should
     all be archives, and they are searched repeatedly until no new
     undefined references are created.  See the description of `-(' in
     Command Line Options: Options    

`OUTPUT ( FILENAME )'
     Use this command to name the link output file FILENAME.  The
     effect of `OUTPUT(FILENAME)' is identical to the effect of
     `-o FILENAME', which overrides it.  You can use this command to
     supply a default output-file name other than `a.out'.

`OUTPUT_ARCH ( BFDNAME )'
     Specify a particular output machine architecture, with one of the
     names used by the BFD back-end routines (BFD:.).  This   
     command is often unnecessary; the architecture is most often set
     implicitly by either the system BFD configuration or as a side
     effect of the `OUTPUT_FORMAT' command.

`OUTPUT_FORMAT ( BFDNAME )'
     When `ld' is configured to support multiple object code formats,
     you can use this command to specify a particular output format.
     BFDNAME is one of the names used by the BFD back-end routines
     (BFD:.).  The effect is identical to the effect of the   
     `-oformat' command-line option.  This selection affects only the
     output file; the related command `TARGET' affects primarily input
     files.

`SEARCH_DIR ( PATH )'
     Add PATH to the list of paths where `ld' looks for archive
     libraries.  `SEARCH_DIR(PATH)' has the same effect as `-LPATH' on
     the command line.

`STARTUP ( FILENAME )'
     Ensure that FILENAME is the first input file used in the link
     process.

`TARGET ( FORMAT )'
     When `ld' is configured to support multiple object code formats,
     you can use this command to change the input-file object code
     format (like the command-line option `-b' or its synonym
     `-format').  The argument FORMAT is one of the strings used by BFD
     to name binary formats.  If `TARGET' is specified but
     `OUTPUT_FORMAT' is not, the last `TARGET' argument is also used as
     the default format for the `ld' output file.  BFD:.   

     If you don't use the `TARGET' command, `ld' uses the value of the
     environment variable `GNUTARGET', if available, to select the
     output file format.  If that variable is also absent, `ld' uses
     the default format configured for your machine in the BFD
     libraries.


See Also: Options Options BFD BFD BFD

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