2013/5/3 reed kotler <rkot...@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

Reply via email to