]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/8l: fix data corruption for MULB SI,
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Mon, 26 Nov 2012 20:31:42 +0000 (21:31 +0100)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Mon, 26 Nov 2012 20:31:42 +0000 (21:31 +0100)
The 8l linker automatically inserts XCHG instructions
to support otherwise impossible byte registers
(only available on AX, BX, CX, DX).

Sometimes AX or DX is needed (for MUL and DIV) so
we need to avoid clobbering them.

R=golang-dev, dave, iant, iant, rsc
CC=golang-dev
https://golang.org/cl/6846057

src/cmd/6l/span.c
src/cmd/8l/span.c

index abffc2935cfeae73afd36834057c3f3e4ab69a9a..a181178680ae571206d6b2ce0e9bac8afccc494b 100644 (file)
@@ -1618,7 +1618,9 @@ bad:
                pp = *p;
                z = p->from.type;
                if(z >= D_BP && z <= D_DI) {
-                       if(isax(&p->to)) {
+                       if(isax(&p->to) || p->to.type == D_NONE) {
+                               // We certainly don't want to exchange
+                               // with AX if the op is MUL or DIV.
                                *andptr++ = 0x87;                       /* xchg lhs,bx */
                                asmando(&p->from, reg[D_BX]);
                                subreg(&pp, z, D_BX);
index d90ddc2233e8c9d7eb86d7f418516c6f8714ee35..9e3447c2d28d1d0aa4d398284e4f2acd27c4e502 100644 (file)
@@ -1272,7 +1272,9 @@ bad:
        pp = *p;
        z = p->from.type;
        if(z >= D_BP && z <= D_DI) {
-               if(isax(&p->to)) {
+               if(isax(&p->to) || p->to.type == D_NONE) {
+                       // We certainly don't want to exchange
+                       // with AX if the op is MUL or DIV.
                        *andptr++ = 0x87;                       /* xchg lhs,bx */
                        asmand(&p->from, reg[D_BX]);
                        subreg(&pp, z, D_BX);