Function without prologue and epilogue
How can I set a function without a prologue and an epilogue so that only the body code is created?
For example, to have the function
void func() {
__asm__ volatile__ ("nop");
}
Compiled into the code
0: 90 nop
Instead of the code
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 90 nop
4: 5d pop %ebp
5: c3 ret
Are there standard C tools (visual c, gcc) ?
6
1 answers
There is no such feature in the C standard. It can be provided by specific compilers. For example, for Visual C++ on the x86 platform, it will look like this:
__declspec( naked ) void func( void ) { __asm { nop } }
For ARM gcc:
void func() __attribute__ ((naked));
void func(void) {
__asm__ __volatile__("nop");
}
10
Author: stanislav, 2016-12-27 23:03:59