2.6. Pragmas¶
The following pragmas are supported by the tiarmclang compiler:
2.6.1. clang section text¶
The clang section text pragma will place enclosed functions within a named section, which can then be placed with the linker using a linker command file.
Syntax
#pragma clang section text=”scn_name”
The setting is reset to the default section name using
#pragma clang section text=”“
Example
The following use of the clang section text pragma will cause the enclosed function to be included in a section called .text.functions
#include <stdio.h>
#pragma clang section text=".text.functions"
int main() {
emit_msg();
emit_msg();
emit_msg();
}
#pragma clang section text=""
2.6.2. clang section data¶
The clang section data pragma will place enclosed variables within a named section, which can then be placed with the linker using a linker command file.
Syntax
#pragma clang section data=”scn_name”
The setting is reset to the default section name using
#pragma clang section data=”“
Example
The following use of the clang section data pragma will cause the enclosed variables to be included in a section called .data.variables
#include <stdio.h>
#pragma clang section data=".data.variables"
int var1 = 39;
char *myString = "this is a test";
#pragma clang section data=""
extern void func(int, char*);
int main() {
func(var1, myString);
}