📄 simple-assignments.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="Simple%20Assignments">Simple Assignments</a>,
Next:<a rel="next" accesskey="n" href="PROVIDE.html#PROVIDE">PROVIDE</a>,
Up:<a rel="up" accesskey="u" href="Assignments.html#Assignments">Assignments</a>
<hr><br>
</div>
<h4 class="subsection">Simple Assignments</h4>
<p>You may assign to a symbol using any of the C assignment operators:
<dl>
<dt><code></code><var>symbol</var><code> = </code><var>expression</var><code> ;</code>
<dd><dt><code></code><var>symbol</var><code> += </code><var>expression</var><code> ;</code>
<dd><dt><code></code><var>symbol</var><code> -= </code><var>expression</var><code> ;</code>
<dd><dt><code></code><var>symbol</var><code> *= </code><var>expression</var><code> ;</code>
<dd><dt><code></code><var>symbol</var><code> /= </code><var>expression</var><code> ;</code>
<dd><dt><code></code><var>symbol</var><code> <<= </code><var>expression</var><code> ;</code>
<dd><dt><code></code><var>symbol</var><code> >>= </code><var>expression</var><code> ;</code>
<dd><dt><code></code><var>symbol</var><code> &= </code><var>expression</var><code> ;</code>
<dd><dt><code></code><var>symbol</var><code> |= </code><var>expression</var><code> ;</code>
<dd></dl>
<p>The first case will define <var>symbol</var> to the value of
<var>expression</var>. In the other cases, <var>symbol</var> must already be
defined, and the value will be adjusted accordingly.
<p>The special symbol name <code>.</code> indicates the location counter. You
may only use this within a <code>SECTIONS</code> command.
<p>The semicolon after <var>expression</var> is required.
<p>Expressions are defined below; see <a href="Expressions.html#Expressions">Expressions</a>.
<p>You may write symbol assignments as commands in their own right, or as
statements within a <code>SECTIONS</code> command, or as part of an output
section description in a <code>SECTIONS</code> command.
<p>The section of the symbol will be set from the section of the
expression; for more information, see <a href="Expression-Section.html#Expression%20Section">Expression Section</a>.
<p>Here is an example showing the three different places that symbol
assignments may be used:
<pre class="smallexample"> floating_point = 0;
SECTIONS
{
.text :
{
*(.text)
_etext = .;
}
_bdata = (. + 3) & ~ 3;
.data : { *(.data) }
}
</pre>
<p>In this example, the symbol <code>floating_point</code> will be defined as
zero. The symbol <code>_etext</code> will be defined as the address following
the last <code>.text</code> input section. The symbol <code>_bdata</code> will be
defined as the address following the <code>.text</code> output section aligned
upward to a 4 byte boundary.
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -