Posted: Mon Aug 25, 2008 12:52 pm Post subject: How to make Naked Functions in GCC (explained)
GCC has a somewhat arbitrary restriction of not allowing declspec(naked) (or rather, __attribute__((naked)) ) on any processors except ARM, AVR, C4x and IP2K. This is a pain in the ass. However, it is possible to circumvent.
The way this works: int foobar declares the function prototype, without defining the function. Since the function is never defined in C, the buck gets passed to the linker to find foobar (mingw appends an underscore to the symbol name). The asm block gets passed, along with the asm generated by gcc, to the assembler, which makes _foobar into a symbol which the linker then finds.
Another note: .intel_syntax allows you to use intel asm syntax with GCC. At the end of your block you must use .att_syntax again or the assembler will try to interpret GCC's att asm as intel asm.
~nog_lorp
Credits to GynvaelColdwind of OpenRCE for his advice. _________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum