blob: 9f33d30ac7b5b607baa3713670c7404a0fce6181 [file] [log] [blame]
Nico Rieck1da45292013-04-10 23:28:17 +00001===============
2LLVM Extensions
3===============
4
5.. contents::
6 :local:
Nico Rieck1da45292013-04-10 23:28:17 +00007
8.. toctree::
9 :hidden:
10
11Introduction
12============
13
14This document describes extensions to tools and formats LLVM seeks compatibility
15with.
16
Tim Northover09376792013-08-14 15:27:20 +000017General Assembly Syntax
18===========================
19
20C99-style Hexadecimal Floating-point Constants
21----------------------------------------------
22
23LLVM's assemblers allow floating-point constants to be written in C99's
24hexadecimal format instead of decimal if desired.
25
26.. code-block:: gas
Benjamin Kramer24ab6b32013-08-14 16:18:47 +000027
Tim Northover09376792013-08-14 15:27:20 +000028 .section .data
29 .float 0x1c2.2ap3
30
Nico Rieck1da45292013-04-10 23:28:17 +000031Machine-specific Assembly Syntax
32================================
33
34X86/COFF-Dependent
35------------------
36
Nico Riecka37acf72013-07-06 12:13:10 +000037Relocations
38^^^^^^^^^^^
39
Nico Rieck1da45292013-04-10 23:28:17 +000040The following additional relocation type is supported:
41
42**@IMGREL** (AT&T syntax only) generates an image-relative relocation that
43corresponds to the COFF relocation types ``IMAGE_REL_I386_DIR32NB`` (32-bit) or
44``IMAGE_REL_AMD64_ADDR32NB`` (64-bit).
45
46.. code-block:: gas
47
48 .text
49 fun:
50 mov foo@IMGREL(%ebx, %ecx, 4), %eax
51
52 .section .pdata
53 .long fun@IMGREL
54 .long (fun@imgrel + 0x3F)
55 .long $unwind$fun@imgrel
Nico Riecka37acf72013-07-06 12:13:10 +000056
57
58``.linkonce`` Directive
59^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60
61Syntax:
62
63 ``.linkonce [ comdat type [ section identifier ] ]``
64
65Supported COMDAT types:
66
67``discard``
68 Discards duplicate sections with the same COMDAT symbol. This is the default
69 if no type is specified.
70
71``one_only``
72 If the symbol is defined multiple times, the linker issues an error.
73
74``same_size``
75 Duplicates are discarded, but the linker issues an error if any have
76 different sizes.
77
78``same_contents``
79 Duplicates are discarded, but the linker issues an error if any duplicates
80 do not have exactly the same content.
81
82``associative``
83 Links the section if a certain other COMDAT section is linked. This other
84 section is indicated by its section identifier following the comdat type.
85 The following restrictions apply to the associated section:
86
87 1. It must be the name of a section already defined.
88 2. It must differ from the current section.
89 3. It must be a COMDAT section.
90 4. It cannot be another associative COMDAT section.
91
92``largest``
93 Links the largest section from among the duplicates.
94
95``newest``
96 Links the newest section from among the duplicates.
97
98
99.. code-block:: gas
100
101 .section .text$foo
102 .linkonce
103 ...
104
105 .section .xdata$foo
106 .linkonce associative .text$foo
107 ...
Rafael Espindola60ec3832013-11-19 19:52:52 +0000108
109``.section`` Directive
110^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
111
112MC supports passing the information in ``.linkonce`` at the end of
113``.section``. For example, these two codes are equivalent
114
115.. code-block:: gas
116
117 .section secName, "dr", discard, "Symbol1"
118 .globl Symbol1
119 Symbol1:
120 .long 1
121
122.. code-block:: gas
123
124 .section secName, "dr"
125 .linkonce discard
126 .globl Symbol1
127 Symbol1:
128 .long 1
129
Timur Iskhodzhanov18f666b2013-12-20 10:32:12 +0000130Note that in the combined form the COMDAT symbol is explicit. This
Rafael Espindola60ec3832013-11-19 19:52:52 +0000131extension exits to support multiple sections with the same name in
132different comdats:
133
134
135.. code-block:: gas
136
137 .section secName, "dr", discard, "Symbol1"
138 .globl Symbol1
139 Symbol1:
140 .long 1
141
142 .section secName, "dr", discard, "Symbol2"
143 .globl Symbol2
144 Symbol2:
145 .long 1