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.
a.outobject 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
XCOFF, the linker will automatically recognize C++ global constructors and destructors by name. For these object file formats, the
CONSTRUCTORScommand tells the linker where this information should be placed. The
CONSTRUCTORScommand is ignored for other object file formats. The symbol
__CTOR_LIST__marks the start of the global constructors, and the symbol
__DTOR_LISTmarks 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
__mainis 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
ELFwhich support multiple sections, GNU C++ will normally arrange to put the addresses of global constructors and destructors into the
.dtorssections. 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.
lddoesn'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
NOFLOATare accepted and ignored.
ldassign space to common symbols even if a relocatable output file is specified (`-r').
-Loption. You can nest calls to
INCLUDEup to 10 levels deep.
INPUT ( file, file, ... )
INPUT ( file file ... )
ldsearches 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 section Command Line Options. If you use `-lfile',
ldwill transform the name to
libfile.aas with the command line argument `-l'.
GROUP ( file, file, ... )
GROUP ( file file ... )
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 section Command Line Options.
OUTPUT ( filename )
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
OUTPUT_ARCH ( bfdname )
OUTPUT_FORMAT ( bfdname )
ldis 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 (see section BFD). The effect is identical to the effect of the `--oformat' command-line option. This selection affects only the output file; the related command
TARGETaffects primarily input files.
SEARCH_DIR ( path )
ldlooks for archive libraries.
SEARCH_DIR(path)has the same effect as `-Lpath' on the command line.
STARTUP ( filename )
TARGET ( format )
ldis 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
TARGETis specified but
OUTPUT_FORMATis not, the last
TARGETargument is also used as the default format for the
ldoutput file. See section BFD. If you don't use the
lduses the value of the environment variable
GNUTARGET, if available, to select the output file format. If that variable is also absent,
lduses the default format configured for your machine in the BFD libraries.
NOCROSSREFS ( section section ... )
ldto issue an error about any references among certain sections. In certain types of programs, particularly on embedded systems, when one section is loaded into memory, another section will not be. Any direct references between the two sections would be errors. For example, it would be an error if code in one section called a function defined in the other section. The
NOCROSSREFScommand takes a list of section names. If
lddetects any cross references between the sections, it reports an error and returns a non-zero exit status. The
NOCROSSREFScommand uses output section names, defined in the
SECTIONScommand. It does not use the names of input sections.
Go to the first, previous, next, last section, table of contents.