Bug 8546 - ebx is not being preserve for inline asm if -fPIC
Summary: ebx is not being preserve for inline asm if -fPIC
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-12 06:06 UTC by daveb
Modified: 2003-07-25 17:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
bug-script (316 bytes, application/octet-stream)
2003-05-21 15:16 UTC, daveb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description daveb 2002-11-12 06:06:05 UTC
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.
Comment 1 daveb 2002-11-12 06:06:05 UTC
Fix:
i don't the proper fix. but a workaround is to push/pop %ebx at the beginning and end of the assembly block.
Comment 2 Wolfgang Bangerth 2002-12-02 13:06:32 UTC
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.
Comment 3 Eric Botcazou 2002-12-19 09:27:03 UTC
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).