1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- This file documents the GNU Assembler "as".
4
5Copyright (C) 1991-2021 Free Software Foundation, Inc.
6
7Permission is granted to copy, distribute and/or modify this document
8under the terms of the GNU Free Documentation License, Version 1.3
9or any later version published by the Free Software Foundation;
10with no Invariant Sections, with no Front-Cover Texts, and with no
11Back-Cover Texts.  A copy of the license is included in the
12section entitled "GNU Free Documentation License".
13 -->
14<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
15<head>
16<title>Using as: Literal Directive</title>
17
18<meta name="description" content="Using as: Literal Directive">
19<meta name="keywords" content="Using as: Literal Directive">
20<meta name="resource-type" content="document">
21<meta name="distribution" content="global">
22<meta name="Generator" content="makeinfo">
23<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
24<link href="index.html#Top" rel="start" title="Top">
25<link href="AS-Index.html#AS-Index" rel="index" title="AS Index">
26<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
27<link href="Xtensa-Directives.html#Xtensa-Directives" rel="up" title="Xtensa Directives">
28<link href="Literal-Position-Directive.html#Literal-Position-Directive" rel="next" title="Literal Position Directive">
29<link href="Transform-Directive.html#Transform-Directive" rel="previous" title="Transform Directive">
30<style type="text/css">
31<!--
32a.summary-letter {text-decoration: none}
33blockquote.smallquotation {font-size: smaller}
34div.display {margin-left: 3.2em}
35div.example {margin-left: 3.2em}
36div.indentedblock {margin-left: 3.2em}
37div.lisp {margin-left: 3.2em}
38div.smalldisplay {margin-left: 3.2em}
39div.smallexample {margin-left: 3.2em}
40div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
41div.smalllisp {margin-left: 3.2em}
42kbd {font-style:oblique}
43pre.display {font-family: inherit}
44pre.format {font-family: inherit}
45pre.menu-comment {font-family: serif}
46pre.menu-preformatted {font-family: serif}
47pre.smalldisplay {font-family: inherit; font-size: smaller}
48pre.smallexample {font-size: smaller}
49pre.smallformat {font-family: inherit; font-size: smaller}
50pre.smalllisp {font-size: smaller}
51span.nocodebreak {white-space:nowrap}
52span.nolinebreak {white-space:nowrap}
53span.roman {font-family:serif; font-weight:normal}
54span.sansserif {font-family:sans-serif; font-weight:normal}
55ul.no-bullet {list-style: none}
56-->
57</style>
58
59
60</head>
61
62<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
63<a name="Literal-Directive"></a>
64<div class="header">
65<p>
66Next: <a href="Literal-Position-Directive.html#Literal-Position-Directive" accesskey="n" rel="next">Literal Position Directive</a>, Previous: <a href="Transform-Directive.html#Transform-Directive" accesskey="p" rel="previous">Transform Directive</a>, Up: <a href="Xtensa-Directives.html#Xtensa-Directives" accesskey="u" rel="up">Xtensa Directives</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
67</div>
68<hr>
69<a name="literal"></a>
70<h4 class="subsubsection">9.55.5.4 literal</h4>
71<a name="index-literal-directive"></a>
72
73<p>The <code>.literal</code> directive is used to define literal pool data, i.e.,
74read-only 32-bit data accessed via <code>L32R</code> instructions.
75</p>
76<div class="smallexample">
77<pre class="smallexample">    .literal <var>label</var>, <var>value</var>[, <var>value</var>&hellip;]
78</pre></div>
79
80<p>This directive is similar to the standard <code>.word</code> directive, except
81that the actual location of the literal data is determined by the
82assembler and linker, not by the position of the <code>.literal</code>
83directive.  Using this directive gives the assembler freedom to locate
84the literal data in the most appropriate place and possibly to combine
85identical literals.  For example, the code:
86</p>
87<div class="smallexample">
88<pre class="smallexample">    entry sp, 40
89    .literal .L1, sym
90    l32r    a4, .L1
91</pre></div>
92
93<p>can be used to load a pointer to the symbol <code>sym</code> into register
94<code>a4</code>.  The value of <code>sym</code> will not be placed between the
95<code>ENTRY</code> and <code>L32R</code> instructions; instead, the assembler puts
96the data in a literal pool.
97</p>
98<p>Literal pools are placed by default in separate literal sections;
99however, when using the &lsquo;<samp>--text-section-literals</samp>&rsquo;
100option (see <a href="Xtensa-Options.html#Xtensa-Options">Command-line Options</a>), the literal
101pools for PC-relative mode <code>L32R</code> instructions
102are placed in the current section.<a name="DOCF3" href="#FOOT3"><sup>3</sup></a>
103These text section literal
104pools are created automatically before <code>ENTRY</code> instructions and
105manually after &lsquo;<samp>.literal_position</samp>&rsquo; directives (see <a href="Literal-Position-Directive.html#Literal-Position-Directive">literal_position</a>).  If there are no preceding
106<code>ENTRY</code> instructions, explicit <code>.literal_position</code> directives
107must be used to place the text section literal pools; otherwise,
108<code>as</code> will report an error.
109</p>
110<p>When literals are placed in separate sections, the literal section names
111are derived from the names of the sections where the literals are
112defined.  The base literal section names are <code>.literal</code> for
113PC-relative mode <code>L32R</code> instructions and <code>.lit4</code> for absolute
114mode <code>L32R</code> instructions (see <a href="Absolute-Literals-Directive.html#Absolute-Literals-Directive">absolute-literals</a>).  These base names are used for literals defined in
115the default <code>.text</code> section.  For literals defined in other
116sections or within the scope of a <code>literal_prefix</code> directive
117(see <a href="Literal-Prefix-Directive.html#Literal-Prefix-Directive">literal_prefix</a>), the following rules
118determine the literal section name:
119</p>
120<ol>
121<li> If the current section is a member of a section group, the literal
122section name includes the group name as a suffix to the base
123<code>.literal</code> or <code>.lit4</code> name, with a period to separate the base
124name and group name.  The literal section is also made a member of the
125group.
126
127</li><li> If the current section name (or <code>literal_prefix</code> value) begins with
128&ldquo;<code>.gnu.linkonce.<var>kind</var>.</code>&rdquo;, the literal section name is formed
129by replacing &ldquo;<code>.<var>kind</var></code>&rdquo; with the base <code>.literal</code> or
130<code>.lit4</code> name.  For example, for literals defined in a section named
131<code>.gnu.linkonce.t.func</code>, the literal section will be
132<code>.gnu.linkonce.literal.func</code> or <code>.gnu.linkonce.lit4.func</code>.
133
134</li><li> If the current section name (or <code>literal_prefix</code> value) ends with
135<code>.text</code>, the literal section name is formed by replacing that
136suffix with the base <code>.literal</code> or <code>.lit4</code> name.  For example,
137for literals defined in a section named <code>.iram0.text</code>, the literal
138section will be <code>.iram0.literal</code> or <code>.iram0.lit4</code>.
139
140</li><li> If none of the preceding conditions apply, the literal section name is
141formed by adding the base <code>.literal</code> or <code>.lit4</code> name as a
142suffix to the current section name (or <code>literal_prefix</code> value).
143</li></ol>
144
145<div class="footnote">
146<hr>
147<h4 class="footnotes-heading">Footnotes</h4>
148
149<h3><a name="FOOT3" href="#DOCF3">(3)</a></h3>
150<p>Literals for the
151<code>.init</code> and <code>.fini</code> sections are always placed in separate
152sections, even when &lsquo;<samp>--text-section-literals</samp>&rsquo; is enabled.</p>
153</div>
154<hr>
155<div class="header">
156<p>
157Next: <a href="Literal-Position-Directive.html#Literal-Position-Directive" accesskey="n" rel="next">Literal Position Directive</a>, Previous: <a href="Transform-Directive.html#Transform-Directive" accesskey="p" rel="previous">Transform Directive</a>, Up: <a href="Xtensa-Directives.html#Xtensa-Directives" accesskey="u" rel="up">Xtensa Directives</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
158</div>
159
160
161
162</body>
163</html>
164