http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41045

Steven Fuerst <svfuerst at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |svfuerst at gmail dot com

--- Comment #9 from Steven Fuerst <svfuerst at gmail dot com> 2012-06-10 
19:32:05 UTC ---
For those interested, it appears that you can use a @nobits segment for
variables using the gcc attribute syntax:

__attribute__ ((section(".sbss,\"awT\",@nobits #"))) int variable;

will emit:

.section    .sbss,"awT",@nobits #,"awT",@progbits

in assembly.  The '#' comment character will get rid of the pesky @progbits
setting, leaving the @nobits option set.

Since the section name is included verbatim in the output, you can do even
bigger hacks by using embedded carriage returns in the section name string. 
This allows arbitrary asm to be inserted at top level.  You don't have access
to anything but compile-time string constants though, which makes usage a
little annoying.

static __attribute__((used)) __attribute__ ((section(".text\n\t"
        ".globl a_function\n"
        "a_function:\n\t"
        "mov %al, %ah\n\t"
        "ret\n\t"
        "# "))) char variable;

Of course... since this is not exactly the intent of the (section()) attribute,
tricks like this may break at any time.

Reply via email to