It appears that %ebx is used by gcc to access global variables when -fPIC is specified. Hence %ebx should be preserved if __asm__ inlines add "%ebx" to the clobber list. However, %ebx guards are not being added, so the resulting code has undefined behavior. Release: gcc-3.0 and gcc-3.2 Environment: intel i386, Debian GNU/Linux How-To-Repeat: just run the attached script, which makes two tiny .c files, compiles, links and runs the result, which segfaults when i do it.
Fix: i don't the proper fix. but a workaround is to push/pop %ebx at the beginning and end of the assembly block.
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed, with 3.2.2pre and 3.3CVS. I'm not sure, though, whether it is allowed to do what you do, or not. I leave this to others.
State-Changed-From-To: analyzed->closed State-Changed-Why: Clobbering %ebx is now illegal in PIC mode on mainline (which will likely become gcc 3.4).