summaryrefslogtreecommitdiffstats
path: root/docs/LanguageExtensions.rst
diff options
context:
space:
mode:
authorJaved Absar <javed.absar@arm.com>2017-06-05 10:11:57 +0000
committerJaved Absar <javed.absar@arm.com>2017-06-05 10:11:57 +0000
commit7c78710146c10e25cd149914210013905d70d6d6 (patch)
tree68099d75a27c12fbc744658ed441e2e8abf1c591 /docs/LanguageExtensions.rst
parent6235d9b1ad493fbbd905e46b2b6afab52eeeb2cb (diff)
Add support for #pragma clang section
This patch provides a means to specify section-names for global variables, functions and static variables, using #pragma directives. This feature is only defined to work sensibly for ELF targets. One can specify section names as: #pragma clang section bss="myBSS" data="myData" rodata="myRodata" text="myText" One can "unspecify" a section name with empty string e.g. #pragma clang section bss="" data="" text="" rodata="" Reviewers: Roger Ferrer, Jonathan Roelofs, Reid Kleckner Differential Revision: https://reviews.llvm.org/D33412 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304705 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/LanguageExtensions.rst')
-rw-r--r--docs/LanguageExtensions.rst42
1 files changed, 42 insertions, 0 deletions
diff --git a/docs/LanguageExtensions.rst b/docs/LanguageExtensions.rst
index f8dd1a39c6..dab538f3a9 100644
--- a/docs/LanguageExtensions.rst
+++ b/docs/LanguageExtensions.rst
@@ -2521,3 +2521,45 @@ whether or not an attribute is supported by the pragma by referring to the
The attributes are applied to all matching declarations individually, even when
the attribute is semantically incorrect. The attributes that aren't applied to
any declaration are not verified semantically.
+
+Specifying section names for global objects (#pragma clang section)
+===================================================================
+
+The ``#pragma clang section`` directive provides a means to assign section-names
+to global variables, functions and static variables.
+
+The section names can be specified as:
+
+.. code-block:: c++
+
+ #pragma clang section bss="myBSS" data="myData" rodata="myRodata" text="myText"
+
+The section names can be reverted back to default name by supplying an empty
+string to the section kind, for example:
+
+.. code-block:: c++
+
+ #pragma clang section bss="" data="" text="" rodata=""
+
+The ``#pragma clang section`` directive obeys the following rules:
+
+* The pragma applies to all global variable, statics and function declarations
+ from the pragma to the end of the translation unit.
+
+* The pragma clang section is enabled automatically, without need of any flags.
+
+* This feature is only defined to work sensibly for ELF targets.
+
+* If section name is specified through _attribute_((section("myname"))), then
+ the attribute name gains precedence.
+
+* Global variables that are initialized to zero will be placed in the named
+ bss section, if one is present.
+
+* The ``#pragma clang section`` directive does not does try to infer section-kind
+ from the name. For example, naming a section "``.bss.mySec``" does NOT mean
+ it will be a bss section name.
+
+* The decision about which section-kind applies to each global is taken in the back-end.
+ Once the section-kind is known, appropriate section name, as specified by the user using
+ ``#pragma clang section`` directive, is applied to that global.