Forcing inline assembly code to be produced

Kristis Makris kristis.makris@asu.edu
Tue Apr 24 18:40:00 GMT 2007


>  > 
>  > if (something) {
>  > /* body /*
>  > }
>  > 
>  > ...I want to place the body, which is written in C, in the 'bar'
>  > section.
> 
> So why not put the body in another function if you want to do that?
> gcc reorders basic blocks, and so there's no guarantee that your
> section changes are going to come out in any order with respect to the
> code.

Because the body may contain a return statement, or a group of goto
statements to other parts of the function. Grouping the body in another
function won't permit returning from the original function, or
continuing execution from somewhere else in the original function.

It seems to me that a more granular way of using the __attribute__
((section ("bar"))) is needed. Something that defines a section at a
scope level. e.g.

if (something) 
__attribute__ ((section ("bar"))) {
/* body */
}





More information about the Gcc-help mailing list