mixed in with command‐line options, except that an object file argument may not be placed between an
option and its argument.
Usually the linker is invoked with at least one object file, but you can specify other forms of binary input files using -l, -R, and the script command language. If no binary input files at all are specified, the
linker does not produce any output, and issues the message No input files.
If the linker cannot recognize the format of an object file, it will assume that it is a linker script. A script specified in this way augments the main linker script used for the link (either the default linker
script or the one specified by using -T). This feature permits the linker to link against a file which appears to be an object or an archive, but actually merely defines some symbol values, or uses "INPUT" or "GROUP"
to load other objects. Specifying a script in this way merely augments the main linker script, with the extra commands placed after the main script; use the -T option to replace the default linker script entirely,
but note the effect of the "INSERT" command.
For options whose names are a single letter, option arguments must either follow the option letter without intervening whitespace, or be given as separate arguments immediately following the option that requires them.
For options whose names are multiple letters, either one dash or two can precede the option name; for example, -trace-symbol and --trace-symbol are equivalent. Note---there is one exception to this rule. Multiple
letter options that start with a lower case ’o’ can only be preceded by two dashes. This is to reduce confusion with the -o option. So for example -omagic sets the output file name to magic whereas --omagic sets the
NMAGIC flag on the output.
Arguments to multiple‐letter options must either be separated from the option name by an equals sign, or be given as separate arguments immediately following the option that requires them. For example, --trace-symbol
foo and --trace-symbol=foo are equivalent. Unique abbreviations of the names of multiple‐letter options are accepted.
Note---if the linker is being invoked indirectly, via a compiler driver (e.g. gcc) then all the linker command‐line options should be prefixed by -Wl, (or whatever is appropriate for the particular compiler driver)
like this:
gcc -Wl,--start-group foo.o bar.o -Wl,--end-group
This is important, because otherwise the compiler driver program may silently drop the linker options, resulting in a bad link. Confusion may also arise when passing options that require values through a driver, as
the use of a space between option and argument acts as a separator, and causes the driver to pass only the option to the linker and the argument to the compiler. In this case, it is simplest to use the joined forms
of both single- and multiple‐letter options, such as:
gcc foo.o bar.o -Wl,-eENTRY -Wl,-Map=a.map
Here is a table of the generic command‐line switches accepted by the GNU linker:
@file
Read command‐line options from file. The options read are inserted in place of the original @file option. If file does not exist, or cannot be read, then the option will be treated literally, and not removed.
Options in file are separated by whitespace. A whitespace character may be included in an option by surrounding the entire option in either single or double quotes. Any character (including a backslash) may be
included by prefixing the character to be included with a backslash. The file may itself contain additional @file options; any such options will be processed recursively.
-a keyword
This option is supported for HP/UX compatibility. The keyword argument must be one of the strings archive, shared, or default. -aarchive is