Portál AbcLinuxu, 13. května 2025 22:21
void func(void) __attribute__((naked)) {}mi vyhodí chybu "error: attributes are not allowed on a function-definition". Není to náhodou blbost? Tenhle atribut by přece měl být právě na definici funkce. Tak jsem teda zkusil udělat deklaraci:
void func(void) __attribute__((naked));a z toho je "warning: 'naked' attribute directive ignored". Myslíte si že je to chyba v GCC nebo ve mě?
push ebp mov ebp, espKaždopádně __declspec(naked) na MSVC jde, tak jsem předpokládal, že to bude brát i GCC.
`naked' Use this attribute on the ARM, AVR, C4x and IP2K 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.Co přesně dělá __declspec(naked) u MSVC na Intelu?
For functions declared with the naked attribute, the compiler generates code without prolog and epilog code. You can use this feature to write your own prolog/epilog code sequences using inline assembler code.
pushl %ebp movl %esp, %ebp leave retTo lze jednak inlinováním ;-) a jednak -fomit-frame-pointer (pokud ho ta funkce nepotřebuje).
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.