This is the mail archive of the gcc-help@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]

Re: Misalignment of local SSE variables in thread function


I've looked at the assembly (I'm not an expert...).

When using the microsoft compiler both main() and f() have this code at
the start:

00401000  push        ebp
00401001  mov         ebp,esp
00401003  and         esp,0FFFFFFF0h
00401006  sub         esp,10h
..

But with gcc main() has this:

0x4012e2 <main>:        push   %ebp
0x4012e3 <main+1>:      mov    %esp,%ebp
0x4012e5 <main+3>:      sub    $0x28,%esp
0x4012e8 <main+6>:      and    $0xfffffff0,%esp
0x4012eb <main+9>:      mov    $0x0,%eax
..

and f() has:

0x4012ce <f>:   push   %ebp
0x4012cf <f+1>: mov    %esp,%ebp
0x4012d1 <f+3>: sub    $0x8,%esp
0x4012d4 <f+6>: call   0x401290 <g>
0x4012d9 <f+11>:        mov    $0x0,%eax
..

I'm guessing that the 'and 0xfffffff0' is aligning the stack pointer?
So gcc isn't aligning the stack pointer for f(), maybe assuming that it
will already be aligned somehow (which it isn't when it's the entry
point of the thread)?

Jon


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