include/elf/
[deliverable/binutils-gdb.git] / gas / doc / c-cris.texi
CommitLineData
328eb32e
HPN
1@c Copyright 2002 Free Software Foundation, Inc.
2@c This is part of the GAS manual.
3@c For copying conditions, see the file as.texinfo.
4@c CRIS description contributed by Axis Communications.
5@ifset GENERIC
6@page
7@node CRIS-Dependent
8@chapter CRIS Dependent Features
9@end ifset
10@ifclear GENERIC
11@node Machine Dependencies
12@chapter CRIS Dependent Features
13@end ifclear
14
15@cindex CRIS support
16@menu
17* CRIS-Opts:: Command-line Options
18* CRIS-Expand:: Instruction expansion
19* CRIS-Syntax:: Syntax
20@end menu
21
22@node CRIS-Opts
23@section Command-line Options
24
25@cindex options, CRIS
26@cindex CRIS options
27The CRIS version of @code{@value{AS}} has these
28machine-dependent command-line options.
29
30@cindex @option{--emulation=criself} command line option, CRIS
31@cindex @option{--emulation=crisaout} command line option, CRIS
32@cindex CRIS @option{--emulation=criself} command line option
33@cindex CRIS @option{--emulation=crisaout} command line option
34
35The format of the generated object files can be either ELF or
36a.out, specified by the command-line options
37@option{--emulation=crisaout} and @option{--emulation=criself}.
38The default is ELF (criself), unless @code{@value{AS}} has been
39configured specifically for a.out by using the configuration
40name @code{cris-axis-aout}.
41
42@cindex @option{--underscore} command line option, CRIS
43@cindex @option{--no-underscore} command line option, CRIS
44@cindex CRIS @option{--underscore} command line option
45@cindex CRIS @option{--no-underscore} command line option
46There are two different link-incompatible ELF object file
47variants for CRIS, for use in environments where symbols are
48expected to be prefixed by a leading @samp{_} character and for
49environments without such a symbol prefix. The variant used for
50GNU/Linux port has no symbol prefix. Which variant to produce
51is specified by either of the options @option{--underscore} and
52@option{--no-underscore}. The default is @option{--underscore}.
53Since symbols in CRIS a.out objects are expected to have a
54@samp{_} prefix, specifying @option{--no-underscore} when
55generating a.out objects is an error. Besides the object format
56difference, the effect of this option is to parse register names
57differently (@pxref{crisnous}). The @option{--no-underscore}
58option makes a @samp{$} register prefix mandatory.
59
60@cindex @option{--pic} command line option, CRIS
61@cindex CRIS @option{--pic} command line option
62@cindex Position-independent code, CRIS
63@cindex CRIS position-independent code
64The option @option{--pic} must be passed to @code{@value{AS}} in
65order to recognize the symbol syntax used for ELF (SVR4 PIC)
66position-independent-code (@pxref{crispic}). This will also
67affect expansion of instructions. The expansion with
68@option{--pic} will use PC-relative rather than (slightly
69faster) absolute addresses in those expansions.
70
71@cindex @option{-N} command line option, CRIS
72@cindex CRIS @option{-N} command line option
73When @option{-N} is specified, @code{@value{AS}} will emit a
74warning when a 16-bit branch instruction is expanded into a
7532-bit multiple-instruction construct (@pxref{CRIS-Expand}).
76
77@node CRIS-Expand
78@section Instruction expansion
79
80@cindex instruction expansion, CRIS
81@cindex CRIS instruction expansion
82@code{@value{AS}} will silently choose an instruction that fits
83the operand size for @samp{[register+constant]} operands. For
84example, the offset @code{127} in @code{move.d [r3+127],r4} fits
85in an instruction using a signed-byte offset. Similarly,
86@code{move.d [r2+32767],r1} will generate an instruction using a
8716-bit offset. For symbolic expressions and constants that do
88not fit in 16 bits including the sign bit, a 32-bit offset is
89generated.
90
91For branches, @code{@value{AS}} will expand from a 16-bit branch
92instruction into a sequence of instructions that can reach a
93full 32-bit address. Since this does not correspond to a single
94instruction, such expansions can optionally be warned about.
95@xref{CRIS-Opts}.
96
97@node CRIS-Syntax
98@section Syntax
99
100There are different aspects of the CRIS assembly syntax.
101
102@menu
103* CRIS-Chars:: Special Characters
104* CRIS-Pic:: Position-Independent Code Symbols
105* CRIS-Regs:: Register Names
106* CRIS-Pseudos:: Assembler Directives
107@end menu
108
109@node CRIS-Chars
110@subsection Special Characters
111@cindex line comment characters, CRIS
112@cindex CRIS line comment characters
113
114The character @samp{#} is a line comment character. It starts a
115comment if and only if it is placed at the beginning of a line.
116
117A @samp{;} character starts a comment anywhere on the line,
118causing all characters up to the end of the line to be ignored.
119
120A @samp{@@} character is handled as a line separator equivalent
121to a logical new-line character (except in a comment), so
122separate instructions can be specified on a single line.
123
124@node CRIS-Pic
125@subsection Symbols in position-independent code
126@cindex Symbols in position-independent code, CRIS
127@cindex CRIS symbols in position-independent code
128@cindex Position-independent code, symbols in, CRIS
129
130When generating @anchor{crispic}position-independent code (SVR4
131PIC) for use in cris-axis-linux-gnu shared libraries, symbol
132suffixes are used to specify what kind of run-time symbol lookup
133will be used, expressed in the object as different
134@emph{relocation types}. Usually, all absolute symbol values
135must be located in a table, the @emph{global offset table},
136leaving the code position-independent; independent of values of
137global symbols and independent of the address of the code. The
138suffix modifies the value of the symbol, into for example an
139index into the global offset table where the real symbol value
140is entered, or a PC-relative value, or a value relative to the
141start of the global offset table. All symbol suffixes start
142with the character @samp{:} (omitted in the list below). Every
143symbol use in code or a read-only section must therefore have a
144PIC suffix to enable a useful shared library to be created.
145Usually, these constructs must not be used with an additive
146constant offset as is usually allowed, i.e.@: no 4 as in
147@code{symbol + 4} is allowed. This restriction is checked at
148link-time, not at assembly-time.
149
150@table @code
151@item GOT
152
153Attaching this suffix to a symbol in an instruction causes the
154symbol to be entered into the global offset table. The value is
155a 32-bit index for that symbol into the global offset table.
156The name of the corresponding relocation is
157@samp{R_CRIS_32_GOT}. Example: @code{move.d
158[$r0+extsym:GOT],$r9}
159
160@item GOT16
161
162Same as for @samp{GOT}, but the value is a 16-bit index into the
163global offset table. The corresponding relocation is
164@samp{R_CRIS_16_GOT}. Example: @code{move.d
165[$r0+asymbol:GOT16],$r10}
166
167@item PLT
168
169This suffix is used for function symbols. It causes a
170@emph{procedure linkage table}, an array of code stubs, to be
171created at the time the shared object is created or linked
172against, together with a global offset table entry. The value
173is a pc-relative offset to the corresponding stub code in the
174procedure linkage table. This arrangement causes the run-time
175symbol resolver to be called to look up and set the value of the
176symbol the first time the function is called (at latest;
177depending environment variables). It is only safe to leave the
178symbol unresolved this way if all references are function calls.
179The name of the relocation is @samp{R_CRIS_32_PLT_PCREL}.
180Example: @code{add.d fnname:PLT,$pc}
181
182@item PLTG
183
184Like PLT, but the value is relative to the beginning of the
185global offset table. The relocation is
186@samp{R_CRIS_32_PLT_GOTREL}. Example: @code{move.d
187fnname:PLTG,$r3}
188
189@item GOTPLT
190
191Similar to @samp{PLT}, but the value of the symbol is a 32-bit
192index into the global offset table. This is somewhat of a mix
193between the effect of the @samp{GOT} and the @samp{PLT} suffix;
194the difference to @samp{GOT} is that there will be a procedure
195linkage table entry created, and that the symbol is assumed to
196be a function entry and will be resolved by the run-time
197resolver as with @samp{PLT}. The relocation is
198@samp{R_CRIS_32_GOTPLT}. Example: @code{jsr
199[$r0+fnname:GOTPLT]}
200
201@item GOTPLT16
202
203A variant of @samp{GOTPLT} giving a 16-bit value. Its
204relocation name is @samp{R_CRIS_16_GOTPLT}. Example: @code{jsr
205[$r0+fnname:GOTPLT16]}
206
207@item GOTOFF
208
209This suffix must only be attached to a local symbol, but may be
210used in an expression adding an offset. The value is the
211address of the symbol relative to the start of the global offset
212table. The relocation name is @samp{R_CRIS_32_GOTREL}.
213Example: @code{move.d [$r0+localsym:GOTOFF],r3}
214@end table
215
216@node CRIS-Regs
217@subsection Register names
218@cindex register names, CRIS
219@cindex CRIS register names
220
221A @samp{$} character may always prefix a general or special
222register name in an instruction operand but is mandatory when
223the option @option{--no-underscore} is specified or when the
224@code{.syntax register_prefix} directive is in effect
225(@pxref{crisnous}). Register names are case-insensitive.
226
227@node CRIS-Pseudos
228@subsection Assembler Directives
229@cindex assembler directives, CRIS
230@cindex pseudo-ops, CRIS
231@cindex CRIS assembler directives
232@cindex CRIS pseudo-ops
233
234There are a few CRIS-specific pseudo-directives in addition to
235the generic ones. @xref{Pseudo Ops}. Constants emitted by
236pseudo-directives are in little-endian order for CRIS. There is
237no support for floating-point-specific directives for CRIS.
238
239@table @code
240@item .dword EXPRESSIONS
241@cindex assembler directive .dword, CRIS
242@cindex pseudo-op .dword, CRIS
243@cindex CRIS assembler directive .dword
244@cindex CRIS pseudo-op .dword
245
246The @code{.dword} directive is a synonym for @code{.int},
247expecting zero or more EXPRESSIONS, separated by commas. For
248each expression, a 32-bit little-endian constant is emitted.
249
250@item .syntax ARGUMENT
251@cindex assembler directive .syntax, CRIS
252@cindex pseudo-op .syntax, CRIS
253@cindex CRIS assembler directive .syntax
254@cindex CRIS pseudo-op .syntax
255The @code{.syntax} directive takes as ARGUMENT one of the
256following case-sensitive choices.
257
258@table @code
259@item no_register_prefix
260
261The @code{.syntax no_register_prefix} @anchor{crisnous}directive
262makes a @samp{$} character prefix on all registers optional. It
263overrides a previous setting, including the corresponding effect
264of the option @option{--no-underscore}. If this directive is
265used when ordinary symbols do not have a @samp{_} character
266prefix, care must be taken to avoid ambiguities whether an
267operand is a register or a symbol; using symbols with names the
268same as general or special registers then invoke undefined
269behavior.
270
271@item register_prefix
272
273This directive makes a @samp{$} character prefix on all
274registers mandatory. It overrides a previous setting, including
275the corresponding effect of the option @option{--underscore}.
276
277@item leading_underscore
278
279This is an assertion directive, emitting an error if the
280@option{--no-underscore} option is in effect.
281
282@item no_leading_underscore
283
284This is the opposite of the @code{.syntax leading_underscore}
285directive and emits an error if the option @option{--underscore}
286is in effect.
287@end table
288
289@c If you compare with md_pseudo_table, you see that we don't
290@c document ".file" and ".loc" here. This is because we're just
291@c wrapping the corresponding ELF function and emitting an error for
292@c a.out.
293@end table
This page took 0.045423 seconds and 4 git commands to generate.