📄 hal-linker-scripts.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>Linker Scripts</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos Reference Manual"HREF="ecos-ref.html"><LINKREL="UP"TITLE="HAL Interfaces"HREF="hal-interfaces.html"><LINKREL="PREVIOUS"TITLE="Cache Control"HREF="hal-cache-control.html"><LINKREL="NEXT"TITLE="Diagnostic Support"HREF="hal-diagnostic-support.html"></HEAD><BODYCLASS="SECTION"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 Reference Manual</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="hal-cache-control.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 9. HAL Interfaces</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="hal-diagnostic-support.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECTION"><H1CLASS="SECTION"><ANAME="HAL-LINKER-SCRIPTS">Linker Scripts</H1><P>When an eCos application is linked it must be done under the controlof a linker script. This script defines the memory areas, addressesand sized, into which the code and data are to be put, and allocatesthe various sections generated by the compiler to these.</P><P>The linker script actually used is in<TTCLASS="FILENAME">lib/target.ld</TT> in the install directory. This isactually manufactured out of two other files: a base linker script andan <TTCLASS="LITERAL">.ldi</TT> file that was generated by the memorylayout tool.</P><P>The base linker script is usually supplied either by the architectureHAL or the variant HAL. It consists of a set of linker scriptfragments, in the form of C preprocessor macros, that define the majoroutput sections to be generated by the link operation. The<TTCLASS="LITERAL">.ldi</TT> file, which is <TTCLASS="LITERAL">#include'ed</TT>by the base linker script, uses these macro definitions to assign theoutput sections to the required memory areas and link addresses.</P><P>The <TTCLASS="LITERAL">.ldi</TT> file is supplied by the platform HAL, andcontains knowledge of the memory layout of the target platform. Thesefiles generally conform to a standard naming convention, each filebeing of the form:</P><P><TTCLASS="FILENAME">pkgconf/mlt_<architecture>_<variant>_<platform>_<startup>.ldi</TT></P><P>where <TTCLASS="LITERAL"><architecture></TT>,<TTCLASS="LITERAL"><variant></TT> and<TTCLASS="LITERAL"><platform></TT> are the respective HAL packagenames and <TTCLASS="LITERAL"><startup></TT> is the startup type whichis usually one of <TTCLASS="LITERAL">ROM</TT>, <TTCLASS="LITERAL">RAM</TT> or<TTCLASS="LITERAL">ROMRAM</TT>.</P><P>In addition to the <TTCLASS="LITERAL">.ldi</TT> file, there is also acongruously name <TTCLASS="LITERAL">.h</TT> file. This may be used by theapplication to access information defined in the<TTCLASS="LITERAL">.ldi</TT> file. Specifically it contains the memorylayout defined there, together with any additional section namesdefined by the user. Examples of the latter are heap areas or PCI busmemory access windows.</P><P>The <TTCLASS="LITERAL">.ldi</TT> is manufactured by the <SPANCLASS="APPLICATION">MemoryLayout Tool</SPAN> (MLT). The <SPANCLASS="APPLICATION">MLT</SPAN> saves the memoryconfiguration into a file named</P><P><TTCLASS="FILENAME">include/pkgconf/mlt_<architecture>_<variant>_<platform>_<startup>.mlt</TT></P><P>in the platform HAL. This file is used by the<SPANCLASS="APPLICATION">MLT</SPAN> to manufacture both the<TTCLASS="LITERAL">.ldi</TT> and <TTCLASS="LITERAL">.h</TT> files. Users shouldbeware that direct edits the either of these files may be overwrittenif the <SPANCLASS="APPLICATION">MLT</SPAN> is run and regenerates them from the<TTCLASS="LITERAL">.mlt</TT> file.</P><P>The names of the <TTCLASS="LITERAL">.ldi</TT> and <TTCLASS="LITERAL">.h</TT>files are defined by macro definitions in<TTCLASS="FILENAME">pkgconf/system.h</TT>. These are<TTCLASS="LITERAL">CYGHWR_MEMORY_LAYOUT_LDI</TT> and<TTCLASS="LITERAL">CYGHWR_MEMORY_LAYOUT_H</TT> respectively. While therewill be little need for the application to refer to the<TTCLASS="LITERAL">.ldi</TT> file directly, it may include the<TTCLASS="LITERAL">.h</TT> file as follows:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">#include CYGHWR_MEMORY_LAYOUT_H</PRE></TD></TR></TABLE></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="hal-cache-control.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="hal-diagnostic-support.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Cache Control</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="hal-interfaces.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Diagnostic Support</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -