📄 modifying-the-memory-layout.html
字号:
<!-- Copyright (C) 2003 Red Hat, Inc. --><!-- This material may be distributed only subject to the terms --><!-- and conditions set forth in the Open Publication License, v1.0 --><!-- or later (the latest version is presently available at --><!-- http://www.opencontent.org/openpub/). --><!-- Distribution of the work or derivative of the work in any --><!-- standard (paper) book form is prohibited unless prior --><!-- permission is obtained from the copyright holder. --><HTML><HEAD><TITLE>Modifying the Memory Layout</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos User Guide"HREF="ecos-user-guide.html"><LINKREL="UP"TITLE="Manual Configuration"HREF="manual-configuration.html"><LINKREL="PREVIOUS"TITLE="Editing the Sources"HREF="editing-the-sources.html"><LINKREL="NEXT"TITLE="Managing the Package Repository"HREF="managing-package-repository.html"></HEAD><BODYCLASS="SECT1"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">eCos User Guide</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="editing-the-sources.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 28. Manual Configuration</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="managing-package-repository.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="MODIFYING-THE-MEMORY-LAYOUT">Modifying the Memory Layout</H1><P>Each <SPANCLASS="PRODUCTNAME">eCos</SPAN> platform package is supplied with linker scriptfragments which describe the location of memory regions on the evaluationboard and the location of memory sections within these regions.The correct linker script fragment is selected and included in the<SPANCLASS="PRODUCTNAME">eCos</SPAN> linker script <TTCLASS="FILENAME">target.ld</TT> when<SPANCLASS="PRODUCTNAME">eCos</SPAN> is built.</P><P>It is not necessary to modify the default memorylayouts in order to start development with <SPANCLASS="PRODUCTNAME">eCos</SPAN>. However, it willbe necessary to edit a linker script fragment when the memory mapof the evaluation board is changed. For example, if additional memoryis added, the linker must be notified that the new memory is availablefor use. As a minimum, this would involve modifying the length ofthe corresponding memory region. Where the available memory is non-contiguous,it may be necessary to declare a new memory region and reassigncertain linker output sections to the new region.</P><P>Linker script fragments and memory layout header files shouldbe edited within the <SPANCLASS="PRODUCTNAME">eCos</SPAN> install tree. They arelocated at <TTCLASS="FILENAME">include/pkgconf/mlt_*.*</TT>.Where multiple start-up types are in use, it will be necessary toedit multiple linker script fragments and header files. The informationprovided in the header file and the corresponding linker scriptfragment must always match. A typical linker script fragment isshown below:</P><DIVCLASS="EXAMPLE"><ANAME="AEN2992"><P><B>Example 28-1. <SPANCLASS="PRODUCTNAME">eCos</SPAN> linker script fragment</B></P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">MEMORY{ rom : ORIGIN = 0x40000000, LENGTH = 0x80000 ram : ORIGIN = 0x48000000, LENGTH = 0x200000}SECTIONS{ SECTIONS_BEGIN SECTION_rom_vectors (rom, 0x40000000, LMA_EQ_VMA) SECTION_text (rom, ALIGN (0x1), LMA_EQ_VMA) SECTION_fini (rom, ALIGN (0x1), LMA_EQ_VMA) SECTION_rodata (rom, ALIGN (0x1), LMA_EQ_VMA) SECTION_rodata1 (rom, ALIGN (0x1), LMA_EQ_VMA) SECTION_fixup (rom, ALIGN (0x1), LMA_EQ_VMA) SECTION_gcc_except_table (rom, ALIGN (0x1), LMA_EQ_VMA) SECTION_data (ram, 0x48000000, FOLLOWING (.gcc_except_table)) SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA) SECTIONS_END}</PRE></TD></TR></TABLE></DIV><P>The file consists of two blocks, the <TTCLASS="LITERAL">MEMORY</TT> blockcontains lines describing the address (<TTCLASS="LITERAL">ORIGIN</TT>)and the size (<TTCLASS="LITERAL">LENGTH</TT>) of each memoryregion. The <TTCLASS="LITERAL">MEMORY</TT> block is followedby the <TTCLASS="LITERAL">SECTIONS</TT> block which containslines describing each of the linker output sections. Each sectionis represented by a macro call. The arguments of these macros areordered as follows: </P><P></P><OLTYPE="1"><LI><P>The memory region in which the section will finally reside.</P></LI><LI><P>The final address (<TTCLASS="LITERAL">VMA</TT>) of the section. This is expressed using one of the following forms:</P><P></P><DIVCLASS="VARIABLELIST"><DL><DT><SPANCLASS="emphasis"><ICLASS="EMPHASIS">n</I></SPAN></DT><DD><P>at the absolute address specified by the unsigned integer <SPANCLASS="emphasis"><ICLASS="EMPHASIS">n</I></SPAN></P></DD><DT>ALIGN (<SPANCLASS="emphasis"><ICLASS="EMPHASIS">n</I></SPAN>)</DT><DD><P>following the final location of the previous section with alignment to the next <SPANCLASS="emphasis"><ICLASS="EMPHASIS">n</I></SPAN>-byte boundary</P></DD></DL></DIV></LI><LI><P>The initial address (<TTCLASS="LITERAL">LMA</TT>) of the section. This is expressed using one of the following forms:</P><P></P><DIVCLASS="VARIABLELIST"><DL><DT>LMA_EQ_VMA</DT><DD><P>the <TTCLASS="LITERAL">LMA</TT> equals the <TTCLASS="LITERAL">VMA</TT> (no relocation)</P></DD><DT>AT (<SPANCLASS="emphasis"><ICLASS="EMPHASIS">n</I></SPAN>)</DT><DD><P>at the absolute address specified by the unsigned integer <SPANCLASS="emphasis"><ICLASS="EMPHASIS">n</I></SPAN></P></DD><DT>FOLLOWING (.<SPANCLASS="emphasis"><ICLASS="EMPHASIS">name</I></SPAN>)</DT><DD><P>following the initial location of section <SPANCLASS="emphasis"><ICLASS="EMPHASIS">name</I></SPAN></P></DD></DL></DIV></LI></OL><P>In order to maintain compatibility with linker script fragments and header files exported by the <SPANCLASS="PRODUCTNAME">eCos</SPAN> <SPANCLASS="APPLICATION">Configuration Tool</SPAN>, the use of other expressions within these files is not recommended.</P><P>Note that the names of the linker output sections will varybetween target architectures. A description of these sections canbe found in the specific <SPANCLASS="PRODUCTNAME">GCC</SPAN> documentation foryour architecture.</P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="editing-the-sources.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-user-guide.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="managing-package-repository.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Editing the Sources</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="manual-configuration.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Managing the Package Repository</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -