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