Reapply r188119 now that the bug it exposed is fixed.
[oota-llvm.git] / docs / Extensions.rst
1 ===============
2 LLVM Extensions
3 ===============
4
5 .. contents::
6    :local:
7
8 .. toctree::
9    :hidden:
10
11 Introduction
12 ============
13
14 This document describes extensions to tools and formats LLVM seeks compatibility
15 with.
16
17 Machine-specific Assembly Syntax
18 ================================
19
20 X86/COFF-Dependent
21 ------------------
22
23 Relocations
24 ^^^^^^^^^^^
25
26 The following additional relocation type is supported:
27
28 **@IMGREL** (AT&T syntax only) generates an image-relative relocation that
29 corresponds to the COFF relocation types ``IMAGE_REL_I386_DIR32NB`` (32-bit) or
30 ``IMAGE_REL_AMD64_ADDR32NB`` (64-bit).
31
32 .. code-block:: gas
33
34   .text
35   fun:
36     mov foo@IMGREL(%ebx, %ecx, 4), %eax
37
38   .section .pdata
39     .long fun@IMGREL
40     .long (fun@imgrel + 0x3F)
41     .long $unwind$fun@imgrel
42
43
44 ``.linkonce`` Directive
45 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46
47 Syntax:
48
49    ``.linkonce [ comdat type [ section identifier ] ]``
50
51 Supported COMDAT types:
52
53 ``discard``
54    Discards duplicate sections with the same COMDAT symbol. This is the default
55    if no type is specified.
56
57 ``one_only``
58    If the symbol is defined multiple times, the linker issues an error.
59
60 ``same_size``
61    Duplicates are discarded, but the linker issues an error if any have
62    different sizes.
63
64 ``same_contents``
65    Duplicates are discarded, but the linker issues an error if any duplicates
66    do not have exactly the same content.
67
68 ``associative``
69    Links the section if a certain other COMDAT section is linked. This other
70    section is indicated by its section identifier following the comdat type.
71    The following restrictions apply to the associated section:
72
73    1. It must be the name of a section already defined.
74    2. It must differ from the current section.
75    3. It must be a COMDAT section.
76    4. It cannot be another associative COMDAT section.
77
78 ``largest``
79    Links the largest section from among the duplicates.
80
81 ``newest``
82    Links the newest section from among the duplicates.
83
84
85 .. code-block:: gas
86
87   .section .text$foo
88   .linkonce
89     ...
90
91   .section .xdata$foo
92   .linkonce associative .text$foo
93     ...