This is the mail archive of the gcc-help@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: __declspec(naked) and function body size



Hi,


Thank you for your reply!

Is it possible to get the size of a function, i.e the number of bytes generated by the compiler between the prologue and the final routine's ret instruction, so that it would be available through a 'sizeof' like operator for the other code?

It would be possible to do,

int a = sizeof(some_function);

I'm not expecting the standard sizeof to do that, but I'm looking for possibly another operator or some proprietary GCC extensions. I'm writing a JIT for my simplified C language and I'd like to copy template code around and patch it when necessary (and not only emitting opcode by opcode in the code buffers).

BR,
Ilyes Gouta.

Brian Dessent wrote:
Ilyes Gouta wrote:

Is it possible using GCC? If yes, could you please tell me how?

There is __attribute__((naked)) but it's not supported for x86. I think the feeling is that gcc should be able to detect when a prologue is not necessary on its own and just not emit it, and that forcably disabling the prologue just results in horribly broken code if the function happens to require a spill. See also <http://gcc.gnu.org/ml/gcc/2004-02/threads.html#00939>.

Brian



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