94 lines
4.5 KiB
HTML
94 lines
4.5 KiB
HTML
<html lang="en">
|
|
<head>
|
|
<title>Simple Assignments - Untitled</title>
|
|
<meta http-equiv="Content-Type" content="text/html">
|
|
<meta name="description" content="Untitled">
|
|
<meta name="generator" content="makeinfo 4.13">
|
|
<link title="Top" rel="start" href="index.html#Top">
|
|
<link rel="up" href="Assignments.html#Assignments" title="Assignments">
|
|
<link rel="next" href="HIDDEN.html#HIDDEN" title="HIDDEN">
|
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
|
<!--
|
|
This file documents the GNU linker LD
|
|
(GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10))
|
|
version 2.33.1.
|
|
|
|
Copyright (C) 1991-2019 Free Software Foundation, Inc.
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3
|
|
or any later version published by the Free Software Foundation;
|
|
with no Invariant Sections, with no Front-Cover Texts, and with no
|
|
Back-Cover Texts. A copy of the license is included in the
|
|
section entitled ``GNU Free Documentation License''.-->
|
|
<meta http-equiv="Content-Style-Type" content="text/css">
|
|
<style type="text/css"><!--
|
|
pre.display { font-family:inherit }
|
|
pre.format { font-family:inherit }
|
|
pre.smalldisplay { font-family:inherit; font-size:smaller }
|
|
pre.smallformat { font-family:inherit; font-size:smaller }
|
|
pre.smallexample { font-size:smaller }
|
|
pre.smalllisp { font-size:smaller }
|
|
span.sc { font-variant:small-caps }
|
|
span.roman { font-family:serif; font-weight:normal; }
|
|
span.sansserif { font-family:sans-serif; font-weight:normal; }
|
|
--></style>
|
|
</head>
|
|
<body>
|
|
<div class="node">
|
|
<a name="Simple-Assignments"></a>
|
|
<p>
|
|
Next: <a rel="next" accesskey="n" href="HIDDEN.html#HIDDEN">HIDDEN</a>,
|
|
Up: <a rel="up" accesskey="u" href="Assignments.html#Assignments">Assignments</a>
|
|
<hr>
|
|
</div>
|
|
|
|
<h4 class="subsection">3.5.1 Simple Assignments</h4>
|
|
|
|
<p>You may assign to a symbol using any of the C assignment operators:
|
|
|
|
<dl>
|
|
<dt><var>symbol</var><code> = </code><var>expression</var><code> ;</code><dt><var>symbol</var><code> += </code><var>expression</var><code> ;</code><dt><var>symbol</var><code> -= </code><var>expression</var><code> ;</code><dt><var>symbol</var><code> *= </code><var>expression</var><code> ;</code><dt><var>symbol</var><code> /= </code><var>expression</var><code> ;</code><dt><var>symbol</var><code> <<= </code><var>expression</var><code> ;</code><dt><var>symbol</var><code> >>= </code><var>expression</var><code> ;</code><dt><var>symbol</var><code> &= </code><var>expression</var><code> ;</code><dt><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 ‘<samp><span class="samp">.</span></samp>’ indicates the location counter. You
|
|
may only use this within a <code>SECTIONS</code> command. See <a href="Location-Counter.html#Location-Counter">Location Counter</a>.
|
|
|
|
<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-Section">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 class="noindent">In this example, the symbol ‘<samp><span class="samp">floating_point</span></samp>’ will be defined as
|
|
zero. The symbol ‘<samp><span class="samp">_etext</span></samp>’ will be defined as the address following
|
|
the last ‘<samp><span class="samp">.text</span></samp>’ input section. The symbol ‘<samp><span class="samp">_bdata</span></samp>’ will be
|
|
defined as the address following the ‘<samp><span class="samp">.text</span></samp>’ output section aligned
|
|
upward to a 4 byte boundary.
|
|
|
|
</body></html>
|
|
|