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

📄 provide.html

📁 gcc手册
💻 HTML
字号:
<html lang="en">

<head>

<title>Untitled</title>

<meta http-equiv="Content-Type" content="text/html">

<meta name="description" content="Untitled">

<meta name="generator" content="makeinfo 4.3">

<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">

</head>

<body>

<div class="node">

<p>

Node:<a name="PROVIDE">PROVIDE</a>,

Previous:<a rel="previous" accesskey="p" href="Simple-Assignments.html#Simple%20Assignments">Simple Assignments</a>,

Up:<a rel="up" accesskey="u" href="Assignments.html#Assignments">Assignments</a>

<hr><br>

</div>



<h4 class="subsection">PROVIDE</h4>



   <p>In some cases, it is desirable for a linker script to define a symbol

only if it is referenced and is not defined by any object included in

the link.  For example, traditional linkers defined the symbol

<code>etext</code>.  However, ANSI C requires that the user be able to use

<code>etext</code> as a function name without encountering an error.  The

<code>PROVIDE</code> keyword may be used to define a symbol, such as

<code>etext</code>, only if it is referenced but not defined.  The syntax is

<code>PROVIDE(</code><var>symbol</var><code> = </code><var>expression</var><code>)</code>.



   <p>Here is an example of using <code>PROVIDE</code> to define <code>etext</code>:

<pre class="smallexample">     SECTIONS

     {

       .text :

         {

           *(.text)

           _etext = .;

           PROVIDE(etext = .);

         }

     }

     </pre>



   <p>In this example, if the program defines <code>_etext</code> (with a leading

underscore), the linker will give a multiple definition error.  If, on

the other hand, the program defines <code>etext</code> (with no leading

underscore), the linker will silently use the definition in the program. 

If the program references <code>etext</code> but does not define it, the

linker will use the definition in the linker script.



   </body></html>



⌨️ 快捷键说明

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