This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Suggestion for function attributes on x86 architecture


> > > __attributte__((naked)) :  indicate that the specified function do not need
> > > prologue/epilogue sequences generated by the compiler.
> > 
> > This is an ill-conceived idea that I have resisted every time
> > it comes up.  If you want this level of control, write in 
> > assembly language to begin with.
> 
> Why? This is possible for ARM architecture, why not for x86??
> Instead using complicated assembler like the below, it's  more clear
> to use c syntax:
> 
> asm(".text\n"
>     ".globl _MyFunc\n"
>     "_MyFunc:\n"
>     "ret\n");
> 
> ^ This is really ill.
> 
> Instead using 
> 
> void __naked MyFunc() {
> }
> 

I agree with Richard: It's an abomination.  It means that you can write 
things like

extern int x, y;

void __naked set_x()
{
  x = y;
}

and the compiler might, or might not, generate correct code.  There's just 
no way to tell what will work and what won't.  It can even change with 
compilation options.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]