]> granicus.if.org Git - yasm/commitdiff
Fix #58 and a more basic form of this bug (all EAs that needed non-zero
authorPeter Johnson <peter@tortall.net>
Sat, 12 Aug 2006 18:27:04 +0000 (18:27 -0000)
committerPeter Johnson <peter@tortall.net>
Sat, 12 Aug 2006 18:27:04 +0000 (18:27 -0000)
displacement length and required optimization would end up with 0
displacement length, causing an internal error).

svn path=/trunk/yasm/; revision=1606

libyasm/section.c
modules/arch/x86/tests/Makefile.inc
modules/arch/x86/tests/ea-nonzero.asm [new file with mode: 0644]
modules/arch/x86/tests/ea-nonzero.errwarn [new file with mode: 0644]
modules/arch/x86/tests/ea-nonzero.hex [new file with mode: 0644]
modules/arch/x86/x86bc.c

index 8ca23dbf145de6ccdbf152521ee4b07946f652fb..78f79ecea0ac0c8e7f2efd4bccde33c038cf5cb1 100644 (file)
@@ -853,10 +853,11 @@ span_create_terms(yasm_span *span)
                span->items[i].data.intn = yasm_intnum_create_int(0);
 
                /* Check for circular references */
-               if ((span->bc->bc_index > span->terms[i].precbc->bc_index &&
-                    span->bc->bc_index <= span->terms[i].precbc2->bc_index) ||
-                   (span->bc->bc_index > span->terms[i].precbc2->bc_index &&
-                    span->bc->bc_index <= span->terms[i].precbc->bc_index))
+               if (span->id == 0 &&
+                   ((span->bc->bc_index > span->terms[i].precbc->bc_index &&
+                     span->bc->bc_index <= span->terms[i].precbc2->bc_index) ||
+                    (span->bc->bc_index > span->terms[i].precbc2->bc_index &&
+                     span->bc->bc_index <= span->terms[i].precbc->bc_index)))
                    yasm_error_set(YASM_ERROR_VALUE,
                                   N_("circular reference detected"));
            }
index c2c79ccb3c3d695cf9c5976856ee5b61173c593d..eab5961bec54b784d273f7b8dc2523e08c1294b4 100644 (file)
@@ -27,6 +27,9 @@ EXTRA_DIST += modules/arch/x86/tests/cpubasic-err.asm
 EXTRA_DIST += modules/arch/x86/tests/cpubasic-err.errwarn
 EXTRA_DIST += modules/arch/x86/tests/div-err.asm
 EXTRA_DIST += modules/arch/x86/tests/div-err.errwarn
+EXTRA_DIST += modules/arch/x86/tests/ea-nonzero.asm
+EXTRA_DIST += modules/arch/x86/tests/ea-nonzero.errwarn
+EXTRA_DIST += modules/arch/x86/tests/ea-nonzero.hex
 EXTRA_DIST += modules/arch/x86/tests/ea-over.asm
 EXTRA_DIST += modules/arch/x86/tests/ea-over.errwarn
 EXTRA_DIST += modules/arch/x86/tests/ea-over.hex
diff --git a/modules/arch/x86/tests/ea-nonzero.asm b/modules/arch/x86/tests/ea-nonzero.asm
new file mode 100644 (file)
index 0000000..27d36bd
--- /dev/null
@@ -0,0 +1,6 @@
+; Ticket #58
+; Also tests that this isn't seen as a circular reference.
+[bits 64]
+a:
+lea rbp,[rsi+rbp*1+(b-a)]
+b:
diff --git a/modules/arch/x86/tests/ea-nonzero.errwarn b/modules/arch/x86/tests/ea-nonzero.errwarn
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/modules/arch/x86/tests/ea-nonzero.hex b/modules/arch/x86/tests/ea-nonzero.hex
new file mode 100644 (file)
index 0000000..dd2b57e
--- /dev/null
@@ -0,0 +1,5 @@
+48 
+8d 
+6c 
+2e 
+05 
index b2f01d048afde228305d4652dfb9caa230a155a2..e587d36da8c632466941fbe8067c9c6e2e2f5894 100644 (file)
@@ -533,10 +533,10 @@ x86_bc_insn_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
            /* Handle unknown case, default to byte-sized and set as
             * critical expression.
             */
-           bc->len += 1;
+           x86_ea->ea.disp.size = 8;
            add_span(add_span_data, bc, 1, &x86_ea->ea.disp, -128, 127);
-       } else
-           bc->len += x86_ea->ea.disp.size/8;
+       }
+       bc->len += x86_ea->ea.disp.size/8;
 
        /* Handle address16 postop case */
        if (insn->postop == X86_POSTOP_ADDRESS16)
@@ -608,7 +608,7 @@ x86_bc_insn_expand(yasm_bytecode *bc, int span, long old_val, long new_val,
 
     if (ea && span == 1) {
        /* Change displacement length into word-sized */
-       if (ea->disp.size == 0) {
+       if (ea->disp.size == 8) {
            ea->disp.size = (insn->common.addrsize == 16) ? 16 : 32;
            x86_ea->modrm &= ~0300;
            x86_ea->modrm |= 0200;