ld
时间:2006-08-13 来源:anima
ld
ld [options] objfiles
Combine several objfiles, in the specified order, into a single executable object module (a.out by default). ld is the link editor and is often invoked automatically by compiler commands. ld accepts many options, the most common of which are listed here.
Options
-b format, --format=formatIf ld is configured to accept more than one kind of object file, this option can be used to specify the input format. format should be a GNU Binary File Descriptor (BFD), as described in the BFD library. Use objdump -i to list available formats.
-call_sharedLink with dynamic libraries.
-d, -dc, -dpForce the assignment of space to common symbols.
-defsym symbol=expressionCreate the global symbol with the value expression.
-demangle[=style]Force demangling of symbol names. Optionally set the demangling style. Turn off demangling with -nodemangle.
-e symbolSet symbol as the address of the output file's entry point.
-f nameSet the DT_AUXILIARY field of ELF shared object to name.
-fini nameSet the DT_FINI field of ELF shared object to the address of function name. The default function is _fini.
-h nameSet the DT_SONAME field of ELF shared object to name.
--helpPrint help message, then exit.
-iProduce a linkable output file; attempt to set its magic number to OMAGIC.
-init nameSet the DT_INIT field of ELF shared object to the address of function name. The default function is _init.
-larch, --library=archiveInclude the archive file arch in the list of files to link.
-m linkerEmulate linker. List supported emulations with the -V option.
-nMake text read-only; attempt to set NMAGIC.
-o outputPlace output in output, instead of in a.out.
-oformat formatSpecify output format.
-qRetain relocation sections and contents in linked executables.
-rProduce a linkable output file; attempt to set its magic number to OMAGIC.
-rpath dirAdd directory dir to the runtime library search path. Ignore additional paths normally read from the LD_RUN_PATH environment variable.
-rpath-link dirsSpecify path to search for shared libraries required by another shared library. The dirs argument can be a single directory, or multiple directories separated by colons. This overrides search paths specified in shared libraries themselves.
-sDo not include any symbol information in output.
-sharedCreate a shared library.
-staticDo not link with shared libraries.
-sort-commonDo not sort global common symbols by size.
-tPrint each input file's name as it is processed.
--target-helpPrint target-specific options, then exit.
-u symbolForce symbol to be undefined.
-v, --versionShow version number.
--verbosePrint information about ld; print the names of input files while attempting to open them.
-warn-commonWarn when encountering common symbols combined with other constructs.
-warn-onceProvide only one warning per undefined symbol.
-xWith -s or -S, delete all local symbols. These generally begin with L.
-z keywordMark the object for special behavior specified by keyword. ld recognizes the following keywords:
combrelocObject combines and sorts multiple relocation sections for dynamic symbol lookup caching.
defsDisallow undefined symbols.
initfirstInitialize object first at runtime.
interposeInterpose object's symbol table before all but the primary executable's symbol table.
loadfltrProcess object's filter immediately at runtime.
multidefsAllow multiple definitions of a single symbol. Use the first definition.
nocombrelocDisable combining multiple relocation sections.
nocopyrelocDisable copy relocation.
nodefaultlibIgnore default library search path when seeking dependencies for object.
nodeleteDo not unload object at runtime.
nodlopenObject is not available to dlopen.
nodumpObject cannot be dumped by dldump.
nowNon-lazy runtime binding.
originObject may contain $ORIGIN.
-E, --export-dynamicAdd all symbols to dynamic symbol table, not just those referenced by linked objects.
-EBLink big-endian objects.
-ELLink little-endian objects.
-F nameSet DT_FILTER field of ELF shared object to name.
-Ldir, --library-path=dirSearch directory dir before standard search directories (this option must precede the -l option that searches that directory).
-MDisplay a link map on standard output.
-Map filePrint a link map to file.
-NAllow reading of and writing to both data and text. Mark ouput if it supports Unix magic numbers. Do not page-align data.
-O levelOptimize. level should be 1, 2, 3, or 0. The default is 1. 0 turns off optimization; 3 optimizes the most.
-R fileObtain symbol names and addresses from file, but suppress relocation of file and its inclusion in output.
-SDo not include debugger symbol information in output.
-T fileExecute script file instead of the default linker script.
-Tbss addressBegin bss segment of output at address.
-Tdata addressBegin data segment of output at address.
-Ttext addressBegin text segment of output at address.
-UrSynonymous with -r except when linking C++ programs, where it resolves constructor references.
-XWith -s or -S, delete local symbols beginning with L.
-VShow version number and emulation linkers for -m option.