Testcase is extracted from Wine.
/home/marcus/projects/gcc/BIN/bin/gcc -m32 -fPIC -O2 -o reg reg.i
./reg
Segmentation fault
(I did not try the i586 version of the compiler.)
Looking at the disassembly the stdcall function is compiled as:
foo:
pushl %ebp
movl %esp, %ebp
pushl %ebx
call __i686.get_pc_thunk.bx
addl $_GLOBAL_OFFSET_TABLE_, %ebx
subl $4, %esp
movl $0, (%esp)
call [EMAIL PROTECTED]
addl $4, %esp
popl %ebx
popl %ebp
ret
It does adjust the stackframe after the call to bar wrongly, either it should
not do it, or just emit a "leave".
--
Summary: stdcall function is miscompiled
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: marcus at jet dot franken dot de
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: i586-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31628