This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/25967] Add attribute naked for x86
- From: "daniel.santos at pobox dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 29 Jul 2017 05:34:13 +0000
- Subject: [Bug target/25967] Add attribute naked for x86
- Auto-submitted: auto-generated
- References: <bug-25967-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25967
--- Comment #12 from Daniel Santos <daniel.santos at pobox dot com> ---
For those interested in a work-around, you can define an __attribute__((used))
function and then within that function use inline assembly to declare your real
function. This can get messy depending upon how portable you need you your
code to be, here is an example:
static void __attribute__((used)) dummy ()
{
__asm__ ("\n"
" .globl myfunc\n"
#ifdef __ELF__
" .type myfunc,@function\n"
#endif
"myfunc:\n"
" <your assembly here>\n"
" ret\n # you must do your own ret.\n"
)
}
I used this in the ms to system v function call tests:
https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.c#L172