为什么gcc不支持裸函数? [英] Why doesn't gcc support naked functions?

查看:189
本文介绍了为什么gcc不支持裸函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用裸功能在程序运行时修补程序的某些部分.我可以在Windows的VC ++中轻松地做到这一点.我正在尝试在Linux中执行此操作,而gcc似乎不支持裸函数.使用裸函数编译代码可以给我以下信息:警告:"naked"属性指令已被忽略.在CentOS 5.5 i386下编译.

I use naked functions to patch parts of a program while it's running. I can easily do this in VC++ in Windows. I'm trying to do this in Linux and it seems gcc doesn't support naked functions. Compiling code with naked functions gives me this: warning: ‘naked’ attribute directive ignored. Compiled under CentOS 5.5 i386.

推荐答案

根据

naked : 在ARM,AVR,MCORE,RX和SPU端口上使用此属性可以 指示指定的功能不需要序言/结尾 编译器生成的序列.由程序员决定 提供这些序列.唯一可以安全地声明的语句 裸函数中包含的asm语句没有 操作数.所有其他声明,包括本地声明 应避免使用变量,if语句等.裸 应该使用函数来实现程序集的主体 函数,同时允许编译器构造必要的 汇编器的函数声明.

naked: Use this attribute on the ARM, AVR, MCORE, 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.

我不确定为什么.

这篇关于为什么gcc不支持裸函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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