* symtab.h (SYMBOL_SET_LINKAGE_NAME): Update comment.
[deliverable/binutils-gdb.git] / gas / doc / c-arm.texi
1 @c Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2 @c 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
3 @c This is part of the GAS manual.
4 @c For copying conditions, see the file as.texinfo.
5
6 @ifset GENERIC
7 @page
8 @node ARM-Dependent
9 @chapter ARM Dependent Features
10 @end ifset
11
12 @ifclear GENERIC
13 @node Machine Dependencies
14 @chapter ARM Dependent Features
15 @end ifclear
16
17 @cindex ARM support
18 @cindex Thumb support
19 @menu
20 * ARM Options:: Options
21 * ARM Syntax:: Syntax
22 * ARM Floating Point:: Floating Point
23 * ARM Directives:: ARM Machine Directives
24 * ARM Opcodes:: Opcodes
25 * ARM Mapping Symbols:: Mapping Symbols
26 * ARM Unwinding Tutorial:: Unwinding
27 @end menu
28
29 @node ARM Options
30 @section Options
31 @cindex ARM options (none)
32 @cindex options for ARM (none)
33
34 @table @code
35
36 @cindex @code{-mcpu=} command line option, ARM
37 @item -mcpu=@var{processor}[+@var{extension}@dots{}]
38 This option specifies the target processor. The assembler will issue an
39 error message if an attempt is made to assemble an instruction which
40 will not execute on the target processor. The following processor names are
41 recognized:
42 @code{arm1},
43 @code{arm2},
44 @code{arm250},
45 @code{arm3},
46 @code{arm6},
47 @code{arm60},
48 @code{arm600},
49 @code{arm610},
50 @code{arm620},
51 @code{arm7},
52 @code{arm7m},
53 @code{arm7d},
54 @code{arm7dm},
55 @code{arm7di},
56 @code{arm7dmi},
57 @code{arm70},
58 @code{arm700},
59 @code{arm700i},
60 @code{arm710},
61 @code{arm710t},
62 @code{arm720},
63 @code{arm720t},
64 @code{arm740t},
65 @code{arm710c},
66 @code{arm7100},
67 @code{arm7500},
68 @code{arm7500fe},
69 @code{arm7t},
70 @code{arm7tdmi},
71 @code{arm7tdmi-s},
72 @code{arm8},
73 @code{arm810},
74 @code{strongarm},
75 @code{strongarm1},
76 @code{strongarm110},
77 @code{strongarm1100},
78 @code{strongarm1110},
79 @code{arm9},
80 @code{arm920},
81 @code{arm920t},
82 @code{arm922t},
83 @code{arm940t},
84 @code{arm9tdmi},
85 @code{fa526} (Faraday FA526 processor),
86 @code{fa626} (Faraday FA626 processor),
87 @code{arm9e},
88 @code{arm926e},
89 @code{arm926ej-s},
90 @code{arm946e-r0},
91 @code{arm946e},
92 @code{arm946e-s},
93 @code{arm966e-r0},
94 @code{arm966e},
95 @code{arm966e-s},
96 @code{arm968e-s},
97 @code{arm10t},
98 @code{arm10tdmi},
99 @code{arm10e},
100 @code{arm1020},
101 @code{arm1020t},
102 @code{arm1020e},
103 @code{arm1022e},
104 @code{arm1026ej-s},
105 @code{fa626te} (Faraday FA626TE processor),
106 @code{fa726te} (Faraday FA726TE processor),
107 @code{arm1136j-s},
108 @code{arm1136jf-s},
109 @code{arm1156t2-s},
110 @code{arm1156t2f-s},
111 @code{arm1176jz-s},
112 @code{arm1176jzf-s},
113 @code{mpcore},
114 @code{mpcorenovfp},
115 @code{cortex-a5},
116 @code{cortex-a8},
117 @code{cortex-a9},
118 @code{cortex-r4},
119 @code{cortex-r4f},
120 @code{cortex-m3},
121 @code{cortex-m1},
122 @code{cortex-m0},
123 @code{ep9312} (ARM920 with Cirrus Maverick coprocessor),
124 @code{i80200} (Intel XScale processor)
125 @code{iwmmxt} (Intel(r) XScale processor with Wireless MMX(tm) technology coprocessor)
126 and
127 @code{xscale}.
128 The special name @code{all} may be used to allow the
129 assembler to accept instructions valid for any ARM processor.
130
131 In addition to the basic instruction set, the assembler can be told to
132 accept various extension mnemonics that extend the processor using the
133 co-processor instruction space. For example, @code{-mcpu=arm920+maverick}
134 is equivalent to specifying @code{-mcpu=ep9312}. The following extensions
135 are currently supported:
136 @code{+maverick}
137 @code{+iwmmxt}
138 and
139 @code{+xscale}.
140
141 @cindex @code{-march=} command line option, ARM
142 @item -march=@var{architecture}[+@var{extension}@dots{}]
143 This option specifies the target architecture. The assembler will issue
144 an error message if an attempt is made to assemble an instruction which
145 will not execute on the target architecture. The following architecture
146 names are recognized:
147 @code{armv1},
148 @code{armv2},
149 @code{armv2a},
150 @code{armv2s},
151 @code{armv3},
152 @code{armv3m},
153 @code{armv4},
154 @code{armv4xm},
155 @code{armv4t},
156 @code{armv4txm},
157 @code{armv5},
158 @code{armv5t},
159 @code{armv5txm},
160 @code{armv5te},
161 @code{armv5texp},
162 @code{armv6},
163 @code{armv6j},
164 @code{armv6k},
165 @code{armv6z},
166 @code{armv6zk},
167 @code{armv7},
168 @code{armv7-a},
169 @code{armv7-r},
170 @code{armv7-m},
171 @code{iwmmxt}
172 and
173 @code{xscale}.
174 If both @code{-mcpu} and
175 @code{-march} are specified, the assembler will use
176 the setting for @code{-mcpu}.
177
178 The architecture option can be extended with the same instruction set
179 extension options as the @code{-mcpu} option.
180
181 @cindex @code{-mfpu=} command line option, ARM
182 @item -mfpu=@var{floating-point-format}
183
184 This option specifies the floating point format to assemble for. The
185 assembler will issue an error message if an attempt is made to assemble
186 an instruction which will not execute on the target floating point unit.
187 The following format options are recognized:
188 @code{softfpa},
189 @code{fpe},
190 @code{fpe2},
191 @code{fpe3},
192 @code{fpa},
193 @code{fpa10},
194 @code{fpa11},
195 @code{arm7500fe},
196 @code{softvfp},
197 @code{softvfp+vfp},
198 @code{vfp},
199 @code{vfp10},
200 @code{vfp10-r0},
201 @code{vfp9},
202 @code{vfpxd},
203 @code{vfpv2},
204 @code{vfpv3},
205 @code{vfpv3-fp16},
206 @code{vfpv3-d16},
207 @code{vfpv3-d16-fp16},
208 @code{vfpv3xd},
209 @code{vfpv3xd-d16},
210 @code{vfpv4},
211 @code{vfpv4-d16},
212 @code{arm1020t},
213 @code{arm1020e},
214 @code{arm1136jf-s},
215 @code{maverick},
216 @code{neon},
217 and
218 @code{neon-vfpv4}.
219
220 In addition to determining which instructions are assembled, this option
221 also affects the way in which the @code{.double} assembler directive behaves
222 when assembling little-endian code.
223
224 The default is dependent on the processor selected. For Architecture 5 or
225 later, the default is to assembler for VFP instructions; for earlier
226 architectures the default is to assemble for FPA instructions.
227
228 @cindex @code{-mthumb} command line option, ARM
229 @item -mthumb
230 This option specifies that the assembler should start assembling Thumb
231 instructions; that is, it should behave as though the file starts with a
232 @code{.code 16} directive.
233
234 @cindex @code{-mthumb-interwork} command line option, ARM
235 @item -mthumb-interwork
236 This option specifies that the output generated by the assembler should
237 be marked as supporting interworking.
238
239 @cindex @code{-mimplicit-it} command line option, ARM
240 @item -mimplicit-it=never
241 @itemx -mimplicit-it=always
242 @itemx -mimplicit-it=arm
243 @itemx -mimplicit-it=thumb
244 The @code{-mimplicit-it} option controls the behavior of the assembler when
245 conditional instructions are not enclosed in IT blocks.
246 There are four possible behaviors.
247 If @code{never} is specified, such constructs cause a warning in ARM
248 code and an error in Thumb-2 code.
249 If @code{always} is specified, such constructs are accepted in both
250 ARM and Thumb-2 code, where the IT instruction is added implicitly.
251 If @code{arm} is specified, such constructs are accepted in ARM code
252 and cause an error in Thumb-2 code.
253 If @code{thumb} is specified, such constructs cause a warning in ARM
254 code and are accepted in Thumb-2 code. If you omit this option, the
255 behavior is equivalent to @code{-mimplicit-it=arm}.
256
257 @cindex @code{-mapcs-26} command line option, ARM
258 @cindex @code{-mapcs-32} command line option, ARM
259 @item -mapcs-26
260 @itemx -mapcs-32
261 These options specify that the output generated by the assembler should
262 be marked as supporting the indicated version of the Arm Procedure.
263 Calling Standard.
264
265 @cindex @code{-matpcs} command line option, ARM
266 @item -matpcs
267 This option specifies that the output generated by the assembler should
268 be marked as supporting the Arm/Thumb Procedure Calling Standard. If
269 enabled this option will cause the assembler to create an empty
270 debugging section in the object file called .arm.atpcs. Debuggers can
271 use this to determine the ABI being used by.
272
273 @cindex @code{-mapcs-float} command line option, ARM
274 @item -mapcs-float
275 This indicates the floating point variant of the APCS should be
276 used. In this variant floating point arguments are passed in FP
277 registers rather than integer registers.
278
279 @cindex @code{-mapcs-reentrant} command line option, ARM
280 @item -mapcs-reentrant
281 This indicates that the reentrant variant of the APCS should be used.
282 This variant supports position independent code.
283
284 @cindex @code{-mfloat-abi=} command line option, ARM
285 @item -mfloat-abi=@var{abi}
286 This option specifies that the output generated by the assembler should be
287 marked as using specified floating point ABI.
288 The following values are recognized:
289 @code{soft},
290 @code{softfp}
291 and
292 @code{hard}.
293
294 @cindex @code{-eabi=} command line option, ARM
295 @item -meabi=@var{ver}
296 This option specifies which EABI version the produced object files should
297 conform to.
298 The following values are recognized:
299 @code{gnu},
300 @code{4}
301 and
302 @code{5}.
303
304 @cindex @code{-EB} command line option, ARM
305 @item -EB
306 This option specifies that the output generated by the assembler should
307 be marked as being encoded for a big-endian processor.
308
309 @cindex @code{-EL} command line option, ARM
310 @item -EL
311 This option specifies that the output generated by the assembler should
312 be marked as being encoded for a little-endian processor.
313
314 @cindex @code{-k} command line option, ARM
315 @cindex PIC code generation for ARM
316 @item -k
317 This option specifies that the output of the assembler should be marked
318 as position-independent code (PIC).
319
320 @cindex @code{--fix-v4bx} command line option, ARM
321 @item --fix-v4bx
322 Allow @code{BX} instructions in ARMv4 code. This is intended for use with
323 the linker option of the same name.
324
325 @cindex @code{-mwarn-deprecated} command line option, ARM
326 @item -mwarn-deprecated
327 @itemx -mno-warn-deprecated
328 Enable or disable warnings about using deprecated options or
329 features. The default is to warn.
330
331 @end table
332
333
334 @node ARM Syntax
335 @section Syntax
336 @menu
337 * ARM-Instruction-Set:: Instruction Set
338 * ARM-Chars:: Special Characters
339 * ARM-Regs:: Register Names
340 * ARM-Relocations:: Relocations
341 @end menu
342
343 @node ARM-Instruction-Set
344 @subsection Instruction Set Syntax
345 Two slightly different syntaxes are support for ARM and THUMB
346 instructions. The default, @code{divided}, uses the old style where
347 ARM and THUMB instructions had their own, separate syntaxes. The new,
348 @code{unified} syntax, which can be selected via the @code{.syntax}
349 directive, and has the following main features:
350
351 @table @bullet
352 @item
353 Immediate operands do not require a @code{#} prefix.
354
355 @item
356 The @code{IT} instruction may appear, and if it does it is validated
357 against subsequent conditional affixes. In ARM mode it does not
358 generate machine code, in THUMB mode it does.
359
360 @item
361 For ARM instructions the conditional affixes always appear at the end
362 of the instruction. For THUMB instructions conditional affixes can be
363 used, but only inside the scope of an @code{IT} instruction.
364
365 @item
366 All of the instructions new to the V6T2 architecture (and later) are
367 available. (Only a few such instructions can be written in the
368 @code{divided} syntax).
369
370 @item
371 The @code{.N} and @code{.W} suffixes are recognized and honored.
372
373 @item
374 All instructions set the flags if and only if they have an @code{s}
375 affix.
376 @end table
377
378 @node ARM-Chars
379 @subsection Special Characters
380
381 @cindex line comment character, ARM
382 @cindex ARM line comment character
383 The presence of a @samp{@@} on a line indicates the start of a comment
384 that extends to the end of the current line. If a @samp{#} appears as
385 the first character of a line, the whole line is treated as a comment.
386
387 @cindex line separator, ARM
388 @cindex statement separator, ARM
389 @cindex ARM line separator
390 The @samp{;} character can be used instead of a newline to separate
391 statements.
392
393 @cindex immediate character, ARM
394 @cindex ARM immediate character
395 Either @samp{#} or @samp{$} can be used to indicate immediate operands.
396
397 @cindex identifiers, ARM
398 @cindex ARM identifiers
399 *TODO* Explain about /data modifier on symbols.
400
401 @node ARM-Regs
402 @subsection Register Names
403
404 @cindex ARM register names
405 @cindex register names, ARM
406 *TODO* Explain about ARM register naming, and the predefined names.
407
408 @node ARM Floating Point
409 @section Floating Point
410
411 @cindex floating point, ARM (@sc{ieee})
412 @cindex ARM floating point (@sc{ieee})
413 The ARM family uses @sc{ieee} floating-point numbers.
414
415 @node ARM-Relocations
416 @subsection ARM relocation generation
417
418 @cindex data relocations, ARM
419 @cindex ARM data relocations
420 Specific data relocations can be generated by putting the relocation name
421 in parentheses after the symbol name. For example:
422
423 @smallexample
424 .word foo(TARGET1)
425 @end smallexample
426
427 This will generate an @samp{R_ARM_TARGET1} relocation against the symbol
428 @var{foo}.
429 The following relocations are supported:
430 @code{GOT},
431 @code{GOTOFF},
432 @code{TARGET1},
433 @code{TARGET2},
434 @code{SBREL},
435 @code{TLSGD},
436 @code{TLSLDM},
437 @code{TLSLDO},
438 @code{GOTTPOFF}
439 and
440 @code{TPOFF}.
441
442 For compatibility with older toolchains the assembler also accepts
443 @code{(PLT)} after branch targets. This will generate the deprecated
444 @samp{R_ARM_PLT32} relocation.
445
446 @cindex MOVW and MOVT relocations, ARM
447 Relocations for @samp{MOVW} and @samp{MOVT} instructions can be generated
448 by prefixing the value with @samp{#:lower16:} and @samp{#:upper16}
449 respectively. For example to load the 32-bit address of foo into r0:
450
451 @smallexample
452 MOVW r0, #:lower16:foo
453 MOVT r0, #:upper16:foo
454 @end smallexample
455
456 @node ARM Directives
457 @section ARM Machine Directives
458
459 @cindex machine directives, ARM
460 @cindex ARM machine directives
461 @table @code
462
463 @c AAAAAAAAAAAAAAAAAAAAAAAAA
464
465 @cindex @code{.2byte} directive, ARM
466 @cindex @code{.4byte} directive, ARM
467 @cindex @code{.8byte} directive, ARM
468 @item .2byte @var{expression} [, @var{expression}]*
469 @itemx .4byte @var{expression} [, @var{expression}]*
470 @itemx .8byte @var{expression} [, @var{expression}]*
471 These directives write 2, 4 or 8 byte values to the output section.
472
473 @cindex @code{.align} directive, ARM
474 @item .align @var{expression} [, @var{expression}]
475 This is the generic @var{.align} directive. For the ARM however if the
476 first argument is zero (ie no alignment is needed) the assembler will
477 behave as if the argument had been 2 (ie pad to the next four byte
478 boundary). This is for compatibility with ARM's own assembler.
479
480 @cindex @code{.arch} directive, ARM
481 @item .arch @var{name}
482 Select the target architecture. Valid values for @var{name} are the same as
483 for the @option{-march} commandline option.
484
485 @cindex @code{.arm} directive, ARM
486 @item .arm
487 This performs the same action as @var{.code 32}.
488
489 @anchor{arm_pad}
490 @cindex @code{.pad} directive, ARM
491 @item .pad #@var{count}
492 Generate unwinder annotations for a stack adjustment of @var{count} bytes.
493 A positive value indicates the function prologue allocated stack space by
494 decrementing the stack pointer.
495
496 @c BBBBBBBBBBBBBBBBBBBBBBBBBB
497
498 @cindex @code{.bss} directive, ARM
499 @item .bss
500 This directive switches to the @code{.bss} section.
501
502 @c CCCCCCCCCCCCCCCCCCCCCCCCCC
503
504 @cindex @code{.cantunwind} directive, ARM
505 @item .cantunwind
506 Prevents unwinding through the current function. No personality routine
507 or exception table data is required or permitted.
508
509 @cindex @code{.code} directive, ARM
510 @item .code @code{[16|32]}
511 This directive selects the instruction set being generated. The value 16
512 selects Thumb, with the value 32 selecting ARM.
513
514 @cindex @code{.cpu} directive, ARM
515 @item .cpu @var{name}
516 Select the target processor. Valid values for @var{name} are the same as
517 for the @option{-mcpu} commandline option.
518
519 @c DDDDDDDDDDDDDDDDDDDDDDDDDD
520
521 @cindex @code{.dn} and @code{.qn} directives, ARM
522 @item @var{name} .dn @var{register name} [@var{.type}] [[@var{index}]]
523 @item @var{name} .qn @var{register name} [@var{.type}] [[@var{index}]]
524
525 The @code{dn} and @code{qn} directives are used to create typed
526 and/or indexed register aliases for use in Advanced SIMD Extension
527 (Neon) instructions. The former should be used to create aliases
528 of double-precision registers, and the latter to create aliases of
529 quad-precision registers.
530
531 If these directives are used to create typed aliases, those aliases can
532 be used in Neon instructions instead of writing types after the mnemonic
533 or after each operand. For example:
534
535 @smallexample
536 x .dn d2.f32
537 y .dn d3.f32
538 z .dn d4.f32[1]
539 vmul x,y,z
540 @end smallexample
541
542 This is equivalent to writing the following:
543
544 @smallexample
545 vmul.f32 d2,d3,d4[1]
546 @end smallexample
547
548 Aliases created using @code{dn} or @code{qn} can be destroyed using
549 @code{unreq}.
550
551 @c EEEEEEEEEEEEEEEEEEEEEEEEEE
552
553 @cindex @code{.eabi_attribute} directive, ARM
554 @item .eabi_attribute @var{tag}, @var{value}
555 Set the EABI object attribute @var{tag} to @var{value}.
556
557 The @var{tag} is either an attribute number, or one of the following:
558 @code{Tag_CPU_raw_name}, @code{Tag_CPU_name}, @code{Tag_CPU_arch},
559 @code{Tag_CPU_arch_profile}, @code{Tag_ARM_ISA_use},
560 @code{Tag_THUMB_ISA_use}, @code{Tag_VFP_arch}, @code{Tag_WMMX_arch},
561 @code{Tag_Advanced_SIMD_arch}, @code{Tag_PCS_config},
562 @code{Tag_ABI_PCS_R9_use}, @code{Tag_ABI_PCS_RW_data},
563 @code{Tag_ABI_PCS_RO_data}, @code{Tag_ABI_PCS_GOT_use},
564 @code{Tag_ABI_PCS_wchar_t}, @code{Tag_ABI_FP_rounding},
565 @code{Tag_ABI_FP_denormal}, @code{Tag_ABI_FP_exceptions},
566 @code{Tag_ABI_FP_user_exceptions}, @code{Tag_ABI_FP_number_model},
567 @code{Tag_ABI_align8_needed}, @code{Tag_ABI_align8_preserved},
568 @code{Tag_ABI_enum_size}, @code{Tag_ABI_HardFP_use},
569 @code{Tag_ABI_VFP_args}, @code{Tag_ABI_WMMX_args},
570 @code{Tag_ABI_optimization_goals}, @code{Tag_ABI_FP_optimization_goals},
571 @code{Tag_compatibility}, @code{Tag_CPU_unaligned_access},
572 @code{Tag_VFP_HP_extension}, @code{Tag_ABI_FP_16bit_format},
573 @code{Tag_nodefaults}, @code{Tag_also_compatible_with},
574 @code{Tag_conformance}, @code{Tag_T2EE_use},
575 @code{Tag_Virtualization_use}, @code{Tag_MPextension_use}
576
577 The @var{value} is either a @code{number}, @code{"string"}, or
578 @code{number, "string"} depending on the tag.
579
580 @cindex @code{.even} directive, ARM
581 @item .even
582 This directive aligns to an even-numbered address.
583
584 @cindex @code{.extend} directive, ARM
585 @cindex @code{.ldouble} directive, ARM
586 @item .extend @var{expression} [, @var{expression}]*
587 @itemx .ldouble @var{expression} [, @var{expression}]*
588 These directives write 12byte long double floating-point values to the
589 output section. These are not compatible with current ARM processors
590 or ABIs.
591
592 @c FFFFFFFFFFFFFFFFFFFFFFFFFF
593
594 @anchor{arm_fnend}
595 @cindex @code{.fnend} directive, ARM
596 @item .fnend
597 Marks the end of a function with an unwind table entry. The unwind index
598 table entry is created when this directive is processed.
599
600 If no personality routine has been specified then standard personality
601 routine 0 or 1 will be used, depending on the number of unwind opcodes
602 required.
603
604 @anchor{arm_fnstart}
605 @cindex @code{.fnstart} directive, ARM
606 @item .fnstart
607 Marks the start of a function with an unwind table entry.
608
609 @cindex @code{.force_thumb} directive, ARM
610 @item .force_thumb
611 This directive forces the selection of Thumb instructions, even if the
612 target processor does not support those instructions
613
614 @cindex @code{.fpu} directive, ARM
615 @item .fpu @var{name}
616 Select the floating-point unit to assemble for. Valid values for @var{name}
617 are the same as for the @option{-mfpu} commandline option.
618
619 @c GGGGGGGGGGGGGGGGGGGGGGGGGG
620 @c HHHHHHHHHHHHHHHHHHHHHHHHHH
621
622 @cindex @code{.handlerdata} directive, ARM
623 @item .handlerdata
624 Marks the end of the current function, and the start of the exception table
625 entry for that function. Anything between this directive and the
626 @code{.fnend} directive will be added to the exception table entry.
627
628 Must be preceded by a @code{.personality} or @code{.personalityindex}
629 directive.
630
631 @c IIIIIIIIIIIIIIIIIIIIIIIIII
632
633 @cindex @code{.inst} directive, ARM
634 @item .inst @var{opcode} [ , @dots{} ]
635 @item .inst.n @var{opcode} [ , @dots{} ]
636 @item .inst.w @var{opcode} [ , @dots{} ]
637 Generates the instruction corresponding to the numerical value @var{opcode}.
638 @code{.inst.n} and @code{.inst.w} allow the Thumb instruction size to be
639 specified explicitly, overriding the normal encoding rules.
640
641 @c JJJJJJJJJJJJJJJJJJJJJJJJJJ
642 @c KKKKKKKKKKKKKKKKKKKKKKKKKK
643 @c LLLLLLLLLLLLLLLLLLLLLLLLLL
644
645 @item .ldouble @var{expression} [, @var{expression}]*
646 See @code{.extend}.
647
648 @cindex @code{.ltorg} directive, ARM
649 @item .ltorg
650 This directive causes the current contents of the literal pool to be
651 dumped into the current section (which is assumed to be the .text
652 section) at the current location (aligned to a word boundary).
653 @code{GAS} maintains a separate literal pool for each section and each
654 sub-section. The @code{.ltorg} directive will only affect the literal
655 pool of the current section and sub-section. At the end of assembly
656 all remaining, un-empty literal pools will automatically be dumped.
657
658 Note - older versions of @code{GAS} would dump the current literal
659 pool any time a section change occurred. This is no longer done, since
660 it prevents accurate control of the placement of literal pools.
661
662 @c MMMMMMMMMMMMMMMMMMMMMMMMMM
663
664 @cindex @code{.movsp} directive, ARM
665 @item .movsp @var{reg} [, #@var{offset}]
666 Tell the unwinder that @var{reg} contains an offset from the current
667 stack pointer. If @var{offset} is not specified then it is assumed to be
668 zero.
669
670 @c NNNNNNNNNNNNNNNNNNNNNNNNNN
671 @c OOOOOOOOOOOOOOOOOOOOOOOOOO
672
673 @cindex @code{.object_arch} directive, ARM
674 @item .object_arch @var{name}
675 Override the architecture recorded in the EABI object attribute section.
676 Valid values for @var{name} are the same as for the @code{.arch} directive.
677 Typically this is useful when code uses runtime detection of CPU features.
678
679 @c PPPPPPPPPPPPPPPPPPPPPPPPPP
680
681 @cindex @code{.packed} directive, ARM
682 @item .packed @var{expression} [, @var{expression}]*
683 This directive writes 12-byte packed floating-point values to the
684 output section. These are not compatible with current ARM processors
685 or ABIs.
686
687 @cindex @code{.pad} directive, ARM
688 @item .pad #@var{count}
689 Generate unwinder annotations for a stack adjustment of @var{count} bytes.
690 A positive value indicates the function prologue allocated stack space by
691 decrementing the stack pointer.
692
693 @cindex @code{.personality} directive, ARM
694 @item .personality @var{name}
695 Sets the personality routine for the current function to @var{name}.
696
697 @cindex @code{.personalityindex} directive, ARM
698 @item .personalityindex @var{index}
699 Sets the personality routine for the current function to the EABI standard
700 routine number @var{index}
701
702 @cindex @code{.pool} directive, ARM
703 @item .pool
704 This is a synonym for .ltorg.
705
706 @c QQQQQQQQQQQQQQQQQQQQQQQQQQ
707 @c RRRRRRRRRRRRRRRRRRRRRRRRRR
708
709 @cindex @code{.req} directive, ARM
710 @item @var{name} .req @var{register name}
711 This creates an alias for @var{register name} called @var{name}. For
712 example:
713
714 @smallexample
715 foo .req r0
716 @end smallexample
717
718 @c SSSSSSSSSSSSSSSSSSSSSSSSSS
719
720 @anchor{arm_save}
721 @cindex @code{.save} directive, ARM
722 @item .save @var{reglist}
723 Generate unwinder annotations to restore the registers in @var{reglist}.
724 The format of @var{reglist} is the same as the corresponding store-multiple
725 instruction.
726
727 @smallexample
728 @exdent @emph{core registers}
729 .save @{r4, r5, r6, lr@}
730 stmfd sp!, @{r4, r5, r6, lr@}
731 @exdent @emph{FPA registers}
732 .save f4, 2
733 sfmfd f4, 2, [sp]!
734 @exdent @emph{VFP registers}
735 .save @{d8, d9, d10@}
736 fstmdx sp!, @{d8, d9, d10@}
737 @exdent @emph{iWMMXt registers}
738 .save @{wr10, wr11@}
739 wstrd wr11, [sp, #-8]!
740 wstrd wr10, [sp, #-8]!
741 or
742 .save wr11
743 wstrd wr11, [sp, #-8]!
744 .save wr10
745 wstrd wr10, [sp, #-8]!
746 @end smallexample
747
748 @anchor{arm_setfp}
749 @cindex @code{.setfp} directive, ARM
750 @item .setfp @var{fpreg}, @var{spreg} [, #@var{offset}]
751 Make all unwinder annotations relative to a frame pointer. Without this
752 the unwinder will use offsets from the stack pointer.
753
754 The syntax of this directive is the same as the @code{sub} or @code{mov}
755 instruction used to set the frame pointer. @var{spreg} must be either
756 @code{sp} or mentioned in a previous @code{.movsp} directive.
757
758 @smallexample
759 .movsp ip
760 mov ip, sp
761 @dots{}
762 .setfp fp, ip, #4
763 sub fp, ip, #4
764 @end smallexample
765
766 @cindex @code{.secrel32} directive, ARM
767 @item .secrel32 @var{expression} [, @var{expression}]*
768 This directive emits relocations that evaluate to the section-relative
769 offset of each expression's symbol. This directive is only supported
770 for PE targets.
771
772 @cindex @code{.syntax} directive, ARM
773 @item .syntax [@code{unified} | @code{divided}]
774 This directive sets the Instruction Set Syntax as described in the
775 @ref{ARM-Instruction-Set} section.
776
777 @c TTTTTTTTTTTTTTTTTTTTTTTTTT
778
779 @cindex @code{.thumb} directive, ARM
780 @item .thumb
781 This performs the same action as @var{.code 16}.
782
783 @cindex @code{.thumb_func} directive, ARM
784 @item .thumb_func
785 This directive specifies that the following symbol is the name of a
786 Thumb encoded function. This information is necessary in order to allow
787 the assembler and linker to generate correct code for interworking
788 between Arm and Thumb instructions and should be used even if
789 interworking is not going to be performed. The presence of this
790 directive also implies @code{.thumb}
791
792 This directive is not neccessary when generating EABI objects. On these
793 targets the encoding is implicit when generating Thumb code.
794
795 @cindex @code{.thumb_set} directive, ARM
796 @item .thumb_set
797 This performs the equivalent of a @code{.set} directive in that it
798 creates a symbol which is an alias for another symbol (possibly not yet
799 defined). This directive also has the added property in that it marks
800 the aliased symbol as being a thumb function entry point, in the same
801 way that the @code{.thumb_func} directive does.
802
803 @c UUUUUUUUUUUUUUUUUUUUUUUUUU
804
805 @cindex @code{.unreq} directive, ARM
806 @item .unreq @var{alias-name}
807 This undefines a register alias which was previously defined using the
808 @code{req}, @code{dn} or @code{qn} directives. For example:
809
810 @smallexample
811 foo .req r0
812 .unreq foo
813 @end smallexample
814
815 An error occurs if the name is undefined. Note - this pseudo op can
816 be used to delete builtin in register name aliases (eg 'r0'). This
817 should only be done if it is really necessary.
818
819 @cindex @code{.unwind_raw} directive, ARM
820 @item .unwind_raw @var{offset}, @var{byte1}, @dots{}
821 Insert one of more arbitary unwind opcode bytes, which are known to adjust
822 the stack pointer by @var{offset} bytes.
823
824 For example @code{.unwind_raw 4, 0xb1, 0x01} is equivalent to
825 @code{.save @{r0@}}
826
827 @c VVVVVVVVVVVVVVVVVVVVVVVVVV
828
829 @cindex @code{.vsave} directive, ARM
830 @item .vsave @var{vfp-reglist}
831 Generate unwinder annotations to restore the VFP registers in @var{vfp-reglist}
832 using FLDMD. Also works for VFPv3 registers
833 that are to be restored using VLDM.
834 The format of @var{vfp-reglist} is the same as the corresponding store-multiple
835 instruction.
836
837 @smallexample
838 @exdent @emph{VFP registers}
839 .vsave @{d8, d9, d10@}
840 fstmdd sp!, @{d8, d9, d10@}
841 @exdent @emph{VFPv3 registers}
842 .vsave @{d15, d16, d17@}
843 vstm sp!, @{d15, d16, d17@}
844 @end smallexample
845
846 Since FLDMX and FSTMX are now deprecated, this directive should be
847 used in favour of @code{.save} for saving VFP registers for ARMv6 and above.
848
849 @c WWWWWWWWWWWWWWWWWWWWWWWWWW
850 @c XXXXXXXXXXXXXXXXXXXXXXXXXX
851 @c YYYYYYYYYYYYYYYYYYYYYYYYYY
852 @c ZZZZZZZZZZZZZZZZZZZZZZZZZZ
853
854 @end table
855
856 @node ARM Opcodes
857 @section Opcodes
858
859 @cindex ARM opcodes
860 @cindex opcodes for ARM
861 @code{@value{AS}} implements all the standard ARM opcodes. It also
862 implements several pseudo opcodes, including several synthetic load
863 instructions.
864
865 @table @code
866
867 @cindex @code{NOP} pseudo op, ARM
868 @item NOP
869 @smallexample
870 nop
871 @end smallexample
872
873 This pseudo op will always evaluate to a legal ARM instruction that does
874 nothing. Currently it will evaluate to MOV r0, r0.
875
876 @cindex @code{LDR reg,=<label>} pseudo op, ARM
877 @item LDR
878 @smallexample
879 ldr <register> , = <expression>
880 @end smallexample
881
882 If expression evaluates to a numeric constant then a MOV or MVN
883 instruction will be used in place of the LDR instruction, if the
884 constant can be generated by either of these instructions. Otherwise
885 the constant will be placed into the nearest literal pool (if it not
886 already there) and a PC relative LDR instruction will be generated.
887
888 @cindex @code{ADR reg,<label>} pseudo op, ARM
889 @item ADR
890 @smallexample
891 adr <register> <label>
892 @end smallexample
893
894 This instruction will load the address of @var{label} into the indicated
895 register. The instruction will evaluate to a PC relative ADD or SUB
896 instruction depending upon where the label is located. If the label is
897 out of range, or if it is not defined in the same file (and section) as
898 the ADR instruction, then an error will be generated. This instruction
899 will not make use of the literal pool.
900
901 @cindex @code{ADRL reg,<label>} pseudo op, ARM
902 @item ADRL
903 @smallexample
904 adrl <register> <label>
905 @end smallexample
906
907 This instruction will load the address of @var{label} into the indicated
908 register. The instruction will evaluate to one or two PC relative ADD
909 or SUB instructions depending upon where the label is located. If a
910 second instruction is not needed a NOP instruction will be generated in
911 its place, so that this instruction is always 8 bytes long.
912
913 If the label is out of range, or if it is not defined in the same file
914 (and section) as the ADRL instruction, then an error will be generated.
915 This instruction will not make use of the literal pool.
916
917 @end table
918
919 For information on the ARM or Thumb instruction sets, see @cite{ARM
920 Software Development Toolkit Reference Manual}, Advanced RISC Machines
921 Ltd.
922
923 @node ARM Mapping Symbols
924 @section Mapping Symbols
925
926 The ARM ELF specification requires that special symbols be inserted
927 into object files to mark certain features:
928
929 @table @code
930
931 @cindex @code{$a}
932 @item $a
933 At the start of a region of code containing ARM instructions.
934
935 @cindex @code{$t}
936 @item $t
937 At the start of a region of code containing THUMB instructions.
938
939 @cindex @code{$d}
940 @item $d
941 At the start of a region of data.
942
943 @end table
944
945 The assembler will automatically insert these symbols for you - there
946 is no need to code them yourself. Support for tagging symbols ($b,
947 $f, $p and $m) which is also mentioned in the current ARM ELF
948 specification is not implemented. This is because they have been
949 dropped from the new EABI and so tools cannot rely upon their
950 presence.
951
952 @node ARM Unwinding Tutorial
953 @section Unwinding
954
955 The ABI for the ARM Architecture specifies a standard format for
956 exception unwind information. This information is used when an
957 exception is thrown to determine where control should be transferred.
958 In particular, the unwind information is used to determine which
959 function called the function that threw the exception, and which
960 function called that one, and so forth. This information is also used
961 to restore the values of callee-saved registers in the function
962 catching the exception.
963
964 If you are writing functions in assembly code, and those functions
965 call other functions that throw exceptions, you must use assembly
966 pseudo ops to ensure that appropriate exception unwind information is
967 generated. Otherwise, if one of the functions called by your assembly
968 code throws an exception, the run-time library will be unable to
969 unwind the stack through your assembly code and your program will not
970 behave correctly.
971
972 To illustrate the use of these pseudo ops, we will examine the code
973 that G++ generates for the following C++ input:
974
975 @verbatim
976 void callee (int *);
977
978 int
979 caller ()
980 {
981 int i;
982 callee (&i);
983 return i;
984 }
985 @end verbatim
986
987 This example does not show how to throw or catch an exception from
988 assembly code. That is a much more complex operation and should
989 always be done in a high-level language, such as C++, that directly
990 supports exceptions.
991
992 The code generated by one particular version of G++ when compiling the
993 example above is:
994
995 @verbatim
996 _Z6callerv:
997 .fnstart
998 .LFB2:
999 @ Function supports interworking.
1000 @ args = 0, pretend = 0, frame = 8
1001 @ frame_needed = 1, uses_anonymous_args = 0
1002 stmfd sp!, {fp, lr}
1003 .save {fp, lr}
1004 .LCFI0:
1005 .setfp fp, sp, #4
1006 add fp, sp, #4
1007 .LCFI1:
1008 .pad #8
1009 sub sp, sp, #8
1010 .LCFI2:
1011 sub r3, fp, #8
1012 mov r0, r3
1013 bl _Z6calleePi
1014 ldr r3, [fp, #-8]
1015 mov r0, r3
1016 sub sp, fp, #4
1017 ldmfd sp!, {fp, lr}
1018 bx lr
1019 .LFE2:
1020 .fnend
1021 @end verbatim
1022
1023 Of course, the sequence of instructions varies based on the options
1024 you pass to GCC and on the version of GCC in use. The exact
1025 instructions are not important since we are focusing on the pseudo ops
1026 that are used to generate unwind information.
1027
1028 An important assumption made by the unwinder is that the stack frame
1029 does not change during the body of the function. In particular, since
1030 we assume that the assembly code does not itself throw an exception,
1031 the only point where an exception can be thrown is from a call, such
1032 as the @code{bl} instruction above. At each call site, the same saved
1033 registers (including @code{lr}, which indicates the return address)
1034 must be located in the same locations relative to the frame pointer.
1035
1036 The @code{.fnstart} (@pxref{arm_fnstart,,.fnstart pseudo op}) pseudo
1037 op appears immediately before the first instruction of the function
1038 while the @code{.fnend} (@pxref{arm_fnend,,.fnend pseudo op}) pseudo
1039 op appears immediately after the last instruction of the function.
1040 These pseudo ops specify the range of the function.
1041
1042 Only the order of the other pseudos ops (e.g., @code{.setfp} or
1043 @code{.pad}) matters; their exact locations are irrelevant. In the
1044 example above, the compiler emits the pseudo ops with particular
1045 instructions. That makes it easier to understand the code, but it is
1046 not required for correctness. It would work just as well to emit all
1047 of the pseudo ops other than @code{.fnend} in the same order, but
1048 immediately after @code{.fnstart}.
1049
1050 The @code{.save} (@pxref{arm_save,,.save pseudo op}) pseudo op
1051 indicates registers that have been saved to the stack so that they can
1052 be restored before the function returns. The argument to the
1053 @code{.save} pseudo op is a list of registers to save. If a register
1054 is ``callee-saved'' (as specified by the ABI) and is modified by the
1055 function you are writing, then your code must save the value before it
1056 is modified and restore the original value before the function
1057 returns. If an exception is thrown, the run-time library restores the
1058 values of these registers from their locations on the stack before
1059 returning control to the exception handler. (Of course, if an
1060 exception is not thrown, the function that contains the @code{.save}
1061 pseudo op restores these registers in the function epilogue, as is
1062 done with the @code{ldmfd} instruction above.)
1063
1064 You do not have to save callee-saved registers at the very beginning
1065 of the function and you do not need to use the @code{.save} pseudo op
1066 immediately following the point at which the registers are saved.
1067 However, if you modify a callee-saved register, you must save it on
1068 the stack before modifying it and before calling any functions which
1069 might throw an exception. And, you must use the @code{.save} pseudo
1070 op to indicate that you have done so.
1071
1072 The @code{.pad} (@pxref{arm_pad,,.pad}) pseudo op indicates a
1073 modification of the stack pointer that does not save any registers.
1074 The argument is the number of bytes (in decimal) that are subtracted
1075 from the stack pointer. (On ARM CPUs, the stack grows downwards, so
1076 subtracting from the stack pointer increases the size of the stack.)
1077
1078 The @code{.setfp} (@pxref{arm_setfp,,.setfp pseudo op}) pseudo op
1079 indicates the register that contains the frame pointer. The first
1080 argument is the register that is set, which is typically @code{fp}.
1081 The second argument indicates the register from which the frame
1082 pointer takes its value. The third argument, if present, is the value
1083 (in decimal) added to the register specified by the second argument to
1084 compute the value of the frame pointer. You should not modify the
1085 frame pointer in the body of the function.
1086
1087 If you do not use a frame pointer, then you should not use the
1088 @code{.setfp} pseudo op. If you do not use a frame pointer, then you
1089 should avoid modifying the stack pointer outside of the function
1090 prologue. Otherwise, the run-time library will be unable to find
1091 saved registers when it is unwinding the stack.
1092
1093 The pseudo ops described above are sufficient for writing assembly
1094 code that calls functions which may throw exceptions. If you need to
1095 know more about the object-file format used to represent unwind
1096 information, you may consult the @cite{Exception Handling ABI for the
1097 ARM Architecture} available from @uref{http://infocenter.arm.com}.
This page took 0.051971 seconds and 4 git commands to generate.