[llvm-dev] [cfe-dev] proposal - pragma section directive in clang

Jonathan Roelofs via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 13 11:12:57 PDT 2017



On 3/10/17 2:47 AM, James Molloy via llvm-dev wrote:
> +llvm-dev properly this time.
>
> On Fri, 10 Mar 2017 at 09:42 James Molloy <james at jamesmolloy.co.uk
> <mailto:james at jamesmolloy.co.uk>> wrote:
>

>
>     The documentation is here:
>     http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0472m/chr1359124985290.html
>
>     ** Proposed syntax and (vague) semantics **
>
>     As this is a new pragma for Clang and isn't ARM-specific, we've
>     invented a less ARM-specific syntax. Bikeshedding is expected and
>     welcome.
>
>       #pragma clang section bss(".mybss") rodata(".myrodata")
>     data(".mydata") text(".mytext")

There's some prior art in the GreenHills compiler too, where the example 
above would be spelled:

     #pragma ghs section bss=".mybss", rodata=".myrodata", 
data=".mydata", text=".mytext"

Maybe it's worth using that syntax, i.e:

     #pragma clang section bss=".mybss", rodata=".myrodata", 
data=".mydata", text=".mytext"

Alternatively, supporting vendor-specific spellings might be useful, if 
there's a consistency argument to be made for clang doing it its own way.

Docs are pages 108/109 here:
http://www.ece.ualberta.ca/~cmpe490/documents/ghs/build_arm.pdf


Jon

>
>     The pragma applies to all global variable and function declarations
>     from the pragma to the end of the translation unit. The pragma
>     should ideally be pushable and poppable, but that is outside the
>     scope of this RFC. The pragma also applies to static local
>     declarations within functions.
>
>     All global variables and functions affected by this pragma have
>     their default ELF section destinations changed. Globals with
>     __attribute__((section())) are not affected (the attribute trumps
>     the pragma).
>
>     This pragma is only defined to work sensibly for ELF targets.
>


-- 
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded


More information about the llvm-dev mailing list