From 44ccd2b09e7237d85b7d66e6b4f1ac8998b36b77 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 13 Sep 2008 15:07:39 -0600 Subject: [PATCH] write alignment padding to output buffer in MyAssembler::writeTo --- src/x86.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/x86.cpp b/src/x86.cpp index ff56bdfd01..c2f4bd4698 100644 --- a/src/x86.cpp +++ b/src/x86.cpp @@ -1569,7 +1569,19 @@ class MyAssembler: public Assembler { c.result = dst; for (MyBlock* b = c.firstBlock; b; b = b->next) { - memcpy(dst + b->start, c.code.data + b->offset, b->size); + unsigned index = 0; + for (AlignmentPadding* p = b->firstPadding; p; p = p->next) { + unsigned size = p->offset - b->offset; + memcpy(dst + b->start + index, c.code.data + b->offset + index, size); + index += size; + while ((b->start + index + 1) % 4) { + *(dst + b->start + index) = 0x90; + ++ index; + } + } + + memcpy(dst + b->start + index, c.code.data + b->offset + index, + b->size - index); } for (Task* t = c.tasks; t; t = t->next) {