ld.texinfo

来自「基于4个mips核的noc设计」· TEXINFO 代码 · 共 1,654 行 · 第 1/5 页

TEXINFO
1,654
字号
\input texinfo@setfilename ld.info@c Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,@c 2001 Free Software Foundation, Inc.@syncodeindex ky cp@include configdoc.texi@c (configdoc.texi is generated by the Makefile)@include ldver.texi@c @smallbook@ifinfo@formatSTART-INFO-DIR-ENTRY* Ld: (ld).                       The GNU linker.END-INFO-DIR-ENTRY@end format@end ifinfo@ifinfoThis file documents the @sc{gnu} linker LD version @value{VERSION}.Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.@ignorePermission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.1or any later version published by the Free Software Foundation;with no Invariant Sections, with no Front-Cover Texts, and with noBack-Cover Texts.  A copy of the license is included in thesection entitled "GNU Free Documentation License".Permission is granted to process this file through Tex and print theresults, provided the printed document carries copying permissionnotice identical to this one except for the removal of this paragraph(this paragraph not being relevant to the printed manual).@end ignore@end ifinfo@iftex@finalout@setchapternewpage odd@settitle Using LD, the GNU linker@titlepage@title Using ld@subtitle The GNU linker@sp 1@subtitle @code{ld} version 2@subtitle Version @value{VERSION}@author Steve Chamberlain@author Ian Lance Taylor@page@tex{\parskip=0pt\hfill Red Hat Inc\par\hfill nickc\@credhat.com, doc\@redhat.com\par\hfill {\it Using LD, the GNU linker}\par\hfill Edited by Jeffrey Osier (jeffrey\@cygnus.com)\par}\global\parindent=0pt % Steve likes it this way.@end tex@vskip 0pt plus 1filllCopyright @copyright{} 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.      Permission is granted to copy, distribute and/or modify this document      under the terms of the GNU Free Documentation License, Version 1.1      or any later version published by the Free Software Foundation;      with no Invariant Sections, with no Front-Cover Texts, and with no      Back-Cover Texts.  A copy of the license is included in the      section entitled "GNU Free Documentation License".@end titlepage@end iftex@c FIXME: Talk about importance of *order* of args, cmds to linker!@ifinfo@node Top@top Using ldThis file documents the @sc{gnu} linker ld version @value{VERSION}.This document is distributed under the terms of the GNU FreeDocumentation License.  A copy of the license is included in thesection entitled "GNU Free Documentation License".@menu* Overview::                    Overview* Invocation::                  Invocation* Scripts::                     Linker Scripts@ifset GENERIC* Machine Dependent::           Machine Dependent Features@end ifset@ifclear GENERIC@ifset H8300* H8/300::                      ld and the H8/300@end ifset@ifset Hitachi* Hitachi::                     ld and other Hitachi micros@end ifset@ifset I960* i960::                        ld and the Intel 960 family@end ifset@ifset TICOFF* TI COFF::                     ld and the TI COFF@end ifset@end ifclear@ifclear SingleFormat* BFD::                         BFD@end ifclear@c Following blank line required for remaining bug in makeinfo conds/menus* Reporting Bugs::              Reporting Bugs* MRI::                         MRI Compatible Script Files* GNU Free Documentation License::  GNU Free Documentation License* Index::                       Index@end menu@end ifinfo@node Overview@chapter Overview@cindex @sc{gnu} linker@cindex what is this?@code{ld} 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 @code{ld}.@code{ld} accepts Linker Command Language files written ina superset of AT&T's Link Editor Command Language syntax,to provide explicit and total control over the linking process.@ifclear SingleFormatThis version of @code{ld} uses the general purpose BFD librariesto operate on object files. This allows @code{ld} to read, combine, andwrite object files in many different formats---for example, COFF or@code{a.out}.  Different formats may be linked together to produce anyavailable kind of object file.  @xref{BFD}, for more information.@end ifclearAside from its flexibility, the @sc{gnu} linker is more helpful than otherlinkers in providing diagnostic information.  Many linkers abandonexecution immediately upon encountering an error; whenever possible,@code{ld} continues executing, allowing you to identify other errors(or, in some cases, to get an output file in spite of the error).@node Invocation@chapter InvocationThe @sc{gnu} linker @code{ld} 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.@ifset UsesEnvVars@menu* Options::                     Command Line Options* Environment::                 Environment Variables@end menu@node Options@section Command Line Options@end ifset@cindex command line@cindex optionsThe linker supports a plethora of command-line options, but in actualpractice few of them are used in any particular context.@cindex standard Unix systemFor instance, a frequent use of @code{ld} is to link standard Unixobject files on a standard, supported Unix system.  On such a system, tolink a file @code{hello.o}:@smallexampleld -o @var{output} /lib/crt0.o hello.o -lc@end smallexampleThis tells @code{ld} to produce a file called @var{output} as theresult of linking the file @code{/lib/crt0.o} with @code{hello.o} andthe library @code{libc.a}, which will come from the standard searchdirectories.  (See the discussion of the @samp{-l} option below.)Some of the command-line options to @code{ld} may be specified at anypoint in the command line.  However, options which refer to files, suchas @samp{-l} or @samp{-T}, 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.@cindex object filesNon-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.Usually the linker is invoked with at least one object file, but you canspecify other forms of binary input files using @samp{-l}, @samp{-R},and the script command language.  If @emph{no} binary input files at allare specified, the linker does not produce any output, and issues themessage @samp{No input files}.If the linker can not 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 @samp{-T}).  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@code{INPUT} or @code{GROUP} to load other objects.  Note thatspecifying a script in this way should only be used to augment the mainlinker script; if you want to use some command that logically can onlyappear once, such as the @code{SECTIONS} or @code{MEMORY} command, youmust replace the default linker script using the @samp{-T} option.@xref{Scripts}.For 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.For options whose names are multiple letters, either one dash or two canprecede the option name; for example, @samp{-trace-symbol} and@samp{--trace-symbol} are equivalent.  Note - there is one exception tothis rule.  Multiple letter options that start with a lower case 'o' canonly be preceeded by two dashes.  This is to reduce confusion with the@samp{-o} option.  So for example @samp{-omagic} sets the output filename to @samp{magic} whereas @samp{--omagic} sets the NMAGIC flag on theoutput.Arguments 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,@samp{--trace-symbol foo} and @samp{--trace-symbol=foo} are equivalent.Unique abbreviations of the names of multiple-letter options areaccepted.Note - if the linker is being invoked indirectly, via a compiler driver(eg @samp{gcc}) then all the linker command line options should beprefixed by @samp{-Wl,} (or whatever is appropriate for the particularcompiler driver) like this:@smallexample  gcc -Wl,--startgroup foo.o bar.o -Wl,--endgroup@end smallexampleThis is important, because otherwise the compiler driver program maysilently drop the linker options, resulting in a bad link.Here is a table of the generic command line switches accepted by the GNUlinker:@table @code@kindex -a@var{keyword}@item -a@var{keyword}This option is supported for HP/UX compatibility.  The @var{keyword}argument must be one of the strings @samp{archive}, @samp{shared}, or@samp{default}.  @samp{-aarchive} is functionally equivalent to@samp{-Bstatic}, and the other two keywords are functionally equivalentto @samp{-Bdynamic}.  This option may be used any number of times.@ifset I960@cindex architectures@kindex -A@var{arch}@item -A@var{architecture}@kindex --architecture=@var{arch}@itemx --architecture=@var{architecture}In the current release of @code{ld}, this option is useful only for theIntel 960 family of architectures.  In that @code{ld} configuration, the@var{architecture} argument identifies the particular architecture inthe 960 family, enabling some safeguards and modifying thearchive-library search path.  @xref{i960,,@code{ld} and the Intel 960family}, for details.Future releases of @code{ld} may support similar functionality forother architecture families.@end ifset@ifclear SingleFormat@cindex binary input format@kindex -b @var{format}@kindex --format=@var{format}@cindex input format@cindex input format@item -b @var{input-format}@itemx --format=@var{input-format}@code{ld} may be configured to support more than one kind of objectfile.  If your @code{ld} is configured this way, you can use the@samp{-b} option to specify the binary format for input object filesthat follow this option on the command line.  Even when @code{ld} isconfigured to support alternative object formats, you don't usually needto specify this, as @code{ld} should be configured to expect as adefault input format the most usual format on each machine.@var{input-format} is a text string, the name of a particular formatsupported by the BFD libraries.  (You can list the available binaryformats with @samp{objdump -i}.)@xref{BFD}.You may want to use this option if you are linking files with an unusualbinary format.  You can also use @samp{-b} to switch formats explicitly (whenlinking object files of different formats), by including@samp{-b @var{input-format}} before each group of object files in aparticular format.The default format is taken from the environment variable@code{GNUTARGET}.@ifset UsesEnvVars@xref{Environment}.@end ifsetYou can also define the input format from a script, using the command@code{TARGET}; see @ref{Format Commands}.@end ifclear@kindex -c @var{MRI-cmdfile}@kindex --mri-script=@var{MRI-cmdfile}@cindex compatibility, MRI@item -c @var{MRI-commandfile}@itemx --mri-script=@var{MRI-commandfile}For compatibility with linkers produced by MRI, @code{ld} accepts scriptfiles written in an alternate, restricted command language, described in@ref{MRI,,MRI Compatible Script Files}.  Introduce MRI script files withthe option @samp{-c}; use the @samp{-T} option to run linkerscripts written in the general-purpose @code{ld} scripting language.If @var{MRI-cmdfile} does not exist, @code{ld} looks for it in the directoriesspecified by any @samp{-L} options.@cindex common allocation@kindex -d@kindex -dc@kindex -dp

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?