This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Suggestion for function attributes on x86 architecture
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: "Ben. K." <bkausbk at web dot de>
- Cc: "Richard Henderson" <rth at redhat dot com>, gcc at gcc dot gnu dot org, Richard dot Earnshaw at arm dot com
- Date: Wed, 17 Apr 2002 18:14:57 +0100
- Subject: Re: Suggestion for function attributes on x86 architecture
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
> > > __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.