This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/41941] New: bad stack allocation using inline asm


compiling a assembler inline code which use a log of registers and with -O2
option instructions like

movq    %rbx, -40(%rsp)

are generated which are wrong cause it writes to not allocated stack which
could lead to corruption on interrupts

code
void foo(const unsigned char *p)
{

  unsigned int t0, t1, t2, t3;
  __asm__ __volatile__
  (
  ".intel_syntax noprefix;"
  "mov r8" ", " "rsi" ";"
  "mov r9" ", " "rcx" ";"

  ".att_syntax prefix;"
   : "=a" (t0), "=c" (t1), "=S" (t2), "=D" (t3)
   : "D" (p)
   : "memory", "cc"

   , "%ebx" , "%r8", "%r9", "%r10", "%r11", "%r12" , "%r13", "%r14", "%r15"

  );

}



I'll attach source code, generated code and gcc command output

freddy77


-- 
           Summary: bad stack allocation using inline asm
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: freddy77 at gmail dot com
 GCC build triplet: x86_64-linux-gnu
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]