Previous: Options, Up: Invocation


2.2 Environment Variables

You can change the behaviour of ld with the environment variables GNUTARGET, LDEMULATION and COLLECT_NO_DEMANGLE.

GNUTARGET determines the input-file object format if you don't use ‘-b’ (or its synonym ‘--format’). Its value should be one of the BFD names for an input format (see BFD). If there is no GNUTARGET in the environment, ld uses the natural format of the target. If GNUTARGET is set to default then BFD attempts to discover the input format by examining binary input files; this method often succeeds, but there are potential ambiguities, since there is no method of ensuring that the magic number used to specify object-file formats is unique. However, the configuration procedure for BFD on each system places the conventional format for that system first in the search-list, so ambiguities are resolved in favor of convention.

LDEMULATION determines the default emulation if you don't use the ‘-m’ option. The emulation can affect various aspects of linker behaviour, particularly the default linker script. You can list the available emulations with the ‘--verbose’ or ‘-V’ options. If the ‘-m’ option is not used, and the LDEMULATION environment variable is not defined, the default emulation depends upon how the linker was configured.

Normally, the linker will default to demangling symbols. However, if COLLECT_NO_DEMANGLE is set in the environment, then it will default to not demangling symbols. This environment variable is used in a similar fashion by the gcc linker wrapper program. The default may be overridden by the ‘--demangle’ and ‘--no-demangle’ options.