📄 ld.1
字号:
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3.\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. | will give a.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'.\" expand to `' in nroff, nothing in troff, for use with C<>..tr \(*W-|\(bv\*(Tr.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..if \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.\".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..hy 0.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "LD 1".TH LD 1 "2006-08-25" "binutils-2.17.50" "GNU Development Tools".SH "NAME"ld \- The GNU linker.SH "SYNOPSIS".IX Header "SYNOPSIS"ld [\fBoptions\fR] \fIobjfile\fR ....SH "DESCRIPTION".IX Header "DESCRIPTION"\&\fBld\fR combines a number of object and archive files, relocatestheir data and ties up symbol references. Usually the last step incompiling a program is to run \fBld\fR..PP\&\fBld\fR accepts Linker Command Language files written ina superset of \s-1AT&T\s0's Link Editor Command Language syntax,to provide explicit and total control over the linking process..PPThis man page does not describe the command language; see the\&\fBld\fR entry in \f(CW\*(C`info\*(C'\fR for full details on the commandlanguage and on other aspects of the \s-1GNU\s0 linker..PPThis version of \fBld\fR uses the general purpose \s-1BFD\s0 librariesto operate on object files. This allows \fBld\fR to read, combine, andwrite object files in many different formats\-\-\-for example, \s-1COFF\s0 or\&\f(CW\*(C`a.out\*(C'\fR. Different formats may be linked together to produce anyavailable kind of object file. .PPAside from its flexibility, the \s-1GNU\s0 linker is more helpful than otherlinkers in providing diagnostic information. Many linkers abandonexecution immediately upon encountering an error; whenever possible,\&\fBld\fR continues executing, allowing you to identify other errors(or, in some cases, to get an output file in spite of the error)..PPThe \s-1GNU\s0 linker \fBld\fR is meant to cover a broad range of situations,and to be as compatible as possible with other linkers. As a result,you have many choices to control its behavior..SH "OPTIONS".IX Header "OPTIONS"The linker supports a plethora of command-line options, but in actualpractice few of them are used in any particular context.For instance, a frequent use of \fBld\fR is to link standard Unixobject files on a standard, supported Unix system. On such a system, tolink a file \f(CW\*(C`hello.o\*(C'\fR:.PP.Vb 1\& ld -o <output> /lib/crt0.o hello.o -lc.Ve.PPThis tells \fBld\fR to produce a file called \fIoutput\fR as theresult of linking the file \f(CW\*(C`/lib/crt0.o\*(C'\fR with \f(CW\*(C`hello.o\*(C'\fR andthe library \f(CW\*(C`libc.a\*(C'\fR, which will come from the standard searchdirectories. (See the discussion of the \fB\-l\fR option below.).PPSome of the command-line options to \fBld\fR may be specified at anypoint in the command line. However, options which refer to files, suchas \fB\-l\fR or \fB\-T\fR, cause the file to be read at the point atwhich the option appears in the command line, relative to the objectfiles and other file options. Repeating non-file options with adifferent argument will either have no further effect, or override prioroccurrences (those further to the left on the command line) of thatoption. Options which may be meaningfully specified more than once arenoted in the descriptions below..PPNon-option arguments are object files or archives which are to be linkedtogether. They may follow, precede, or be mixed in with command-lineoptions, except that an object file argument may not be placed betweenan option and its argument..PPUsually the linker is invoked with at least one object file, but you canspecify other forms of binary input files using \fB\-l\fR, \fB\-R\fR,and the script command language. If \fIno\fR binary input files at allare specified, the linker does not produce any output, and issues themessage \fBNo input files\fR..PPIf the linker cannot recognize the format of an object file, it willassume that it is a linker script. A script specified in this wayaugments the main linker script used for the link (either the defaultlinker script or the one specified by using \fB\-T\fR). This featurepermits the linker to link against a file which appears to be an objector an archive, but actually merely defines some symbol values, or uses\&\f(CW\*(C`INPUT\*(C'\fR or \f(CW\*(C`GROUP\*(C'\fR to load other objects. Note thatspecifying a script in this way merely augments the main linker script;use the \fB\-T\fR option to replace the default linker script entirely..PPFor options whose names are a single letter,option arguments must either follow the option letter without interveningwhitespace, or be given as separate arguments immediately following theoption that requires them..PPFor options whose names are multiple letters, either one dash or two canprecede the option name; for example, \fB\-trace\-symbol\fR and\&\fB\-\-trace\-symbol\fR are equivalent. Note\-\-\-there is one exception tothis rule. Multiple letter options that start with a lower case 'o' canonly be preceded by two dashes. This is to reduce confusion with the\&\fB\-o\fR option. So for example \fB\-omagic\fR sets the output filename to \fBmagic\fR whereas \fB\-\-omagic\fR sets the \s-1NMAGIC\s0 flag on theoutput..PPArguments to multiple-letter options must either be separated from theoption name by an equals sign, or be given as separate argumentsimmediately following the option that requires them. For example,\&\fB\-\-trace\-symbol foo\fR and \fB\-\-trace\-symbol=foo\fR are equivalent.Unique abbreviations of the names of multiple-letter options areaccepted..PPNote\-\-\-if the linker is being invoked indirectly, via a compiler driver(e.g. \fBgcc\fR) then all the linker command line options should beprefixed by \fB\-Wl,\fR (or whatever is appropriate for the particularcompiler driver) like this:.PP.Vb 1\& gcc -Wl,--startgroup foo.o bar.o -Wl,--endgroup.Ve.PPThis is important, because otherwise the compiler driver program maysilently drop the linker options, resulting in a bad link..PPHere is a table of the generic command line switches accepted by the \s-1GNU\s0linker:.IP "\fB@\fR\fIfile\fR" 4.IX Item "@file"Read command-line options from \fIfile\fR. The options read areinserted in place of the original @\fIfile\fR option. If \fIfile\fRdoes not exist, or cannot be read, then the option will be treatedliterally, and not removed. .SpOptions in \fIfile\fR are separated by whitespace. A whitespacecharacter may be included in an option by surrounding the entireoption in either single or double quotes. Any character (including abackslash) may be included by prefixing the character to be includedwith a backslash. The \fIfile\fR may itself contain additional@\fIfile\fR options; any such options will be processed recursively..IP "\fB\-a\fR\fIkeyword\fR" 4.IX Item "-akeyword"This option is supported for \s-1HP/UX\s0 compatibility. The \fIkeyword\fRargument must be one of the strings \fBarchive\fR, \fBshared\fR, or\&\fBdefault\fR. \fB\-aarchive\fR is functionally equivalent to\&\fB\-Bstatic\fR, and the other two keywords are functionally equivalentto \fB\-Bdynamic\fR. This option may be used any number of times..IP "\fB\-A\fR\fIarchitecture\fR" 4.IX Item "-Aarchitecture".PD 0.IP "\fB\-\-architecture=\fR\fIarchitecture\fR" 4.IX Item "--architecture=architecture".PDIn the current release of \fBld\fR, this option is useful only for theIntel 960 family of architectures. In that \fBld\fR configuration, the\&\fIarchitecture\fR argument identifies the particular architecture inthe 960 family, enabling some safeguards and modifying thearchive-library search path. .SpFuture releases of \fBld\fR may support similar functionality forother architecture families..IP "\fB\-b\fR \fIinput-format\fR" 4.IX Item "-b input-format".PD 0.IP "\fB\-\-format=\fR\fIinput-format\fR" 4.IX Item "--format=input-format".PD\&\fBld\fR may be configured to support more than one kind of objectfile. If your \fBld\fR is configured this way, you can use the\&\fB\-b\fR option to specify the binary format for input object filesthat follow this option on the command line. Even when \fBld\fR isconfigured to support alternative object formats, you don't usually needto specify this, as \fBld\fR should be configured to expect as adefault input format the most usual format on each machine.\&\fIinput-format\fR is a text string, the name of a particular formatsupported by the \s-1BFD\s0 libraries. (You can list the available binaryformats with \fBobjdump \-i\fR.).SpYou may want to use this option if you are linking files with an unusualbinary format. You can also use \fB\-b\fR to switch formats explicitly (whenlinking object files of different formats), by including\&\fB\-b\fR \fIinput-format\fR before each group of object files in aparticular format..SpThe default format is taken from the environment variable
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -