⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ld.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<A NAME="IDX100"></A><A NAME="IDX101"></A><DT><CODE>-traditional-format</CODE><DD>For some targets, the output of <CODE>ld</CODE> is different in some ways fromthe output of some existing linker.  This switch requests <CODE>ld</CODE> touse the traditional format instead.<A NAME="IDX102"></A>For example, on SunOS, <CODE>ld</CODE> combines duplicate entries in thesymbol string table.  This can reduce the size of an output file withfull debugging information by over 30 percent.  Unfortunately, the SunOS<CODE>dbx</CODE> program can not read the resulting program (<CODE>gdb</CODE> has notrouble).  The <SAMP>`-traditional-format'</SAMP> switch tells <CODE>ld</CODE> to notcombine duplicate entries.<A NAME="IDX103"></A><A NAME="IDX104"></A><DT><CODE>-u <VAR>symbol</VAR></CODE><DD>Force <VAR>symbol</VAR> to be entered in the output file as an undefined symbol.Doing this may, for example, trigger linking of additional modules fromstandard libraries.  <SAMP>`-u'</SAMP> may be repeated with different optionarguments to enter additional undefined symbols.<A NAME="IDX105"></A><A NAME="IDX106"></A><DT><CODE>-Ur</CODE><DD>For anything other than C++ programs, this option is equivalent to<SAMP>`-r'</SAMP>: it generates relocatable output--i.e., an output file that can inturn serve as input to <CODE>ld</CODE>.  When linking C++ programs, <SAMP>`-Ur'</SAMP><EM>does</EM> resolve references to constructors, unlike <SAMP>`-r'</SAMP>.It does not work to use <SAMP>`-Ur'</SAMP> on files that were themselves linkedwith <SAMP>`-Ur'</SAMP>; once the constructor table has been built, it cannotbe added to.  Use <SAMP>`-Ur'</SAMP> only for the last partial link, and<SAMP>`-r'</SAMP> for the others.<A NAME="IDX107"></A><A NAME="IDX108"></A><DT><CODE>--verbose</CODE><DD>Display the version number for <CODE>ld</CODE> and list the linker emulationssupported.  Display which input files can and cannot be opened.<A NAME="IDX109"></A><A NAME="IDX110"></A><A NAME="IDX111"></A><DT><CODE>-v</CODE><DD><DT><CODE>-V</CODE><DD>Display the version number for <CODE>ld</CODE>.  The <CODE>-V</CODE> option alsolists the supported emulations.<A NAME="IDX112"></A><DT><CODE>-version</CODE><DD>Display the version number for <CODE>ld</CODE> and exit.<A NAME="IDX113"></A><A NAME="IDX114"></A><A NAME="IDX115"></A><DT><CODE>-warn-common</CODE><DD>Warn when a common symbol is combined with another common symbol or witha symbol definition.  Unix linkers allow this somewhat sloppy practice,but linkers on some other operating systems do not.  This option allowsyou to find potential problems from combining global symbols.Unfortunately, some C libraries use this practice, so you may get somewarnings about symbols in the libraries as well as in your programs.There are three kinds of global symbols, illustrated here by C examples:<DL COMPACT><DT><SAMP>`int i = 1;'</SAMP><DD>A definition, which goes in the initialized data section of the outputfile.<DT><SAMP>`extern int i;'</SAMP><DD>An undefined reference, which does not allocate space.There must be either a definition or a common symbol for thevariable somewhere.<DT><SAMP>`int i;'</SAMP><DD>A common symbol.  If there are only (one or more) common symbols for avariable, it goes in the uninitialized data area of the output file.The linker merges multiple common symbols for the same variable into asingle symbol.  If they are of different sizes, it picks the largestsize.  The linker turns a common symbol into a declaration, if there isa definition of the same variable.</DL>The <SAMP>`-warn-common'</SAMP> option can produce five kinds of warnings.  Eachwarning consists of a pair of lines: the first describes the symbol justencountered, and the second describes the previous symbol encounteredwith the same name.  One or both of the two symbols will be a commonsymbol.<OL><LI>Turning a common symbol into a reference, because there is already adefinition for the symbol.<PRE><VAR>file</VAR>(<VAR>section</VAR>): warning: common of `<VAR>symbol</VAR>'   overridden by definition<VAR>file</VAR>(<VAR>section</VAR>): warning: defined here</PRE><LI>Turning a common symbol into a reference, because a later definition forthe symbol is encountered.  This is the same as the previous case,except that the symbols are encountered in a different order.<PRE><VAR>file</VAR>(<VAR>section</VAR>): warning: definition of `<VAR>symbol</VAR>'   overriding common<VAR>file</VAR>(<VAR>section</VAR>): warning: common is here</PRE><LI>Merging a common symbol with a previous same-sized common symbol.<PRE><VAR>file</VAR>(<VAR>section</VAR>): warning: multiple common   of `<VAR>symbol</VAR>'<VAR>file</VAR>(<VAR>section</VAR>): warning: previous common is here</PRE><LI>Merging a common symbol with a previous larger common symbol.<PRE><VAR>file</VAR>(<VAR>section</VAR>): warning: common of `<VAR>symbol</VAR>'   overridden by larger common<VAR>file</VAR>(<VAR>section</VAR>): warning: larger common is here</PRE><LI>Merging a common symbol with a previous smaller common symbol.  This isthe same as the previous case, except that the symbols areencountered in a different order.<PRE><VAR>file</VAR>(<VAR>section</VAR>): warning: common of `<VAR>symbol</VAR>'   overriding smaller common<VAR>file</VAR>(<VAR>section</VAR>): warning: smaller common is here</PRE></OL><A NAME="IDX116"></A><DT><CODE>-warn-constructors</CODE><DD>Warn if any global constructors are used.  This is only useful for a fewobject file formats.  For formats like COFF or ELF, the linker can notdetect the use of global constructors.<A NAME="IDX117"></A><A NAME="IDX118"></A><A NAME="IDX119"></A><DT><CODE>-warn-once</CODE><DD>Only warn once for each undefined symbol, rather than once per modulewhich refers to it.<A NAME="IDX120"></A><A NAME="IDX121"></A>For each archive mentioned on the command line, include every objectfile in the archive in the link, rather than searching the archive forthe required object files.  This is normally used to turn an archivefile into a shared library, forcing every object to be included in theresulting shared library.<A NAME="IDX122"></A><A NAME="IDX123"></A><A NAME="IDX124"></A><DT><CODE>-X</CODE><DD>Delete all temporary local symbols.  For most targets, this is all localsymbols whose names begin with <SAMP>`L'</SAMP>.<A NAME="IDX125"></A><A NAME="IDX126"></A><DT><CODE>-x</CODE><DD>Delete all local symbols.<A NAME="IDX127"></A><A NAME="IDX128"></A><DT><CODE>-y <VAR>symbol</VAR></CODE><DD>Print the name of each linked file in which <VAR>symbol</VAR> appears.  Thisoption may be given any number of times.  On many systems it is necessaryto prepend an underscore.This option is useful when you have an undefined symbol in your link butdon't know where the reference is coming from.<A NAME="IDX129"></A><A NAME="IDX130"></A><DT><CODE>-( <VAR>archives</VAR> -)</CODE><DD><DT><CODE>--start-group <VAR>archives</VAR> --end-group</CODE><DD>The <VAR>archives</VAR> should be a list of archive files.  They may beeither explicit file names, or <SAMP>`-l'</SAMP> options.The specified archives are searched repeatedly until no new undefinedreferences are created.  Normally, an archive is searched only once inthe order that it is specified on the command line.  If a symbol in thatarchive is needed to resolve an undefined symbol referred to by anobject in an archive that appears later on the command line, the linkerwould not be able to resolve that reference.  By grouping the archives,they all be searched repeatedly until all possible references areresolved.Using this option has a significant performance cost.  It is best to useit only when there are unavoidable circular references between two ormore archives.</DL><H2><A NAME="SEC4" HREF="ld_toc.html#TOC4">Environment Variables</A></H2><P>You can change the behavior of <CODE>ld</CODE> with the environmentvariable <CODE>GNUTARGET</CODE>.  </P><P><A NAME="IDX131"></A><A NAME="IDX132"></A><CODE>GNUTARGET</CODE> determines the input-file object format if you don'tuse <SAMP>`-b'</SAMP> (or its synonym <SAMP>`-format'</SAMP>).  Its value should be oneof the BFD names for an input format (see section <A HREF="ld.html#SEC26">BFD</A>).  If there is no<CODE>GNUTARGET</CODE> in the environment, <CODE>ld</CODE> uses the natural formatof the target. If <CODE>GNUTARGET</CODE> is set to <CODE>default</CODE> then BFD attempts to discover theinput format by examining binary input files; this method oftensucceeds, but there are potential ambiguities, since there is no methodof ensuring that the magic number used to specify object-file formats isunique.  However, the configuration procedure for BFD on each systemplaces the conventional format for that system first in the search-list,so ambiguities are resolved in favor of convention.</P><H1><A NAME="SEC5" HREF="ld_toc.html#TOC5">Command Language</A></H1><P><A NAME="IDX133"></A>The command language provides explicit control over the link process,allowing complete specification of the mapping between the linker'sinput files and its output.  It controls:<UL><LI>input files <LI>file formats<LI>output file layout<LI>addresses of sections<LI>placement of common blocks</UL><P>You may supply a command file (also known as a link script) to thelinker either explicitly through the <SAMP>`-T'</SAMP> option, or implicitly asan ordinary file. If the linker opens a file which it cannot recognizeas a supported object or archive format, it reports an error.</P><H2><A NAME="SEC6" HREF="ld_toc.html#TOC6">Linker Scripts</A></H2><P>The <CODE>ld</CODE> command language is a collection of statements; some aresimple keywords setting a particular option, some are used to select andgroup input files or name output files; and two statementtypes have a fundamental and pervasive impact on the linking process.</P><P><A NAME="IDX134"></A><A NAME="IDX135"></A><A NAME="IDX136"></A><A NAME="IDX137"></A>The most fundamental command of the <CODE>ld</CODE> command language is the<CODE>SECTIONS</CODE> command (see section <A HREF="ld.html#SEC16">Specifying Output Sections</A>).  Every meaningful commandscript must have a <CODE>SECTIONS</CODE> command: it specifies a"picture" of the output file's layout, in varying degrees of detail.No other command is required in all cases.</P><P>The <CODE>MEMORY</CODE> command complements <CODE>SECTIONS</CODE> by describing theavailable memory in the target architecture.  This command is optional;if you don't use a <CODE>MEMORY</CODE> command, <CODE>ld</CODE> assumes sufficientmemory is available in a contiguous block for all output.See section <A HREF="ld.html#SEC15">Memory Layout</A>.</P><P><A NAME="IDX138"></A>You may include comments in linker scripts just as in C: delimitedby <SAMP>`/*'</SAMP> and <SAMP>`*/'</SAMP>.  As in C, comments are syntacticallyequivalent to whitespace.</P><H2><A NAME="SEC7" HREF="ld_toc.html#TOC7">Expressions</A></H2><P><A NAME="IDX139"></A><A NAME="IDX140"></A>Many useful commands involve arithmetic expressions.  The syntax forexpressions in the command language is identical to that of Cexpressions, with the following features:<UL><LI>All expressions evaluated as integers andare of "long" or "unsigned long" type.<LI>All constants are integers.<LI>All of the C arithmetic operators are provided.<LI>You may reference, define, and create global variables.<LI>You may call special purpose built-in functions.</UL><H3><A NAME="SEC8" HREF="ld_toc.html#TOC8">Integers</A></H3><P><A NAME="IDX141"></A><A NAME="IDX142"></A>An octal integer is <SAMP>`0'</SAMP> followed by zero or more of the octaldigits (<SAMP>`01234567'</SAMP>).<PRE>_as_octal = 0157255;</PRE><P><A NAME="IDX143"></A>A decimal integer starts with a non-zero digit followed by zero ormore digits (<SAMP>`0123456789'</SAMP>).

⌨️ 快捷键说明

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