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: return statement in a function with the naked attribute


2013/5/3 reed kotler <rkotler@mips.com>:
> Should a return statement be emitted in a function that has the naked
> attribute.
>
> There seems to be some confusion here and apparently disagreement between
> various
> gcc compilers.
>

IMHO, it depends on how you define the word 'naked' for a function
and how you expect one writing functions with 'naked' attribute.

If you think one is supposed to have *complete* control in the function
(i.e. only inline assembly code, without using any C statement and variables),
then the asm 'ret' can be omitted.  Porgrammers must explicitly
emit 'ret' in the inline asm.

If you allow user using C statement in the function with 'naked' attribute,
the asm 'ret' is still required.  Because compiler may produce a branch
to the epilogue position where 'ret' is expected to exist.

AFAIK, there is no standard defining what 'naked' behavior should be.
So gcc leaves it to back-end developers.


Best regards,
jasonwucj


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