c/8546: ebx is not being preserve for inline asm if -fPIC

daveb@ffem.org daveb@ffem.org
Tue Nov 12 06:06:00 GMT 2002


>Number:         8546
>Category:       c
>Synopsis:       ebx is not being preserve for inline asm if -fPIC
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 12 06:06:05 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Dave Benson <daveb@ffem.org>
>Release:        gcc-3.0 and gcc-3.2
>Organization:
>Environment:
intel i386, Debian GNU/Linux
>Description:
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.
>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.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="bug-script"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="bug-script"

CkdDQz1nY2MtMy4yCgpjYXQgPDwiRU9GIiA+IHQuYwojaW5jbHVkZSA8c3RkaW8uaD4KCnZvbGF0
aWxlIGludCB3aGF0ZXZlciA9IDM7CgppbnQgdGVzdF9saWIoKQp7CiAgZnByaW50ZihzdGRlcnIs
IiV1XG4iLCB3aGF0ZXZlcik7CiAgX19hc21fXyBfX3ZvbGF0aWxlICgKICAgICJtb3ZsICQwLCAl
JWVieFxuIgogICAgOgogICAgOgogICAgOiAiJWVieCIKICApOwogIGZwcmludGYoc3RkZXJyLCIl
dVxuIiwgd2hhdGV2ZXIpOwogIHJldHVybiAwOwp9CkVPRgoKY2F0IDw8RU9GID4gbWFpbi5jCnZv
aWQgdGVzdF9saWIoKTsKCmludCBtYWluKCkgeyB0ZXN0X2xpYigpOyByZXR1cm4gMDsgfQpFT0YK
CnNldCAtZSAteAokR0NDIC1EX1JFRU5UUkFOVCAtV2FsbCAtcGVkYW50aWMgLWMgdC5jICAtZlBJ
QyAtRFBJQyAtbyB0LmxvCiRHQ0MgLXNoYXJlZCAgdC5sbyAgIC1vIGxpYnQuc28KJEdDQyAtRF9S
RUVOVFJBTlQgLVdhbGwgLXBlZGFudGljIC1jIG1haW4uYyAgLWZQSUMgLURQSUMgLW8gbWFpbi5v
CiRHQ0MgLW8gdHR0IG1haW4ubyBsaWJ0LnNvCgpMRF9MSUJSQVJZX1BBVEg9LiAuL3R0dAo=



More information about the Gcc-bugs mailing list