Browse code

Fix bytecode on bigendian.

The last commits broke it: we store bytecode constants little-endian-like,
so an 8-bit constant is at offset 0, a 16-bit one at offsets 0,1; a 32-bit one
at 0,1,2,3; and a 64-bit one 0,1,2,3,4,5,6,7,8.
Of course the constant itself is in host-endianness.

Török Edvin authored on 2010/07/30 00:23:36
Showing 1 changed files
... ...
@@ -1703,7 +1703,7 @@ static inline int get_geptypesize(const struct cli_bc *bc, uint16_t tid)
1703 1703
 static int calc_gepz(struct cli_bc *bc, struct cli_bc_func *func, uint16_t tid, operand_t op)
1704 1704
 {
1705 1705
     unsigned off = 0, i;
1706
-    uint64_t *gepoff;
1706
+    uint32_t *gepoff;
1707 1707
     const struct cli_bc_type *ty;
1708 1708
     if (tid >= bc->num_types + 65) {
1709 1709
 	cli_errmsg("bytecode: typeid out of range %u >= %u\n", tid, bc->num_types);
... ...
@@ -1721,7 +1721,7 @@ static int calc_gepz(struct cli_bc *bc, struct cli_bc_func *func, uint16_t tid,
1721 1721
     ty = &bc->types[ty->containedTypes[0] - 65];
1722 1722
     if (ty->kind != DStructType && ty->kind != DPackedStructType)
1723 1723
 	return 0;
1724
-    gepoff = &func->constants[op - func->numValues];
1724
+    gepoff = (uint32_t*)&func->constants[op - func->numValues];
1725 1725
     if (*gepoff >= ty->numElements) {
1726 1726
 	cli_errmsg("bytecode: gep offset out of range: %d >= %d\n",(uint32_t)*gepoff, ty->numElements);
1727 1727
 	return -1;