public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50242] New: __attribute__((naked)) is ignored on IA32 (x86)
@ 2011-08-30 20:34 congruwer at yahoo dot co.uk
  2011-08-30 20:50 ` [Bug target/50242] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: congruwer at yahoo dot co.uk @ 2011-08-30 20:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50242

             Bug #: 50242
           Summary: __attribute__((naked)) is ignored on IA32 (x86)
    Classification: Unclassified
           Product: gcc
           Version: 4.5.2
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: congruwer@yahoo.co.uk


Given the follow c++ file:
---(start)---
__attribute__((naked)) void test(int a)
{
    asm("//Do stuff");
    asm("ret $4");
};

struct myclass
{
    __attribute__((naked)) ~myclass()
    {
        asm("//Do stuff");
        asm("ret");
    }

    virtual void virt() { };
};

void testmyclass()
{
    myclass x;
}
---(end)---
The compiler will give the following complaints:
testnaked.cpp:1:39: warning: 'naked' attribute directive ignored
testnaked.cpp:9:34: warning: 'naked' attribute directive ignored
Additionally, prolog and epilog code is generated. The relevant parts of the
assembler output with added commentary follow:
---(start)---
__Z4testi: //test(int)
/APP
 # 3 "testnaked.cpp" 1
    //Do stuff
 # 0 "" 2
 # 4 "testnaked.cpp" 1
    ret $4
 # 0 "" 2
/NO_APP
    ret // This ret shouldn't be here.
...(snip)...
__ZN7myclassD1Ev: //myclass::~myclass()
    movl    4(%esp), %eax // Destructor prolog that restores the vtable.
    movl    $__ZTV7myclass+8, (%eax) // These 2 lines shouldn't be present.
/APP
 # 11 "testnaked.cpp" 1
    //Do stuff
 # 0 "" 2
 # 12 "testnaked.cpp" 1
    ret
 # 0 "" 2
/NO_APP
    ret // This ret shouldn't be here.
---(end)---
My apologies for the AT&T syntax, but that's what -S yields.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-12-25 17:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-30 20:34 [Bug c++/50242] New: __attribute__((naked)) is ignored on IA32 (x86) congruwer at yahoo dot co.uk
2011-08-30 20:50 ` [Bug target/50242] " pinskia at gcc dot gnu.org
2011-08-31 16:11 ` [Bug target/50242] __attribute__((naked)) is not implemented " congruwer at yahoo dot co.uk
2011-08-31 17:12 ` jakub at gcc dot gnu.org
2011-09-01  8:10 ` congruwer at yahoo dot co.uk
2011-09-01  8:13 ` jakub at gcc dot gnu.org
2011-09-01  9:16 ` congruwer at yahoo dot co.uk
2011-09-01  9:21 ` congruwer at yahoo dot co.uk
2011-12-25 15:45 ` radoslaw.biernacki at gmail dot com
2011-12-25 17:22 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).