Contents|Index|Previous|Next

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
This command ties up C++ style constructor and destructor records. The details of the constructor representation vary from one object format to another, but usually lists of constructors and destructors appear as special sections. The CONSTRUCTORS command specifies where the linker is to place the data from these sections, relative to the rest of the linked output. Constructor data is marked by the symbol __CTOR_LIST__ at the start, and __CTOR_LIST_END at the end; destructor data is bracketed similarly, between __DTOR_LIST__ and __DTOR_LIST_END.

The compiler must arrange to actually run this code; GNU C++ calls constructors from a subroutine, __main (which it inserts automatically into the startup code for main), and destructors from _exit.

FLOAT
NOFLOAT
These keywords were used in some older linkers to request a particular math subroutine library. ld doesnt 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 for -L in Command Line 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 -( with Command Line 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 (see 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 out-put format. bfdname is one of the names used by the BFD back-end routines (see 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 -L path 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. See BFD. If you dont 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.