diff --git a/src/arm.cpp b/src/arm.cpp index 2c7549238c..af1c6398a2 100644 --- a/src/arm.cpp +++ b/src/arm.cpp @@ -2413,12 +2413,13 @@ class MyAssembler: public Assembler { poolSize += TargetBytesPerWord; } - if (needJump(b)) { + bool jump = needJump(b); + if (jump) { write4 (dst + dstOffset, ::b((poolSize + TargetBytesPerWord - 8) >> 2)); } - dstOffset += poolSize + TargetBytesPerWord; + dstOffset += poolSize + (jump ? TargetBytesPerWord : 0); } unsigned size = b->size - blockOffset; diff --git a/src/powerpc.cpp b/src/powerpc.cpp index 59e0c77146..7e315b1f35 100644 --- a/src/powerpc.cpp +++ b/src/powerpc.cpp @@ -2733,11 +2733,12 @@ class MyAssembler: public Assembler { assert(&c, jumpTableSize); - if (needJump(b)) { + bool jump = needJump(b); + if (jump) { write4(dst + dstOffset, ::b(jumpTableSize + TargetBytesPerWord)); } - dstOffset += jumpTableSize + TargetBytesPerWord; + dstOffset += jumpTableSize + (jump ? TargetBytesPerWord : 0); } unsigned size = b->size - blockOffset; @@ -2749,7 +2750,7 @@ class MyAssembler: public Assembler { dstOffset += size; } - unsigned index = c.code.length(); + unsigned index = dstOffset; assert(&c, index % TargetBytesPerWord == 0); for (ConstantPoolEntry* e = c.constantPool; e; e = e->next) { e->address = dst + index;