This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Miscompilation of remainder expressions
- From: Michael Veksler <mveksler at tx dot technion dot ac dot il>
- To: Dave Korn <dave dot korn at artimi dot com>
- Cc: 'Joe Buck' <Joe dot Buck at synopsys dot COM>, 'Andrew Haley' <aph at redhat dot com>, 'Ian Lance Taylor' <iant at google dot com>, 'Gabriel Dos Reis' <gdr at cs dot tamu dot edu>, 'Roberto Bagnara' <bagnara at cs dot unipr dot it>, gcc at gcc dot gnu dot org
- Date: Wed, 17 Jan 2007 21:38:06 +0200
- Subject: Re: Miscompilation of remainder expressions
- References: <011f01c73a6b$8f6cc390$a501a8c0@CAM.ARTIMI.COM>
Dave Korn wrote:
On 17 January 2007 19:09, Joe Buck wrote:
How will the kernel know whether the overflow in the divide instruction
is because the user's source code has a '%' and not a '/'? We generate
the exact same instruction for i / minus_one(), after all, and in that
case the trap really should be there.
...
Didn't someone suggest a no-op prefix somewhere back up-thread?
Yes, there are two ideas (also documented in the PR):
(1)
IIRC idivl (%ecx) will use the eds segment register by default, so
adding eds prefix will make no difference in semantics. To make
it even more explicit it is possible to add two eds prefixes, just
in case.
If some code depends on a segmented memory model (I think that wine does),
and it still wants to have GCC generate the new behavior, you'd have to
use redundant prefixes such that
eds ess idivl (%ecx)
(I hope got the order right and the first prefix is redundant.)
(2)
The second option is to mark it in the executable in a different ELF
section, like debug info or like C++ exception handling.
This solution will make it workable only with the libc rather
than the kernel modifications.
--
Michael Veksler
http:///tx.technion.ac.il/~mveksler