bug report

Antoine Pitrou Quiche.Eaters@mail.dotcom.fr
Mon Nov 23 04:02:00 GMT 1998


This is a bug report for egcs release 1.1a for x86, DJGPP version under Ms-Dos 6.22
(binaries package). This bug was not present in gcc 2.8.1 or previous releases.
When using the '-fomit-frame-pointer' option, it seems that *not all* functions
use %esp instead of %ebp. Despite of this, when the %ebp is explicitly clobbered
by an extended asm construction, it isn't saved and restored by the compiler
(always with the '-fomit-frame-pointer' option). This of course causes a crash
when the said asm construct is called from a function which uses %ebp as a
frame pointer, and assumes its value remains unchanged.

The following example shows this when compiled with '-O2 -fomit-frame-pointer'.
In the generated assembler source code, you will see that function Video::Init
uses %ebp as a frame pointer as though the '-fomit-frame-pointer' hadn't been
specified. This function calls Video::TotalRedraw which in turn calls Video::Redraw,
which itself calls asmdisp, where %ebp is explicitly clobbered by the asm construction,
but not saved by the compiler (in the asm construction you'll see the "pushl %%ebp" /
"popl %%ebp" pair, which cheaply workarounds the bug).

Anothing thing about the '-fomit-frame-pointer' flag on the x86 is that it doesn't
seem to allow allocation of %ebp by the compiler - you have to use '-fcall-used-ebp'.

attached is a zip containing the incriminated source file (after preprocessing).

good luck

Antoine Pitrou.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: video.zip
Type: application/zip
Size: 34941 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/19981123/2a3dd473/attachment.zip>

More information about the Gcc-bugs mailing list