Due to padding issues, sizeof() can provide incorrect offsets.
Therefore, we replace sizeof() with offsetof().

Signed-off-by: Eduard - Gabriel Munteanu <eduard.munte...@linux360.ro>
---
 arch/x86/insn-selector.brg |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/insn-selector.brg b/arch/x86/insn-selector.brg
index 4e8b96b..d1e8449 100644
--- a/arch/x86/insn-selector.brg
+++ b/arch/x86/insn-selector.brg
@@ -1996,7 +1996,8 @@ inst_field: EXPR_INSTANCE_FIELD(reg) 1
        expr = to_expr(tree);
 
        state->reg1 = state->left->reg1;
-       state->reg2 = (void*)(sizeof(struct vm_object) + 
expr->instance_field->offset);
+       state->reg2 = (void *) (offsetof(struct vm_object, fields) +
+                               expr->instance_field->offset);
 }
 
 float_inst_field: EXPR_FLOAT_INSTANCE_FIELD(reg) 1
@@ -2006,7 +2007,8 @@ float_inst_field: EXPR_FLOAT_INSTANCE_FIELD(reg) 1
        expr = to_expr(tree);
 
        state->reg1 = state->left->reg1;
-       state->reg2 = (void*)(sizeof(struct vm_object) + 
expr->instance_field->offset);
+       state->reg2 = (void *) (offsetof(struct vm_object, fields) +
+                               expr->instance_field->offset);
 }
 
 stmt:  STMT_STORE(inst_field, reg)
-- 
1.6.0.6


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to