14 This document describes extensions to tools and formats LLVM seeks compatibility
17 General Assembly Syntax
18 ===========================
20 C99-style Hexadecimal Floating-point Constants
21 ----------------------------------------------
23 LLVM's assemblers allow floating-point constants to be written in C99's
24 hexadecimal format instead of decimal if desired.
31 Machine-specific Assembly Syntax
32 ================================
40 The following additional relocation types are supported:
42 **@IMGREL** (AT&T syntax only) generates an image-relative relocation that
43 corresponds to the COFF relocation types ``IMAGE_REL_I386_DIR32NB`` (32-bit) or
44 ``IMAGE_REL_AMD64_ADDR32NB`` (64-bit).
50 mov foo@IMGREL(%ebx, %ecx, 4), %eax
54 .long (fun@imgrel + 0x3F)
55 .long $unwind$fun@imgrel
57 **.secrel32** generates a relocation that corresponds to the COFF relocation
58 types ``IMAGE_REL_I386_SECREL`` (32-bit) or ``IMAGE_REL_AMD64_SECREL`` (64-bit).
60 **.secidx** relocation generates an index of the section that contains
61 the target. It corresponds to the COFF relocation types
62 ``IMAGE_REL_I386_SECTION`` (32-bit) or ``IMAGE_REL_AMD64_SECTION`` (64-bit).
66 .section .debug$S,"rn"
70 .secrel32 _function_name
71 .secidx _function_name
74 ``.linkonce`` Directive
75 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
79 ``.linkonce [ comdat type ]``
81 Supported COMDAT types:
84 Discards duplicate sections with the same COMDAT symbol. This is the default
85 if no type is specified.
88 If the symbol is defined multiple times, the linker issues an error.
91 Duplicates are discarded, but the linker issues an error if any have
95 Duplicates are discarded, but the linker issues an error if any duplicates
96 do not have exactly the same content.
99 Links the largest section from among the duplicates.
102 Links the newest section from among the duplicates.
111 ``.section`` Directive
112 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
114 MC supports passing the information in ``.linkonce`` at the end of
115 ``.section``. For example, these two codes are equivalent
119 .section secName, "dr", discard, "Symbol1"
126 .section secName, "dr"
132 Note that in the combined form the COMDAT symbol is explicit. This
133 extension exists to support multiple sections with the same name in
139 .section secName, "dr", discard, "Symbol1"
144 .section secName, "dr", discard, "Symbol2"
149 In addition to the types allowed with ``.linkonce``, ``.section`` also accepts
150 ``associative``. The meaning is that the section is linked if a certain other
151 COMDAT section is linked. This other section is indicated by the comdat symbol
152 in this directive. It can be any symbol defined in the associated section, but
153 is usually the associated section's comdat.
155 The following restrictions apply to the associated section:
157 1. It must be a COMDAT section.
158 2. It cannot be another associative COMDAT section.
160 In the following example the symobl ``sym`` is the comdat symbol of ``.foo``
161 and ``.bar`` is associated to ``.foo``.
165 .section .foo,"bw",discard, "sym"
166 .section .bar,"rd",associative, "sym"
172 ``.section`` Directive
173 ^^^^^^^^^^^^^^^^^^^^^^
175 In order to support creating multiple sections with the same name and comdat,
176 it is possible to add an unique number at the end of the ``.seciton`` directive.
177 For example, the following code creates two sections named ``.text``.
181 .section .text,"ax",@progbits,unique,1
184 .section .text,"ax",@progbits,unique,2
188 The unique number is not present in the resulting object at all. It is just used
189 in the assembler to differentiate the sections.
191 Target Specific Behaviour
192 =========================
200 The reference implementation (Microsoft Visual Studio 2012) emits stack probes
201 in the following fashion:
209 However, this has the limitation of 32 MiB (±16MiB). In order to accommodate
210 larger binaries, LLVM supports the use of ``-mcode-model=large`` to allow a 4GiB
211 range via a slight deviation. It will generate an indirect jump as follows:
216 movw r12, :lower16:__chkstk
217 movt r12, :upper16:__chkstk
221 Variable Length Arrays
222 ^^^^^^^^^^^^^^^^^^^^^^
224 The reference implementation (Microsoft Visual Studio 2012) does not permit the
225 emission of Variable Length Arrays (VLAs).
227 The Windows ARM Itanium ABI extends the base ABI by adding support for emitting
228 a dynamic stack allocation. When emitting a variable stack allocation, a call
229 to ``__chkstk`` is emitted unconditionally to ensure that guard pages are setup
230 properly. The emission of this stack probe emission is handled similar to the
231 standard stack probe emission.
233 The MSVC environment does not emit code for VLAs currently.