使用"裸QUOT;属性在GCC的功能 [英] Using the "naked" attribute for functions in GCC

查看:141
本文介绍了使用"裸QUOT;属性在GCC的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

6.30声明函数的属性的:

使用ARM的这一属性,AVR,IP2K,RX和SPU端口来表明指定的函数不需要由编译器生成的序言/结尾序列。它是由程序员来提供这些序列。可以安全地包含在裸函数的唯一语句是没有操作数 ASM 语句。所有其他的陈述,包括局部变量的声明,如果语句等等,应尽量避免。赤裸裸的功能应该被用于实现汇编函数的身体,同时让编译器来构造汇编必要的函数声明。

Use this attribute on the ARM, AVR, IP2K, RX and SPU ports to indicate that the specified function does not need prologue/epilogue sequences generated by the compiler. It is up to the programmer to provide these sequences. The only statements that can be safely included in naked functions are asm statements that do not have operands. All other statements, including declarations of local variables, if statements, and so forth, should be avoided. Naked functions should be used to implement the body of an assembly function, while allowing the compiler to construct the requisite function declaration for the assembler.

我可以安全地,或只能通过ASM调用使用C语法,从赤裸的函数的功能呢?

Can I safely call functions using C syntax from naked functions, or only by using asm?

推荐答案

如果您在赤裸裸的功能做的唯一事情是调用另一个函数,你可以只使用一个单一的JMP机code指令。

If the only thing you do in the naked function is call another function you can just use a single JMP machine code instruction.

您跳转到该函数将有一个有效的序幕,它应该直接返回赤裸裸的函数的调用者,因为JMP不会在堆栈上推回邮地址。

The function you jump to will have a valid prologue and it should return directly to the caller of the naked function since JMP doesn't push a return address on the stack.

这篇关于使用"裸QUOT;属性在GCC的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆