📄 options.html
字号:
to prepend an underscore.
<p>This option is useful when you have an undefined symbol in your link but
don't know where the reference is coming from.
<br><dt><code>-Y </code><var>path</var><code></code>
<dd>Add <var>path</var> to the default library search path. This option exists
for Solaris compatibility.
<br><dt><code>-z </code><var>keyword</var><code></code>
<dd>The recognized keywords are <code>initfirst</code>, <code>interpose</code>,
<code>loadfltr</code>, <code>nodefaultlib</code>, <code>nodelete</code>, <code>nodlopen</code>,
<code>nodump</code>, <code>now</code>, <code>origin</code>, <code>combreloc</code>, <code>nocombreloc</code>
and <code>nocopyreloc</code>.
The other keywords are
ignored for Solaris compatibility. <code>initfirst</code> marks the object
to be initialized first at runtime before any other objects.
<code>interpose</code> marks the object that its symbol table interposes
before all symbols but the primary executable. <code>loadfltr</code> marks
the object that its filtees be processed immediately at runtime.
<code>nodefaultlib</code> marks the object that the search for dependencies
of this object will ignore any default library search paths.
<code>nodelete</code> marks the object shouldn't be unloaded at runtime.
<code>nodlopen</code> marks the object not available to <code>dlopen</code>.
<code>nodump</code> marks the object can not be dumped by <code>dldump</code>.
<code>now</code> marks the object with the non-lazy runtime binding.
<code>origin</code> marks the object may contain $ORIGIN.
<code>defs</code> disallows undefined symbols.
<code>muldefs</code> allows multiple definitions.
<code>combreloc</code> combines multiple reloc sections and sorts them
to make dynamic symbol lookup caching possible.
<code>nocombreloc</code> disables multiple reloc sections combining.
<code>nocopyreloc</code> disables production of copy relocs.
<br><dt><code>-( </code><var>archives</var><code> -)</code>
<dd><dt><code>--start-group </code><var>archives</var><code> --end-group</code>
<dd>The <var>archives</var> should be a list of archive files. They may be
either explicit file names, or <code>-l</code> options.
<p>The specified archives are searched repeatedly until no new undefined
references are created. Normally, an archive is searched only once in
the order that it is specified on the command line. If a symbol in that
archive is needed to resolve an undefined symbol referred to by an
object in an archive that appears later on the command line, the linker
would not be able to resolve that reference. By grouping the archives,
they all be searched repeatedly until all possible references are
resolved.
<p>Using this option has a significant performance cost. It is best to use
it only when there are unavoidable circular references between two or
more archives.
<br><dt><code>-assert </code><var>keyword</var><code></code>
<dd>This option is ignored for SunOS compatibility.
<br><dt><code>-Bdynamic</code>
<dd><dt><code>-dy</code>
<dd><dt><code>-call_shared</code>
<dd>Link against dynamic libraries. This is only meaningful on platforms
for which shared libraries are supported. This option is normally the
default on such platforms. The different variants of this option are
for compatibility with various systems. You may use this option
multiple times on the command line: it affects library searching for
<code>-l</code> options which follow it.
<br><dt><code>-Bgroup</code>
<dd>Set the <code>DF_1_GROUP</code> flag in the <code>DT_FLAGS_1</code> entry in the dynamic
section. This causes the runtime linker to handle lookups in this
object and its dependencies to be performed only inside the group.
<code>--no-undefined</code> is implied. This option is only meaningful on ELF
platforms which support shared libraries.
<br><dt><code>-Bstatic</code>
<dd><dt><code>-dn</code>
<dd><dt><code>-non_shared</code>
<dd><dt><code>-static</code>
<dd>Do not link against shared libraries. This is only meaningful on
platforms for which shared libraries are supported. The different
variants of this option are for compatibility with various systems. You
may use this option multiple times on the command line: it affects
library searching for <code>-l</code> options which follow it.
<br><dt><code>-Bsymbolic</code>
<dd>When creating a shared library, bind references to global symbols to the
definition within the shared library, if any. Normally, it is possible
for a program linked against a shared library to override the definition
within the shared library. This option is only meaningful on ELF
platforms which support shared libraries.
<br><dt><code>--check-sections</code>
<dd><dt><code>--no-check-sections</code>
<dd>Asks the linker <em>not</em> to check section addresses after they have
been assigned to see if there any overlaps. Normally the linker will
perform this check, and if it finds any overlaps it will produce
suitable error messages. The linker does know about, and does make
allowances for sections in overlays. The default behaviour can be
restored by using the command line switch <code>--check-sections</code>.
<br><dt><code>--cref</code>
<dd>Output a cross reference table. If a linker map file is being
generated, the cross reference table is printed to the map file.
Otherwise, it is printed on the standard output.
<p>The format of the table is intentionally simple, so that it may be
easily processed by a script if necessary. The symbols are printed out,
sorted by name. For each symbol, a list of file names is given. If the
symbol is defined, the first file listed is the location of the
definition. The remaining files contain references to the symbol.
<br><dt><code>--no-define-common</code>
<dd>This option inhibits the assignment of addresses to common symbols.
The script command <code>INHIBIT_COMMON_ALLOCATION</code> has the same effect.
See <a href="Miscellaneous-Commands.html#Miscellaneous%20Commands">Miscellaneous Commands</a>.
<p>The <code>--no-define-common</code> option allows decoupling
the decision to assign addresses to Common symbols from the choice
of the output file type; otherwise a non-Relocatable output type
forces assigning addresses to Common symbols.
Using <code>--no-define-common</code> allows Common symbols that are referenced
from a shared library to be assigned addresses only in the main program.
This eliminates the unused duplicate space in the shared library,
and also prevents any possible confusion over resolving to the wrong
duplicate when there are many dynamic modules with specialized search
paths for runtime symbol resolution.
<br><dt><code>--defsym </code><var>symbol</var><code>=</code><var>expression</var><code></code>
<dd>Create a global symbol in the output file, containing the absolute
address given by <var>expression</var>. You may use this option as many
times as necessary to define multiple symbols in the command line. A
limited form of arithmetic is supported for the <var>expression</var> in this
context: you may give a hexadecimal constant or the name of an existing
symbol, or use <code>+</code> and <code>-</code> to add or subtract hexadecimal
constants or symbols. If you need more elaborate expressions, consider
using the linker command language from a script (see <a href="Assignments.html#Assignments">Assignment: Symbol Definitions</a>). <em>Note:</em> there should be no white
space between <var>symbol</var>, the equals sign ("<=>"), and
<var>expression</var>.
<br><dt><code>--demangle[=</code><var>style</var><code>]</code>
<dd><dt><code>--no-demangle</code>
<dd>These options control whether to demangle symbol names in error messages
and other output. When the linker is told to demangle, it tries to
present symbol names in a readable fashion: it strips leading
underscores if they are used by the object file format, and converts C++
mangled symbol names into user readable names. Different compilers have
different mangling styles. The optional demangling style argument can be used
to choose an appropriate demangling style for your compiler. The linker will
demangle by default unless the environment variable <code>COLLECT_NO_DEMANGLE</code>
is set. These options may be used to override the default.
<br><dt><code>--dynamic-linker </code><var>file</var><code></code>
<dd>Set the name of the dynamic linker. This is only meaningful when
generating dynamically linked ELF executables. The default dynamic
linker is normally correct; don't use this unless you know what you are
doing.
<br><dt><code>--embedded-relocs</code>
<dd>This option is only meaningful when linking MIPS embedded PIC code,
generated by the -membedded-pic option to the <small>GNU</small> compiler and
assembler. It causes the linker to create a table which may be used at
runtime to relocate any data which was statically initialized to pointer
values. See the code in testsuite/ld-empic for details.
<br><dt><code>--fatal-warnings</code>
<dd>Treat all warnings as errors.
<br><dt><code>--force-exe-suffix</code>
<dd>Make sure that an output file has a .exe suffix.
<p>If a successfully built fully linked output file does not have a
<code>.exe</code> or <code>.dll</code> suffix, this option forces the linker to copy
the output file to one of the same name with a <code>.exe</code> suffix. This
option is useful when using unmodified Unix makefiles on a Microsoft
Windows host, since some versions of Windows won't run an image unless
it ends in a <code>.exe</code> suffix.
<br><dt><code>--no-gc-sections</code>
<dd><dt><code>--gc-sections</code>
<dd>Enable garbage collection of unused input sections. It is ignored on
targets that do not support this option. This option is not compatible
with <code>-r</code>, nor should it be used with dynamic linking. The default
behaviour (of not performing this garbage collection) can be restored by
specifying <code>--no-gc-sections</code> on the command line.
<br><dt><code>--help</code>
<dd>Print a summary of the command-line options on the standard output and exit.
<br><dt><code>--target-help</code>
<dd>Print a summary of all target specific options on the standard output and exit.
<br><dt><code>-Map </code><var>mapfile</var><code></code>
<dd>Print a link map to the file <var>mapfile</var>. See the description of the
<code>-M</code> option, above.
<br><dt><code>--no-keep-memory</code>
<dd><code>ld</code> normally optimizes for speed over memory usage by caching the
symbol tables of input files in memory. This option tells <code>ld</code> to
instead optimize for memory usage, by rereading the symbol tables as
necessary. This may be required if <code>ld</code> runs out of memory space
while linking a large executable.
<br><dt><code>--no-undefined</code>
<dd><dt><code>-z defs</code>
<dd>Normally when creating a non-symbolic shared library, undefined symbols
are allowed and left to be resolved by the runtime loader. These options
disallows such undefined symbols.
<br><dt><code>--allow-multiple-definition</code>
<dd><dt><code>-z muldefs</code>
<dd>Normally when a symbol is defined multiple times, the linker will
report a fatal error. These options allow multiple definitions and the
first definition will be used.
<br><dt><code>--allow-shlib-undefined</code>
<dd>Allow undefined symbols in shared objects even when -no-undefined is
set. The net result will be that undefined symbols in regular objects
will still trigger an error, but undefined symbols in shared objects
will be ignored. The implementation of no_undefined makes the
assumption that the runtime linker will choke on undefined symbols.
However there is at least one system (BeOS) where undefined symbols in
shared libraries is normal since the kernel patches them at load time to
select which function is most appropriate for the current architecture.
I.E. dynamically select an appropriate memset function. Apparently it
is also normal for HPPA shared libraries to have undefined symbols.
<br><dt><code>--no-undefined-version</code>
<dd>Normally when a symbol has an undefined version, the linker will ignore
it. This option disallows symbols with undefined version and a fatal error
will be issued instead.
<br><dt><code>--no-warn-mismatch</code>
<dd>Normally <code>ld</code> will give an error if you try to link together input
files that are mismatched for some reason, perhaps because they have
been compiled for different processors or for different endiannesses.
This option tells <code>ld</code> that it should silently permit such possible
errors. This option should only be used with care, in cases when you
have taken some special action that ensures that the linker errors are
inappropriate.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -