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

📄 ld.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 5 页
字号:
Return 1 if <VAR>symbol</VAR> is in the linker global symbol table and isdefined, otherwise return 0.  You can use this function to provide defaultvalues for symbols.  For example, the following command-file fragment shows howto set a global symbol <CODE>begin</CODE> to the first location in the<CODE>.text</CODE> section--but if a symbol called <CODE>begin</CODE> alreadyexisted, its value is preserved:<PRE>SECTIONS{ ...  .text : {    begin = DEFINED(begin) ? begin : . ;    ...  }... }</PRE><A NAME="IDX185"></A><A NAME="IDX186"></A><DT><CODE>NEXT(<VAR>exp</VAR>)</CODE><DD>Return the next unallocated address that is a multiple of <VAR>exp</VAR>.This function is closely related to <CODE>ALIGN(<VAR>exp</VAR>)</CODE>; unless youuse the <CODE>MEMORY</CODE> command to define discontinuous memory for theoutput file, the two functions are equivalent.<A NAME="IDX187"></A><A NAME="IDX188"></A><DT><CODE>SIZEOF(<VAR>section</VAR>)</CODE><DD>Return the size in bytes of the named <VAR>section</VAR>, if that section hasbeen allocated.  In the following example, <CODE>symbol_1</CODE> and<CODE>symbol_2</CODE> are assigned identical values:<PRE>SECTIONS{ ...  .output {    .start = . ;    ...    .end = . ;    }  symbol_1 = .end - .start ;  symbol_2 = SIZEOF(.output);... }</PRE><A NAME="IDX189"></A><A NAME="IDX190"></A><A NAME="IDX191"></A><DT><CODE>SIZEOF_HEADERS</CODE><DD><DT><CODE>sizeof_headers</CODE><DD>Return the size in bytes of the output file's headers.  You can use this numberas the start address of the first section, if you choose, to facilitatepaging. </DL><H2><A NAME="SEC15" HREF="ld_toc.html#TOC15">Memory Layout</A></H2><P><A NAME="IDX192"></A><A NAME="IDX193"></A><A NAME="IDX194"></A><A NAME="IDX195"></A>The linker's default configuration permits allocation of all available memory.You can override this configuration by using the <CODE>MEMORY</CODE> command.  The<CODE>MEMORY</CODE> command describes the location and size of blocks ofmemory in the target.  By using it carefully, you can describe whichmemory regions may be used by the linker, and which memory regions itmust avoid.  The linker does not shuffle sections to fit into theavailable regions, but does move the requested sections into the correctregions and issue errors when the regions become too full.  </P><P>A command file may contain at most one use of the <CODE>MEMORY</CODE>command; however, you can define as many blocks of memory within it asyou wish.  The syntax is:        <PRE>MEMORY   {    <VAR>name</VAR> (<VAR>attr</VAR>) : ORIGIN = <VAR>origin</VAR>, LENGTH = <VAR>len</VAR>    ...  }</PRE><DL COMPACT><DT><CODE><VAR>name</VAR></CODE><DD><A NAME="IDX196"></A> is a name used internally by the linker to refer to the region. Anysymbol name may be used.  The region names are stored in a separatename space, and will not conflict with symbols, file names or sectionnames.  Use distinct names to specify multiple regions.<A NAME="IDX197"></A><DT><CODE>(<VAR>attr</VAR>)</CODE><DD>is an optional list of attributes, permitted for compatibility with theAT&#38;T linker but not used by <CODE>ld</CODE> beyond checking that theattribute list is valid.  Valid attribute lists must be made up of thecharacters "<CODE>LIRWX</CODE>".  If you omit the attribute list, you mayomit the parentheses around it as well.<A NAME="IDX198"></A><A NAME="IDX199"></A><A NAME="IDX200"></A><DT><CODE><VAR>origin</VAR></CODE><DD>is the start address of the region in physical memory.  It isan expression that must evaluate to a constant beforememory allocation is performed. The keyword <CODE>ORIGIN</CODE> may beabbreviated to <CODE>org</CODE> or <CODE>o</CODE> (but not, for example, <SAMP>`ORG'</SAMP>).<A NAME="IDX201"></A><A NAME="IDX202"></A><A NAME="IDX203"></A><DT><CODE><VAR>len</VAR></CODE><DD>is the size in bytes of the region (an expression).The keyword <CODE>LENGTH</CODE> may be abbreviated to <CODE>len</CODE> or <CODE>l</CODE>.</DL><P>For example, to specify that memory has two regions available forallocation--one starting at 0 for 256 kilobytes, and the otherstarting at <CODE>0x40000000</CODE> for four megabytes:</P><PRE>MEMORY   {  rom : ORIGIN = 0, LENGTH = 256K  ram : org = 0x40000000, l = 4M  }</PRE><P>Once you have defined a region of memory named <VAR>mem</VAR>, you can directspecific output sections there by using a command ending in<SAMP>`&#62;<VAR>mem</VAR>'</SAMP> within the <CODE>SECTIONS</CODE> command (see section <A HREF="ld.html#SEC20">Optional Section Attributes</A>).  If the combined output sections directed to a region are toobig for the region, the linker will issue an error message.</P><H2><A NAME="SEC16" HREF="ld_toc.html#TOC16">Specifying Output Sections</A></H2><P><A NAME="IDX204"></A>The <CODE>SECTIONS</CODE> command controls exactly where input sections areplaced into output sections, their order in the output file, and towhich output sections they are allocated.</P><P>You may use at most one <CODE>SECTIONS</CODE> command in a script file,but you can have as many statements within it as you wish.  Statementswithin the <CODE>SECTIONS</CODE> command can do one of three things:</P><UL><LI>define the entry point;<LI>assign a value to a symbol;<LI>describe the placement of a named output section, and which inputsections go into it.</UL><P>You can also use the first two operations--defining the entry point anddefining symbols--outside the <CODE>SECTIONS</CODE> command: see section <A HREF="ld.html#SEC22">The Entry Point</A>, and see section <A HREF="ld.html#SEC13">Assignment: Defining Symbols</A>.  They are permitted here as well foryour convenience in reading the script, so that symbols and the entrypoint can be defined at meaningful points in your output-file layout.</P><P>If you do not use a <CODE>SECTIONS</CODE> command, the linker places each inputsection into an identically named output section in the order that thesections are first encountered in the input files.  If all input sectionsare present in the first file, for example, the order of sections in theoutput file will match the order in the first input file.</P><H3><A NAME="SEC17" HREF="ld_toc.html#TOC17">Section Definitions</A></H3><P><A NAME="IDX205"></A>The most frequently used statement in the <CODE>SECTIONS</CODE> command isthe <EM>section definition</EM>, which specifies theproperties of an output section: its location, alignment, contents,fill pattern, and target memory region.  Most ofthese specifications are optional; the simplest form of a sectiondefinition is<PRE>SECTIONS { ...  <VAR>secname</VAR> : {    <VAR>contents</VAR>  }... }</PRE><P><A NAME="IDX206"></A><VAR>secname</VAR> is the name of the output section, and <VAR>contents</VAR> aspecification of what goes there--for example, a list of input files orsections of input files (see section <A HREF="ld.html#SEC18">Section Placement</A>).  As you mightassume, the whitespace shown is optional.  You do need the colon<SAMP>`:'</SAMP> and the braces <SAMP>`{}'</SAMP>, however.</P><P><VAR>secname</VAR> must meet the constraints of your output format.  Informats which only support a limited number of sections, such as<CODE>a.out</CODE>, the name must be one of the names supported by the format(<CODE>a.out</CODE>, for example, allows only <CODE>.text</CODE>, <CODE>.data</CODE> or<CODE>.bss</CODE>). If the output format supports any number of sections, butwith numbers and not names (as is the case for Oasys), the name should besupplied as a quoted numeric string.  A section name may consist of anysequence of characters, but any name which does not conform to the standard<CODE>ld</CODE> symbol name syntax must be quoted.See section <A HREF="ld.html#SEC9">Symbol Names</A>.</P><P>The linker will not create output sections which do not have anycontents.  This is for convenience when referring to input sections thatmay or may not exist.  For example,<PRE>.foo { *(.foo) }</PRE><P>will only create a <SAMP>`.foo'</SAMP> section in the output file if there is a<SAMP>`.foo'</SAMP> section in at least one input file.</P><H3><A NAME="SEC18" HREF="ld_toc.html#TOC18">Section Placement</A></H3><P><A NAME="IDX207"></A>In a section definition, you can specify the contents of an outputsection by listing particular input files, by listing particularinput-file sections, or by a combination of the two.  You can also placearbitrary data in the section, and define symbols relative to thebeginning of the section.</P><P>The <VAR>contents</VAR> of a section definition may include any of thefollowing kinds of statement.  You can include as many of these as youlike in a single section definition, separated from one another bywhitespace. </P><DL COMPACT><DT><CODE><VAR>filename</VAR></CODE><DD><A NAME="IDX208"></A> <A NAME="IDX209"></A> <A NAME="IDX210"></A> You may simply name a particular input file to be placed in the currentoutput section; <EM>all</EM> sections from that file are placed in thecurrent section definition.  If the file name has already been mentionedin another section definition, with an explicit section name list, thenonly those sections which have not yet been allocated are used.To specify a list of particular files by name:<PRE>.data : { afile.o bfile.o cfile.o }</PRE>The example also illustrates that multiple statements can be included inthe contents of a section definition, since each file name is a separatestatement. <A NAME="IDX211"></A><A NAME="IDX212"></A><DT><CODE><VAR>filename</VAR>( <VAR>section</VAR> )</CODE><DD><DT><CODE><VAR>filename</VAR>( <VAR>section</VAR>, <VAR>section</VAR>, ... )</CODE><DD><DT><CODE><VAR>filename</VAR>( <VAR>section</VAR> <VAR>section</VAR> ... )</CODE><DD>You can name one or more sections from your input files, forinsertion in the current output section.  If you wish to specify a listof input-file sections inside the parentheses, you may separate thesection names by either commas or whitespace.<A NAME="IDX213"></A><A NAME="IDX214"></A><DT><CODE>* (<VAR>section</VAR>)</CODE><DD><DT><CODE>* (<VAR>section</VAR>, <VAR>section</VAR>, ...)</CODE><DD><DT><CODE>* (<VAR>section</VAR> <VAR>section</VAR> ...)</CODE><DD>Instead of explicitly naming particular input files in a link controlscript, you can refer to <EM>all</EM> files from the <CODE>ld</CODE> commandline: use <SAMP>`*'</SAMP> instead of a particular file name before theparenthesized input-file section list.  If you have already explicitly included some files by name, <SAMP>`*'</SAMP>refers to all <EM>remaining</EM> files--those whose places in the outputfile have not yet been defined.For example, to copy sections <CODE>1</CODE> through <CODE>4</CODE> from an Oasys fileinto the <CODE>.text</CODE> section of an <CODE>a.out</CODE> file, and sections <CODE>13</CODE>and <CODE>14</CODE> into the <CODE>.data</CODE> section:<PRE>SECTIONS {  .text :{    *("1" "2" "3" "4")  }    .data :{    *("13" "14")  }}</PRE><A NAME="IDX215"></A><SAMP>`[ <VAR>section</VAR> ... ]'</SAMP> used to be accepted as an alternate wayto specify named sections from all unallocated input files.  Becausesome operating systems (VMS) allow brackets in file names, that notationis no longer supported.<A NAME="IDX216"></A><A NAME="IDX217"></A><A NAME="IDX218"></A><DT><CODE><VAR>filename</VAR><CODE>( COMMON )</CODE></CODE><DD><DT><CODE>*( COMMON )</CODE><DD>Specify where in your output file to place uninitialized datawith this notation.  <CODE>*(COMMON)</CODE> by itself refers to alluninitialized data from all input files (so far as it is not yetallocated); <VAR>filename</VAR><CODE>(COMMON)</CODE> refers to uninitialized datafrom a particular file.  Both are special cases of the generalmechanisms for specifying where to place input-file sections:<CODE>ld</CODE> permits you to refer to uninitialized data as if itwere in an input-file section named <CODE>COMMON</CODE>, regardless of theinput file's format.</DL><P>For example, the following command script arranges the output file intothree consecutive sections, named <CODE>.text</CODE>, <CODE>.data</CODE>, and<CODE>.bss</CODE>, taking the input for each from the correspondingly namedsectio

⌨️ 快捷键说明

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