2013-04-10 23:28:17 +00:00
|
|
|
===============
|
|
|
|
LLVM Extensions
|
|
|
|
===============
|
|
|
|
|
|
|
|
.. contents::
|
|
|
|
:local:
|
|
|
|
|
|
|
|
.. toctree::
|
|
|
|
:hidden:
|
|
|
|
|
|
|
|
Introduction
|
|
|
|
============
|
|
|
|
|
|
|
|
This document describes extensions to tools and formats LLVM seeks compatibility
|
|
|
|
with.
|
|
|
|
|
2013-08-14 15:27:20 +00:00
|
|
|
General Assembly Syntax
|
|
|
|
===========================
|
|
|
|
|
|
|
|
C99-style Hexadecimal Floating-point Constants
|
|
|
|
----------------------------------------------
|
|
|
|
|
|
|
|
LLVM's assemblers allow floating-point constants to be written in C99's
|
|
|
|
hexadecimal format instead of decimal if desired.
|
|
|
|
|
|
|
|
.. code-block:: gas
|
2013-08-14 16:18:47 +00:00
|
|
|
|
2013-08-14 15:27:20 +00:00
|
|
|
.section .data
|
|
|
|
.float 0x1c2.2ap3
|
|
|
|
|
2013-04-10 23:28:17 +00:00
|
|
|
Machine-specific Assembly Syntax
|
|
|
|
================================
|
|
|
|
|
|
|
|
X86/COFF-Dependent
|
|
|
|
------------------
|
|
|
|
|
2013-07-06 12:13:10 +00:00
|
|
|
Relocations
|
|
|
|
^^^^^^^^^^^
|
|
|
|
|
2013-12-20 18:15:00 +00:00
|
|
|
The following additional relocation types are supported:
|
2013-04-10 23:28:17 +00:00
|
|
|
|
|
|
|
**@IMGREL** (AT&T syntax only) generates an image-relative relocation that
|
|
|
|
corresponds to the COFF relocation types ``IMAGE_REL_I386_DIR32NB`` (32-bit) or
|
|
|
|
``IMAGE_REL_AMD64_ADDR32NB`` (64-bit).
|
|
|
|
|
|
|
|
.. code-block:: gas
|
|
|
|
|
|
|
|
.text
|
|
|
|
fun:
|
|
|
|
mov foo@IMGREL(%ebx, %ecx, 4), %eax
|
|
|
|
|
|
|
|
.section .pdata
|
|
|
|
.long fun@IMGREL
|
|
|
|
.long (fun@imgrel + 0x3F)
|
|
|
|
.long $unwind$fun@imgrel
|
2013-07-06 12:13:10 +00:00
|
|
|
|
2013-12-20 18:15:00 +00:00
|
|
|
**.secrel32** generates a relocation that corresponds to the COFF relocation
|
|
|
|
types ``IMAGE_REL_I386_SECREL`` (32-bit) or ``IMAGE_REL_AMD64_SECREL`` (64-bit).
|
|
|
|
|
|
|
|
**.secidx** relocation generates an index of the section that contains
|
|
|
|
the target. It corresponds to the COFF relocation types
|
|
|
|
``IMAGE_REL_I386_SECTION`` (32-bit) or ``IMAGE_REL_AMD64_SECTION`` (64-bit).
|
|
|
|
|
|
|
|
.. code-block:: gas
|
|
|
|
|
|
|
|
.section .debug$S,"rn"
|
|
|
|
.long 4
|
|
|
|
.long 242
|
|
|
|
.long 40
|
|
|
|
.secrel32 _function_name
|
|
|
|
.secidx _function_name
|
|
|
|
...
|
2013-07-06 12:13:10 +00:00
|
|
|
|
|
|
|
``.linkonce`` Directive
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
Syntax:
|
|
|
|
|
|
|
|
``.linkonce [ comdat type [ section identifier ] ]``
|
|
|
|
|
|
|
|
Supported COMDAT types:
|
|
|
|
|
|
|
|
``discard``
|
|
|
|
Discards duplicate sections with the same COMDAT symbol. This is the default
|
|
|
|
if no type is specified.
|
|
|
|
|
|
|
|
``one_only``
|
|
|
|
If the symbol is defined multiple times, the linker issues an error.
|
|
|
|
|
|
|
|
``same_size``
|
|
|
|
Duplicates are discarded, but the linker issues an error if any have
|
|
|
|
different sizes.
|
|
|
|
|
|
|
|
``same_contents``
|
|
|
|
Duplicates are discarded, but the linker issues an error if any duplicates
|
|
|
|
do not have exactly the same content.
|
|
|
|
|
|
|
|
``associative``
|
|
|
|
Links the section if a certain other COMDAT section is linked. This other
|
|
|
|
section is indicated by its section identifier following the comdat type.
|
|
|
|
The following restrictions apply to the associated section:
|
|
|
|
|
|
|
|
1. It must be the name of a section already defined.
|
|
|
|
2. It must differ from the current section.
|
|
|
|
3. It must be a COMDAT section.
|
|
|
|
4. It cannot be another associative COMDAT section.
|
|
|
|
|
|
|
|
``largest``
|
|
|
|
Links the largest section from among the duplicates.
|
|
|
|
|
|
|
|
``newest``
|
|
|
|
Links the newest section from among the duplicates.
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: gas
|
|
|
|
|
|
|
|
.section .text$foo
|
|
|
|
.linkonce
|
|
|
|
...
|
|
|
|
|
|
|
|
.section .xdata$foo
|
|
|
|
.linkonce associative .text$foo
|
|
|
|
...
|
2013-11-19 19:52:52 +00:00
|
|
|
|
|
|
|
``.section`` Directive
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
MC supports passing the information in ``.linkonce`` at the end of
|
|
|
|
``.section``. For example, these two codes are equivalent
|
|
|
|
|
|
|
|
.. code-block:: gas
|
|
|
|
|
|
|
|
.section secName, "dr", discard, "Symbol1"
|
|
|
|
.globl Symbol1
|
|
|
|
Symbol1:
|
|
|
|
.long 1
|
|
|
|
|
|
|
|
.. code-block:: gas
|
|
|
|
|
|
|
|
.section secName, "dr"
|
|
|
|
.linkonce discard
|
|
|
|
.globl Symbol1
|
|
|
|
Symbol1:
|
|
|
|
.long 1
|
|
|
|
|
2013-12-20 10:32:12 +00:00
|
|
|
Note that in the combined form the COMDAT symbol is explicit. This
|
2013-11-19 19:52:52 +00:00
|
|
|
extension exits to support multiple sections with the same name in
|
|
|
|
different comdats:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: gas
|
|
|
|
|
|
|
|
.section secName, "dr", discard, "Symbol1"
|
|
|
|
.globl Symbol1
|
|
|
|
Symbol1:
|
|
|
|
.long 1
|
|
|
|
|
|
|
|
.section secName, "dr", discard, "Symbol2"
|
|
|
|
.globl Symbol2
|
|
|
|
Symbol2:
|
|
|
|
.long 1
|