proposal - pragma section directive in clang

Hi all:

We would like to propose a clang pragma directive to allow specialized section names.
The semantics of it could be as follows. The pragma section name is declared in global
scope. All global variables and functions get assigned to the corresponding specialized
section name if one is present. With this feature, the following code:

// foo.c
#pragma bss_section(“.bss.alpha”)
#pragma data_section(“.data.beta”)
#pragma code_section(“.code.gamma”)
#pragma const_section(“”)
int a;
int b=2;
const int d = 5;
int c(){
return d;

…will emit llvm-ir as:

target triple = “armv7-arm-none-eabi”
@a = global i32 0, section “.bss.alpha”, align 4
@b = global i32 2, section “.data.beta”, align 4
@d = constant i32 5, section “”, align 4

; Function Attrs: noinline nounwind
define i32 @c() #0 section “.code.gamma” {
ret i32 5

This pragma will be very useful for embedded code which
need to control where the different sections are placed in memory.

Microsoft -fms-extension provides similar feature, but our proposal is for a
general use. Attributes are an alternative that is also currently available,
but attributes are applicable only to specific declarations and not entire
file. Many real embedded users prefer the pragma option.
This will be a welcome enabler for them. Also, AUTOSAR, which is an

automotive standard mandates use of a #pragma solution over an attribute one

Looking forward to comments and suggestions.
Best Regards