annotate llvm/docs/Extensions.rst @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents 1f2b6ac9f198
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 ===============
anatofuz
parents:
diff changeset
2 LLVM Extensions
anatofuz
parents:
diff changeset
3 ===============
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 .. contents::
anatofuz
parents:
diff changeset
6 :local:
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 .. toctree::
anatofuz
parents:
diff changeset
9 :hidden:
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 Introduction
anatofuz
parents:
diff changeset
12 ============
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 This document describes extensions to tools and formats LLVM seeks compatibility
anatofuz
parents:
diff changeset
15 with.
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 General Assembly Syntax
anatofuz
parents:
diff changeset
18 ===========================
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 C99-style Hexadecimal Floating-point Constants
anatofuz
parents:
diff changeset
21 ----------------------------------------------
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 LLVM's assemblers allow floating-point constants to be written in C99's
anatofuz
parents:
diff changeset
24 hexadecimal format instead of decimal if desired.
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 .. code-block:: gas
anatofuz
parents:
diff changeset
27
anatofuz
parents:
diff changeset
28 .section .data
anatofuz
parents:
diff changeset
29 .float 0x1c2.2ap3
anatofuz
parents:
diff changeset
30
anatofuz
parents:
diff changeset
31 Machine-specific Assembly Syntax
anatofuz
parents:
diff changeset
32 ================================
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 X86/COFF-Dependent
anatofuz
parents:
diff changeset
35 ------------------
anatofuz
parents:
diff changeset
36
anatofuz
parents:
diff changeset
37 Relocations
anatofuz
parents:
diff changeset
38 ^^^^^^^^^^^
anatofuz
parents:
diff changeset
39
anatofuz
parents:
diff changeset
40 The following additional relocation types are supported:
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 **@IMGREL** (AT&T syntax only) generates an image-relative relocation that
anatofuz
parents:
diff changeset
43 corresponds to the COFF relocation types ``IMAGE_REL_I386_DIR32NB`` (32-bit) or
anatofuz
parents:
diff changeset
44 ``IMAGE_REL_AMD64_ADDR32NB`` (64-bit).
anatofuz
parents:
diff changeset
45
anatofuz
parents:
diff changeset
46 .. code-block:: text
anatofuz
parents:
diff changeset
47
anatofuz
parents:
diff changeset
48 .text
anatofuz
parents:
diff changeset
49 fun:
anatofuz
parents:
diff changeset
50 mov foo@IMGREL(%ebx, %ecx, 4), %eax
anatofuz
parents:
diff changeset
51
anatofuz
parents:
diff changeset
52 .section .pdata
anatofuz
parents:
diff changeset
53 .long fun@IMGREL
anatofuz
parents:
diff changeset
54 .long (fun@imgrel + 0x3F)
anatofuz
parents:
diff changeset
55 .long $unwind$fun@imgrel
anatofuz
parents:
diff changeset
56
anatofuz
parents:
diff changeset
57 **.secrel32** generates a relocation that corresponds to the COFF relocation
anatofuz
parents:
diff changeset
58 types ``IMAGE_REL_I386_SECREL`` (32-bit) or ``IMAGE_REL_AMD64_SECREL`` (64-bit).
anatofuz
parents:
diff changeset
59
anatofuz
parents:
diff changeset
60 **.secidx** relocation generates an index of the section that contains
anatofuz
parents:
diff changeset
61 the target. It corresponds to the COFF relocation types
anatofuz
parents:
diff changeset
62 ``IMAGE_REL_I386_SECTION`` (32-bit) or ``IMAGE_REL_AMD64_SECTION`` (64-bit).
anatofuz
parents:
diff changeset
63
anatofuz
parents:
diff changeset
64 .. code-block:: none
anatofuz
parents:
diff changeset
65
anatofuz
parents:
diff changeset
66 .section .debug$S,"rn"
anatofuz
parents:
diff changeset
67 .long 4
anatofuz
parents:
diff changeset
68 .long 242
anatofuz
parents:
diff changeset
69 .long 40
anatofuz
parents:
diff changeset
70 .secrel32 _function_name + 0
anatofuz
parents:
diff changeset
71 .secidx _function_name
anatofuz
parents:
diff changeset
72 ...
anatofuz
parents:
diff changeset
73
anatofuz
parents:
diff changeset
74 ``.linkonce`` Directive
anatofuz
parents:
diff changeset
75 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
76
anatofuz
parents:
diff changeset
77 Syntax:
anatofuz
parents:
diff changeset
78
anatofuz
parents:
diff changeset
79 ``.linkonce [ comdat type ]``
anatofuz
parents:
diff changeset
80
anatofuz
parents:
diff changeset
81 Supported COMDAT types:
anatofuz
parents:
diff changeset
82
anatofuz
parents:
diff changeset
83 ``discard``
anatofuz
parents:
diff changeset
84 Discards duplicate sections with the same COMDAT symbol. This is the default
anatofuz
parents:
diff changeset
85 if no type is specified.
anatofuz
parents:
diff changeset
86
anatofuz
parents:
diff changeset
87 ``one_only``
anatofuz
parents:
diff changeset
88 If the symbol is defined multiple times, the linker issues an error.
anatofuz
parents:
diff changeset
89
anatofuz
parents:
diff changeset
90 ``same_size``
anatofuz
parents:
diff changeset
91 Duplicates are discarded, but the linker issues an error if any have
anatofuz
parents:
diff changeset
92 different sizes.
anatofuz
parents:
diff changeset
93
anatofuz
parents:
diff changeset
94 ``same_contents``
anatofuz
parents:
diff changeset
95 Duplicates are discarded, but the linker issues an error if any duplicates
anatofuz
parents:
diff changeset
96 do not have exactly the same content.
anatofuz
parents:
diff changeset
97
anatofuz
parents:
diff changeset
98 ``largest``
anatofuz
parents:
diff changeset
99 Links the largest section from among the duplicates.
anatofuz
parents:
diff changeset
100
anatofuz
parents:
diff changeset
101 ``newest``
anatofuz
parents:
diff changeset
102 Links the newest section from among the duplicates.
anatofuz
parents:
diff changeset
103
anatofuz
parents:
diff changeset
104
anatofuz
parents:
diff changeset
105 .. code-block:: gas
anatofuz
parents:
diff changeset
106
anatofuz
parents:
diff changeset
107 .section .text$foo
anatofuz
parents:
diff changeset
108 .linkonce
anatofuz
parents:
diff changeset
109 ...
anatofuz
parents:
diff changeset
110
anatofuz
parents:
diff changeset
111 ``.section`` Directive
anatofuz
parents:
diff changeset
112 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
113
anatofuz
parents:
diff changeset
114 MC supports passing the information in ``.linkonce`` at the end of
anatofuz
parents:
diff changeset
115 ``.section``. For example, these two codes are equivalent
anatofuz
parents:
diff changeset
116
anatofuz
parents:
diff changeset
117 .. code-block:: gas
anatofuz
parents:
diff changeset
118
anatofuz
parents:
diff changeset
119 .section secName, "dr", discard, "Symbol1"
anatofuz
parents:
diff changeset
120 .globl Symbol1
anatofuz
parents:
diff changeset
121 Symbol1:
anatofuz
parents:
diff changeset
122 .long 1
anatofuz
parents:
diff changeset
123
anatofuz
parents:
diff changeset
124 .. code-block:: gas
anatofuz
parents:
diff changeset
125
anatofuz
parents:
diff changeset
126 .section secName, "dr"
anatofuz
parents:
diff changeset
127 .linkonce discard
anatofuz
parents:
diff changeset
128 .globl Symbol1
anatofuz
parents:
diff changeset
129 Symbol1:
anatofuz
parents:
diff changeset
130 .long 1
anatofuz
parents:
diff changeset
131
anatofuz
parents:
diff changeset
132 Note that in the combined form the COMDAT symbol is explicit. This
anatofuz
parents:
diff changeset
133 extension exists to support multiple sections with the same name in
anatofuz
parents:
diff changeset
134 different COMDATs:
anatofuz
parents:
diff changeset
135
anatofuz
parents:
diff changeset
136
anatofuz
parents:
diff changeset
137 .. code-block:: gas
anatofuz
parents:
diff changeset
138
anatofuz
parents:
diff changeset
139 .section secName, "dr", discard, "Symbol1"
anatofuz
parents:
diff changeset
140 .globl Symbol1
anatofuz
parents:
diff changeset
141 Symbol1:
anatofuz
parents:
diff changeset
142 .long 1
anatofuz
parents:
diff changeset
143
anatofuz
parents:
diff changeset
144 .section secName, "dr", discard, "Symbol2"
anatofuz
parents:
diff changeset
145 .globl Symbol2
anatofuz
parents:
diff changeset
146 Symbol2:
anatofuz
parents:
diff changeset
147 .long 1
anatofuz
parents:
diff changeset
148
anatofuz
parents:
diff changeset
149 In addition to the types allowed with ``.linkonce``, ``.section`` also accepts
anatofuz
parents:
diff changeset
150 ``associative``. The meaning is that the section is linked if a certain other
anatofuz
parents:
diff changeset
151 COMDAT section is linked. This other section is indicated by the comdat symbol
anatofuz
parents:
diff changeset
152 in this directive. It can be any symbol defined in the associated section, but
anatofuz
parents:
diff changeset
153 is usually the associated section's comdat.
anatofuz
parents:
diff changeset
154
anatofuz
parents:
diff changeset
155 The following restrictions apply to the associated section:
anatofuz
parents:
diff changeset
156
anatofuz
parents:
diff changeset
157 1. It must be a COMDAT section.
anatofuz
parents:
diff changeset
158 2. It cannot be another associative COMDAT section.
anatofuz
parents:
diff changeset
159
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
160 In the following example the symbol ``sym`` is the comdat symbol of ``.foo``
150
anatofuz
parents:
diff changeset
161 and ``.bar`` is associated to ``.foo``.
anatofuz
parents:
diff changeset
162
anatofuz
parents:
diff changeset
163 .. code-block:: gas
anatofuz
parents:
diff changeset
164
anatofuz
parents:
diff changeset
165 .section .foo,"bw",discard, "sym"
anatofuz
parents:
diff changeset
166 .section .bar,"rd",associative, "sym"
anatofuz
parents:
diff changeset
167
anatofuz
parents:
diff changeset
168 MC supports these flags in the COFF ``.section`` directive:
anatofuz
parents:
diff changeset
169
anatofuz
parents:
diff changeset
170 - ``b``: BSS section (``IMAGE_SCN_CNT_INITIALIZED_DATA``)
anatofuz
parents:
diff changeset
171 - ``d``: Data section (``IMAGE_SCN_CNT_UNINITIALIZED_DATA``)
anatofuz
parents:
diff changeset
172 - ``n``: Section is not loaded (``IMAGE_SCN_LNK_REMOVE``)
anatofuz
parents:
diff changeset
173 - ``r``: Read-only
anatofuz
parents:
diff changeset
174 - ``s``: Shared section
anatofuz
parents:
diff changeset
175 - ``w``: Writable
anatofuz
parents:
diff changeset
176 - ``x``: Executable section
anatofuz
parents:
diff changeset
177 - ``y``: Not readable
anatofuz
parents:
diff changeset
178 - ``D``: Discardable (``IMAGE_SCN_MEM_DISCARDABLE``)
anatofuz
parents:
diff changeset
179
anatofuz
parents:
diff changeset
180 These flags are all compatible with gas, with the exception of the ``D`` flag,
anatofuz
parents:
diff changeset
181 which gnu as does not support. For gas compatibility, sections with a name
anatofuz
parents:
diff changeset
182 starting with ".debug" are implicitly discardable.
anatofuz
parents:
diff changeset
183
anatofuz
parents:
diff changeset
184
anatofuz
parents:
diff changeset
185 ARM64/COFF-Dependent
anatofuz
parents:
diff changeset
186 --------------------
anatofuz
parents:
diff changeset
187
anatofuz
parents:
diff changeset
188 Relocations
anatofuz
parents:
diff changeset
189 ^^^^^^^^^^^
anatofuz
parents:
diff changeset
190
anatofuz
parents:
diff changeset
191 The following additional symbol variants are supported:
anatofuz
parents:
diff changeset
192
anatofuz
parents:
diff changeset
193 **:secrel_lo12:** generates a relocation that corresponds to the COFF relocation
anatofuz
parents:
diff changeset
194 types ``IMAGE_REL_ARM64_SECREL_LOW12A`` or ``IMAGE_REL_ARM64_SECREL_LOW12L``.
anatofuz
parents:
diff changeset
195
anatofuz
parents:
diff changeset
196 **:secrel_hi12:** generates a relocation that corresponds to the COFF relocation
anatofuz
parents:
diff changeset
197 type ``IMAGE_REL_ARM64_SECREL_HIGH12A``.
anatofuz
parents:
diff changeset
198
anatofuz
parents:
diff changeset
199 .. code-block:: gas
anatofuz
parents:
diff changeset
200
anatofuz
parents:
diff changeset
201 add x0, x0, :secrel_hi12:symbol
anatofuz
parents:
diff changeset
202 ldr x0, [x0, :secrel_lo12:symbol]
anatofuz
parents:
diff changeset
203
anatofuz
parents:
diff changeset
204 add x1, x1, :secrel_hi12:symbol
anatofuz
parents:
diff changeset
205 add x1, x1, :secrel_lo12:symbol
anatofuz
parents:
diff changeset
206 ...
anatofuz
parents:
diff changeset
207
anatofuz
parents:
diff changeset
208
anatofuz
parents:
diff changeset
209 ELF-Dependent
anatofuz
parents:
diff changeset
210 -------------
anatofuz
parents:
diff changeset
211
anatofuz
parents:
diff changeset
212 ``.section`` Directive
anatofuz
parents:
diff changeset
213 ^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
214
anatofuz
parents:
diff changeset
215 In order to support creating multiple sections with the same name and comdat,
anatofuz
parents:
diff changeset
216 it is possible to add an unique number at the end of the ``.section`` directive.
anatofuz
parents:
diff changeset
217 For example, the following code creates two sections named ``.text``.
anatofuz
parents:
diff changeset
218
anatofuz
parents:
diff changeset
219 .. code-block:: gas
anatofuz
parents:
diff changeset
220
anatofuz
parents:
diff changeset
221 .section .text,"ax",@progbits,unique,1
anatofuz
parents:
diff changeset
222 nop
anatofuz
parents:
diff changeset
223
anatofuz
parents:
diff changeset
224 .section .text,"ax",@progbits,unique,2
anatofuz
parents:
diff changeset
225 nop
anatofuz
parents:
diff changeset
226
anatofuz
parents:
diff changeset
227
anatofuz
parents:
diff changeset
228 The unique number is not present in the resulting object at all. It is just used
anatofuz
parents:
diff changeset
229 in the assembler to differentiate the sections.
anatofuz
parents:
diff changeset
230
anatofuz
parents:
diff changeset
231 The 'o' flag is mapped to SHF_LINK_ORDER. If it is present, a symbol
anatofuz
parents:
diff changeset
232 must be given that identifies the section to be placed is the
anatofuz
parents:
diff changeset
233 .sh_link.
anatofuz
parents:
diff changeset
234
anatofuz
parents:
diff changeset
235 .. code-block:: gas
anatofuz
parents:
diff changeset
236
anatofuz
parents:
diff changeset
237 .section .foo,"a",@progbits
anatofuz
parents:
diff changeset
238 .Ltmp:
anatofuz
parents:
diff changeset
239 .section .bar,"ao",@progbits,.Ltmp
anatofuz
parents:
diff changeset
240
anatofuz
parents:
diff changeset
241 which is equivalent to just
anatofuz
parents:
diff changeset
242
anatofuz
parents:
diff changeset
243 .. code-block:: gas
anatofuz
parents:
diff changeset
244
anatofuz
parents:
diff changeset
245 .section .foo,"a",@progbits
anatofuz
parents:
diff changeset
246 .section .bar,"ao",@progbits,.foo
anatofuz
parents:
diff changeset
247
anatofuz
parents:
diff changeset
248 ``.linker-options`` Section (linker options)
anatofuz
parents:
diff changeset
249 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
250
anatofuz
parents:
diff changeset
251 In order to support passing linker options from the frontend to the linker, a
anatofuz
parents:
diff changeset
252 special section of type ``SHT_LLVM_LINKER_OPTIONS`` (usually named
anatofuz
parents:
diff changeset
253 ``.linker-options`` though the name is not significant as it is identified by
anatofuz
parents:
diff changeset
254 the type). The contents of this section is a simple pair-wise encoding of
anatofuz
parents:
diff changeset
255 directives for consideration by the linker. The strings are encoded as standard
anatofuz
parents:
diff changeset
256 null-terminated UTF-8 strings. They are emitted inline to avoid having the
anatofuz
parents:
diff changeset
257 linker traverse the object file for retrieving the value. The linker is
anatofuz
parents:
diff changeset
258 permitted to not honour the option and instead provide a warning/error to the
anatofuz
parents:
diff changeset
259 user that the requested option was not honoured.
anatofuz
parents:
diff changeset
260
anatofuz
parents:
diff changeset
261 The section has type ``SHT_LLVM_LINKER_OPTIONS`` and has the ``SHF_EXCLUDE``
anatofuz
parents:
diff changeset
262 flag to ensure that the section is treated as opaque by linkers which do not
anatofuz
parents:
diff changeset
263 support the feature and will not be emitted into the final linked binary.
anatofuz
parents:
diff changeset
264
anatofuz
parents:
diff changeset
265 This would be equivalent to the follow raw assembly:
anatofuz
parents:
diff changeset
266
anatofuz
parents:
diff changeset
267 .. code-block:: gas
anatofuz
parents:
diff changeset
268
anatofuz
parents:
diff changeset
269 .section ".linker-options","e",@llvm_linker_options
anatofuz
parents:
diff changeset
270 .asciz "option 1"
anatofuz
parents:
diff changeset
271 .asciz "value 1"
anatofuz
parents:
diff changeset
272 .asciz "option 2"
anatofuz
parents:
diff changeset
273 .asciz "value 2"
anatofuz
parents:
diff changeset
274
anatofuz
parents:
diff changeset
275 The following directives are specified:
anatofuz
parents:
diff changeset
276
anatofuz
parents:
diff changeset
277 - lib
anatofuz
parents:
diff changeset
278
anatofuz
parents:
diff changeset
279 The parameter identifies a library to be linked against. The library will
anatofuz
parents:
diff changeset
280 be looked up in the default and any specified library search paths
anatofuz
parents:
diff changeset
281 (specified to this point).
anatofuz
parents:
diff changeset
282
anatofuz
parents:
diff changeset
283 - libpath
anatofuz
parents:
diff changeset
284
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
285 The parameter identifies an additional library search path to be considered
150
anatofuz
parents:
diff changeset
286 when looking up libraries after the inclusion of this option.
anatofuz
parents:
diff changeset
287
anatofuz
parents:
diff changeset
288 ``SHT_LLVM_DEPENDENT_LIBRARIES`` Section (Dependent Libraries)
anatofuz
parents:
diff changeset
289 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
290
anatofuz
parents:
diff changeset
291 This section contains strings specifying libraries to be added to the link by
anatofuz
parents:
diff changeset
292 the linker.
anatofuz
parents:
diff changeset
293
anatofuz
parents:
diff changeset
294 The section should be consumed by the linker and not written to the output.
anatofuz
parents:
diff changeset
295
anatofuz
parents:
diff changeset
296 The strings are encoded as standard null-terminated UTF-8 strings.
anatofuz
parents:
diff changeset
297
anatofuz
parents:
diff changeset
298 For example:
anatofuz
parents:
diff changeset
299
anatofuz
parents:
diff changeset
300 .. code-block:: gas
anatofuz
parents:
diff changeset
301
anatofuz
parents:
diff changeset
302 .section ".deplibs","MS",@llvm_dependent_libraries,1
anatofuz
parents:
diff changeset
303 .asciz "library specifier 1"
anatofuz
parents:
diff changeset
304 .asciz "library specifier 2"
anatofuz
parents:
diff changeset
305
anatofuz
parents:
diff changeset
306 The interpretation of the library specifiers is defined by the consuming linker.
anatofuz
parents:
diff changeset
307
anatofuz
parents:
diff changeset
308 ``SHT_LLVM_CALL_GRAPH_PROFILE`` Section (Call Graph Profile)
anatofuz
parents:
diff changeset
309 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
310
anatofuz
parents:
diff changeset
311 This section is used to pass a call graph profile to the linker which can be
anatofuz
parents:
diff changeset
312 used to optimize the placement of sections. It contains a sequence of
anatofuz
parents:
diff changeset
313 (from symbol, to symbol, weight) tuples.
anatofuz
parents:
diff changeset
314
anatofuz
parents:
diff changeset
315 It shall have a type of ``SHT_LLVM_CALL_GRAPH_PROFILE`` (0x6fff4c02), shall
anatofuz
parents:
diff changeset
316 have the ``SHF_EXCLUDE`` flag set, the ``sh_link`` member shall hold the section
anatofuz
parents:
diff changeset
317 header index of the associated symbol table, and shall have a ``sh_entsize`` of
anatofuz
parents:
diff changeset
318 16. It should be named ``.llvm.call-graph-profile``.
anatofuz
parents:
diff changeset
319
anatofuz
parents:
diff changeset
320 The contents of the section shall be a sequence of ``Elf_CGProfile`` entries.
anatofuz
parents:
diff changeset
321
anatofuz
parents:
diff changeset
322 .. code-block:: c
anatofuz
parents:
diff changeset
323
anatofuz
parents:
diff changeset
324 typedef struct {
anatofuz
parents:
diff changeset
325 Elf_Word cgp_from;
anatofuz
parents:
diff changeset
326 Elf_Word cgp_to;
anatofuz
parents:
diff changeset
327 Elf_Xword cgp_weight;
anatofuz
parents:
diff changeset
328 } Elf_CGProfile;
anatofuz
parents:
diff changeset
329
anatofuz
parents:
diff changeset
330 cgp_from
anatofuz
parents:
diff changeset
331 The symbol index of the source of the edge.
anatofuz
parents:
diff changeset
332
anatofuz
parents:
diff changeset
333 cgp_to
anatofuz
parents:
diff changeset
334 The symbol index of the destination of the edge.
anatofuz
parents:
diff changeset
335
anatofuz
parents:
diff changeset
336 cgp_weight
anatofuz
parents:
diff changeset
337 The weight of the edge.
anatofuz
parents:
diff changeset
338
anatofuz
parents:
diff changeset
339 This is represented in assembly as:
anatofuz
parents:
diff changeset
340
anatofuz
parents:
diff changeset
341 .. code-block:: gas
anatofuz
parents:
diff changeset
342
anatofuz
parents:
diff changeset
343 .cg_profile from, to, 42
anatofuz
parents:
diff changeset
344
anatofuz
parents:
diff changeset
345 ``.cg_profile`` directives are processed at the end of the file. It is an error
anatofuz
parents:
diff changeset
346 if either ``from`` or ``to`` are undefined temporary symbols. If either symbol
anatofuz
parents:
diff changeset
347 is a temporary symbol, then the section symbol is used instead. If either
anatofuz
parents:
diff changeset
348 symbol is undefined, then that symbol is defined as if ``.weak symbol`` has been
anatofuz
parents:
diff changeset
349 written at the end of the file. This forces the symbol to show up in the symbol
anatofuz
parents:
diff changeset
350 table.
anatofuz
parents:
diff changeset
351
anatofuz
parents:
diff changeset
352 ``SHT_LLVM_ADDRSIG`` Section (address-significance table)
anatofuz
parents:
diff changeset
353 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
354
anatofuz
parents:
diff changeset
355 This section is used to mark symbols as address-significant, i.e. the address
anatofuz
parents:
diff changeset
356 of the symbol is used in a comparison or leaks outside the translation unit. It
anatofuz
parents:
diff changeset
357 has the same meaning as the absence of the LLVM attributes ``unnamed_addr``
anatofuz
parents:
diff changeset
358 and ``local_unnamed_addr``.
anatofuz
parents:
diff changeset
359
anatofuz
parents:
diff changeset
360 Any sections referred to by symbols that are not marked as address-significant
anatofuz
parents:
diff changeset
361 in any object file may be safely merged by a linker without breaking the
anatofuz
parents:
diff changeset
362 address uniqueness guarantee provided by the C and C++ language standards.
anatofuz
parents:
diff changeset
363
anatofuz
parents:
diff changeset
364 The contents of the section are a sequence of ULEB128-encoded integers
anatofuz
parents:
diff changeset
365 referring to the symbol table indexes of the address-significant symbols.
anatofuz
parents:
diff changeset
366
anatofuz
parents:
diff changeset
367 There are two associated assembly directives:
anatofuz
parents:
diff changeset
368
anatofuz
parents:
diff changeset
369 .. code-block:: gas
anatofuz
parents:
diff changeset
370
anatofuz
parents:
diff changeset
371 .addrsig
anatofuz
parents:
diff changeset
372
anatofuz
parents:
diff changeset
373 This instructs the assembler to emit an address-significance table. Without
anatofuz
parents:
diff changeset
374 this directive, all symbols are considered address-significant.
anatofuz
parents:
diff changeset
375
anatofuz
parents:
diff changeset
376 .. code-block:: gas
anatofuz
parents:
diff changeset
377
anatofuz
parents:
diff changeset
378 .addrsig_sym sym
anatofuz
parents:
diff changeset
379
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
380 If ``sym`` is not otherwise referenced or defined anywhere else in the file,
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
381 this directive is a no-op. Otherwise, mark ``sym`` as address-significant.
150
anatofuz
parents:
diff changeset
382
anatofuz
parents:
diff changeset
383 ``SHT_LLVM_SYMPART`` Section (symbol partition specification)
anatofuz
parents:
diff changeset
384 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
385
anatofuz
parents:
diff changeset
386 This section is used to mark symbols with the `partition`_ that they
anatofuz
parents:
diff changeset
387 belong to. An ``.llvm_sympart`` section consists of a null-terminated string
anatofuz
parents:
diff changeset
388 specifying the name of the partition followed by a relocation referring to
anatofuz
parents:
diff changeset
389 the symbol that belongs to the partition. It may be constructed as follows:
anatofuz
parents:
diff changeset
390
anatofuz
parents:
diff changeset
391 .. code-block:: gas
anatofuz
parents:
diff changeset
392
anatofuz
parents:
diff changeset
393 .section ".llvm_sympart","",@llvm_sympart
anatofuz
parents:
diff changeset
394 .asciz "libpartition.so"
anatofuz
parents:
diff changeset
395 .word symbol_in_partition
anatofuz
parents:
diff changeset
396
anatofuz
parents:
diff changeset
397 .. _partition: https://lld.llvm.org/Partitions.html
anatofuz
parents:
diff changeset
398
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
399 ``SHT_LLVM_BB_ADDR_MAP`` Section (basic block address map)
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
400 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
401 This section stores the binary address of basic blocks along with other related
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
402 metadata. This information can be used to map binary profiles (like perf
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
403 profiles) directly to machine basic blocks.
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
404 This section is emitted with ``-basic-block-sections=labels`` and will contain
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
405 a BB address map table for every function.
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
406
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
407 The ``SHT_LLVM_BB_ADDR_MAP`` type provides backward compatibility to allow
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
408 reading older versions of the BB address map generated by older compilers. Each
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
409 function entry starts with a version byte which specifies the encoding version
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
410 to use. The following versioning schemes are currently supported.
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
411
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
412 Version 1 (newest): basic block address offsets are computed relative to the end
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
413 of previous blocks.
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
414
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
415 Example:
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
416
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
417 .. code-block:: gas
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
418
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
419 .section ".llvm_bb_addr_map","",@llvm_bb_addr_map
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
420 .byte 1 # version number
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
421 .byte 0 # feature byte (reserved for future use)
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
422 .quad .Lfunc_begin0 # address of the function
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
423 .byte 2 # number of basic blocks
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
424 # BB record for BB_0
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
425 .uleb128 .Lfunc_beign0-.Lfunc_begin0 # BB_0 offset relative to function entry (always zero)
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
426 .uleb128 .LBB_END0_0-.Lfunc_begin0 # BB_0 size
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
427 .byte x # BB_0 metadata
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
428 # BB record for BB_1
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
429 .uleb128 .LBB0_1-.LBB_END0_0 # BB_1 offset relative to the end of last block (BB_0).
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
430 .uleb128 .LBB_END0_1-.LBB0_1 # BB_1 size
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
431 .byte y # BB_1 metadata
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
432
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
433 Version 0: basic block address offsets are computed relative to the function
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
434 address. This uses the unversioned ``SHT_LLVM_BB_ADDR_MAP_V0`` section type and
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
435 is semantically equivalent to using ``SHT_LLVM_BB_ADDR_MAP`` with a zero
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
436 version field.
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
437
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
438 Example:
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
439
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
440 .. code-block:: gas
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
441
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
442 .section ".llvm_bb_addr_map","",@llvm_bb_addr_map_v0
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
443 .quad .Lfunc_begin0 # address of the function
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
444 .byte 2 # number of basic blocks
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
445 # BB record for BB_0
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
446 .uleb128 .Lfunc_beign0-.Lfunc_begin0 # BB_0 offset relative to the function entry (always zero)
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
447 .uleb128 .LBB_END0_0-.Lfunc_begin0 # BB_0 size
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
448 .byte x # BB_0 metadata
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
449 # BB record for BB_1
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
450 .uleb128 .LBB0_1-.Lfunc_begin0 # BB_1 offset relative to the function entry
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
451 .uleb128 .LBB_END0_1-.LBB0_1 # BB_1 size
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
452 .byte y # BB_1 metadata
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
453
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
454 ``SHT_LLVM_OFFLOADING`` Section (offloading data)
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
455 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
456 This section stores the binary data used to perform offloading device linking
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
457 and execution, creating a fat binary. This section is emitted during compilation
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
458 of offloading languages such as OpenMP or CUDA. If the data is intended to be
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
459 used by the device linker only, it should use the ``SHF_EXCLUDE`` flag so it is
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
460 automatically stripped from the final executable or shared library.
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
461
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
462 The binary data stored in this section conforms to a custom binary format used
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
463 for storing offloading metadata. This format is effectively a string table
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
464 containing metadata accompanied by a device image.
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
465
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
466 ``SHT_LLVM_LTO`` Section (LLVM bitcode for fat LTO)
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
467 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
468 This section stores LLVM bitcode used to perform regular LTO or ThinLTO at link
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
469 time. This section is generated when the compiler enables fat LTO. This section
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
470 has the ``SHF_EXCLUDE`` flag so that it is stripped from the final executable
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
471 or shared library.
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
472
150
anatofuz
parents:
diff changeset
473 CodeView-Dependent
anatofuz
parents:
diff changeset
474 ------------------
anatofuz
parents:
diff changeset
475
anatofuz
parents:
diff changeset
476 ``.cv_file`` Directive
anatofuz
parents:
diff changeset
477 ^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
478 Syntax:
anatofuz
parents:
diff changeset
479 ``.cv_file`` *FileNumber FileName* [ *checksum* ] [ *checksumkind* ]
anatofuz
parents:
diff changeset
480
anatofuz
parents:
diff changeset
481 ``.cv_func_id`` Directive
anatofuz
parents:
diff changeset
482 ^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
483 Introduces a function ID that can be used with ``.cv_loc``.
anatofuz
parents:
diff changeset
484
anatofuz
parents:
diff changeset
485 Syntax:
anatofuz
parents:
diff changeset
486 ``.cv_func_id`` *FunctionId*
anatofuz
parents:
diff changeset
487
anatofuz
parents:
diff changeset
488 ``.cv_inline_site_id`` Directive
anatofuz
parents:
diff changeset
489 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
490 Introduces a function ID that can be used with ``.cv_loc``. Includes
anatofuz
parents:
diff changeset
491 ``inlined at`` source location information for use in the line table of the
anatofuz
parents:
diff changeset
492 caller, whether the caller is a real function or another inlined call site.
anatofuz
parents:
diff changeset
493
anatofuz
parents:
diff changeset
494 Syntax:
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
495 ``.cv_inline_site_id`` *FunctionId* ``within`` *Function* ``inlined_at`` *FileNumber Line* [ *Column* ]
150
anatofuz
parents:
diff changeset
496
anatofuz
parents:
diff changeset
497 ``.cv_loc`` Directive
anatofuz
parents:
diff changeset
498 ^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
499 The first number is a file number, must have been previously assigned with a
anatofuz
parents:
diff changeset
500 ``.file`` directive, the second number is the line number and optionally the
anatofuz
parents:
diff changeset
501 third number is a column position (zero if not specified). The remaining
anatofuz
parents:
diff changeset
502 optional items are ``.loc`` sub-directives.
anatofuz
parents:
diff changeset
503
anatofuz
parents:
diff changeset
504 Syntax:
anatofuz
parents:
diff changeset
505 ``.cv_loc`` *FunctionId FileNumber* [ *Line* ] [ *Column* ] [ *prologue_end* ] [ ``is_stmt`` *value* ]
anatofuz
parents:
diff changeset
506
anatofuz
parents:
diff changeset
507 ``.cv_linetable`` Directive
anatofuz
parents:
diff changeset
508 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
509 Syntax:
anatofuz
parents:
diff changeset
510 ``.cv_linetable`` *FunctionId* ``,`` *FunctionStart* ``,`` *FunctionEnd*
anatofuz
parents:
diff changeset
511
anatofuz
parents:
diff changeset
512 ``.cv_inline_linetable`` Directive
anatofuz
parents:
diff changeset
513 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
514 Syntax:
anatofuz
parents:
diff changeset
515 ``.cv_inline_linetable`` *PrimaryFunctionId* ``,`` *FileNumber Line FunctionStart FunctionEnd*
anatofuz
parents:
diff changeset
516
anatofuz
parents:
diff changeset
517 ``.cv_def_range`` Directive
anatofuz
parents:
diff changeset
518 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
519 The *GapStart* and *GapEnd* options may be repeated as needed.
anatofuz
parents:
diff changeset
520
anatofuz
parents:
diff changeset
521 Syntax:
anatofuz
parents:
diff changeset
522 ``.cv_def_range`` *RangeStart RangeEnd* [ *GapStart GapEnd* ] ``,`` *bytes*
anatofuz
parents:
diff changeset
523
anatofuz
parents:
diff changeset
524 ``.cv_stringtable`` Directive
anatofuz
parents:
diff changeset
525 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
526
anatofuz
parents:
diff changeset
527 ``.cv_filechecksums`` Directive
anatofuz
parents:
diff changeset
528 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
529
anatofuz
parents:
diff changeset
530 ``.cv_filechecksumoffset`` Directive
anatofuz
parents:
diff changeset
531 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
532 Syntax:
anatofuz
parents:
diff changeset
533 ``.cv_filechecksumoffset`` *FileNumber*
anatofuz
parents:
diff changeset
534
anatofuz
parents:
diff changeset
535 ``.cv_fpo_data`` Directive
anatofuz
parents:
diff changeset
536 ^^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
537 Syntax:
anatofuz
parents:
diff changeset
538 ``.cv_fpo_data`` *procsym*
anatofuz
parents:
diff changeset
539
anatofuz
parents:
diff changeset
540 Target Specific Behaviour
anatofuz
parents:
diff changeset
541 =========================
anatofuz
parents:
diff changeset
542
anatofuz
parents:
diff changeset
543 X86
anatofuz
parents:
diff changeset
544 ---
anatofuz
parents:
diff changeset
545
anatofuz
parents:
diff changeset
546 Relocations
anatofuz
parents:
diff changeset
547 ^^^^^^^^^^^
anatofuz
parents:
diff changeset
548
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
549 **@ABS8** can be applied to symbols which appear as immediate operands to
150
anatofuz
parents:
diff changeset
550 instructions that have an 8-bit immediate form for that operand. It causes
anatofuz
parents:
diff changeset
551 the assembler to use the 8-bit form and an 8-bit relocation (e.g. ``R_386_8``
anatofuz
parents:
diff changeset
552 or ``R_X86_64_8``) for the symbol.
anatofuz
parents:
diff changeset
553
anatofuz
parents:
diff changeset
554 For example:
anatofuz
parents:
diff changeset
555
anatofuz
parents:
diff changeset
556 .. code-block:: gas
anatofuz
parents:
diff changeset
557
anatofuz
parents:
diff changeset
558 cmpq $foo@ABS8, %rdi
anatofuz
parents:
diff changeset
559
anatofuz
parents:
diff changeset
560 This causes the assembler to select the form of the 64-bit ``cmpq`` instruction
anatofuz
parents:
diff changeset
561 that takes an 8-bit immediate operand that is sign extended to 64 bits, as
anatofuz
parents:
diff changeset
562 opposed to ``cmpq $foo, %rdi`` which takes a 32-bit immediate operand. This
anatofuz
parents:
diff changeset
563 is also not the same as ``cmpb $foo, %dil``, which is an 8-bit comparison.
anatofuz
parents:
diff changeset
564
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
565
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
566 **@GOTPCREL_NORELAX** can be used in place of ``@GOTPCREL`` to guarantee that
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
567 the assembler emits an ``R_X86_64_GOTPCREL`` relocation instead of a relaxable
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
568 ``R_X86_64[_REX]_GOTPCRELX`` relocation.
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
569
150
anatofuz
parents:
diff changeset
570 Windows on ARM
anatofuz
parents:
diff changeset
571 --------------
anatofuz
parents:
diff changeset
572
anatofuz
parents:
diff changeset
573 Stack Probe Emission
anatofuz
parents:
diff changeset
574 ^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
575
anatofuz
parents:
diff changeset
576 The reference implementation (Microsoft Visual Studio 2012) emits stack probes
anatofuz
parents:
diff changeset
577 in the following fashion:
anatofuz
parents:
diff changeset
578
anatofuz
parents:
diff changeset
579 .. code-block:: gas
anatofuz
parents:
diff changeset
580
anatofuz
parents:
diff changeset
581 movw r4, #constant
anatofuz
parents:
diff changeset
582 bl __chkstk
anatofuz
parents:
diff changeset
583 sub.w sp, sp, r4
anatofuz
parents:
diff changeset
584
anatofuz
parents:
diff changeset
585 However, this has the limitation of 32 MiB (±16MiB). In order to accommodate
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
586 larger binaries, LLVM supports the use of ``-mcmodel=large`` to allow a 4GiB
150
anatofuz
parents:
diff changeset
587 range via a slight deviation. It will generate an indirect jump as follows:
anatofuz
parents:
diff changeset
588
anatofuz
parents:
diff changeset
589 .. code-block:: gas
anatofuz
parents:
diff changeset
590
anatofuz
parents:
diff changeset
591 movw r4, #constant
anatofuz
parents:
diff changeset
592 movw r12, :lower16:__chkstk
anatofuz
parents:
diff changeset
593 movt r12, :upper16:__chkstk
anatofuz
parents:
diff changeset
594 blx r12
anatofuz
parents:
diff changeset
595 sub.w sp, sp, r4
anatofuz
parents:
diff changeset
596
anatofuz
parents:
diff changeset
597 Variable Length Arrays
anatofuz
parents:
diff changeset
598 ^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
599
anatofuz
parents:
diff changeset
600 The reference implementation (Microsoft Visual Studio 2012) does not permit the
anatofuz
parents:
diff changeset
601 emission of Variable Length Arrays (VLAs).
anatofuz
parents:
diff changeset
602
anatofuz
parents:
diff changeset
603 The Windows ARM Itanium ABI extends the base ABI by adding support for emitting
anatofuz
parents:
diff changeset
604 a dynamic stack allocation. When emitting a variable stack allocation, a call
anatofuz
parents:
diff changeset
605 to ``__chkstk`` is emitted unconditionally to ensure that guard pages are setup
anatofuz
parents:
diff changeset
606 properly. The emission of this stack probe emission is handled similar to the
anatofuz
parents:
diff changeset
607 standard stack probe emission.
anatofuz
parents:
diff changeset
608
anatofuz
parents:
diff changeset
609 The MSVC environment does not emit code for VLAs currently.
anatofuz
parents:
diff changeset
610
anatofuz
parents:
diff changeset
611 Windows on ARM64
anatofuz
parents:
diff changeset
612 ----------------
anatofuz
parents:
diff changeset
613
anatofuz
parents:
diff changeset
614 Stack Probe Emission
anatofuz
parents:
diff changeset
615 ^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
616
anatofuz
parents:
diff changeset
617 The reference implementation (Microsoft Visual Studio 2017) emits stack probes
anatofuz
parents:
diff changeset
618 in the following fashion:
anatofuz
parents:
diff changeset
619
anatofuz
parents:
diff changeset
620 .. code-block:: gas
anatofuz
parents:
diff changeset
621
anatofuz
parents:
diff changeset
622 mov x15, #constant
anatofuz
parents:
diff changeset
623 bl __chkstk
anatofuz
parents:
diff changeset
624 sub sp, sp, x15, lsl #4
anatofuz
parents:
diff changeset
625
anatofuz
parents:
diff changeset
626 However, this has the limitation of 256 MiB (±128MiB). In order to accommodate
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
627 larger binaries, LLVM supports the use of ``-mcmodel=large`` to allow a 8GiB
150
anatofuz
parents:
diff changeset
628 (±4GiB) range via a slight deviation. It will generate an indirect jump as
anatofuz
parents:
diff changeset
629 follows:
anatofuz
parents:
diff changeset
630
anatofuz
parents:
diff changeset
631 .. code-block:: gas
anatofuz
parents:
diff changeset
632
anatofuz
parents:
diff changeset
633 mov x15, #constant
anatofuz
parents:
diff changeset
634 adrp x16, __chkstk
anatofuz
parents:
diff changeset
635 add x16, x16, :lo12:__chkstk
anatofuz
parents:
diff changeset
636 blr x16
anatofuz
parents:
diff changeset
637 sub sp, sp, x15, lsl #4
anatofuz
parents:
diff changeset
638