Revision c69806ab
b/tcg/arm/tcg-target.c | ||
---|---|---|
113 | 113 |
TCG_REG_R0, TCG_REG_R1 |
114 | 114 |
}; |
115 | 115 |
|
116 |
static inline void reloc_abs32(void *code_ptr, tcg_target_long target) |
|
117 |
{ |
|
118 |
*(uint32_t *) code_ptr = target; |
|
119 |
} |
|
120 |
|
|
121 |
static inline void reloc_pc24(void *code_ptr, tcg_target_long target) |
|
122 |
{ |
|
123 |
uint32_t offset = ((target - ((tcg_target_long) code_ptr + 8)) >> 2); |
|
124 |
|
|
125 |
*(uint32_t *) code_ptr = ((*(uint32_t *) code_ptr) & ~0xffffff) |
|
126 |
| (offset & 0xffffff); |
|
127 |
} |
|
128 |
|
|
116 | 129 |
static void patch_reloc(uint8_t *code_ptr, int type, |
117 | 130 |
tcg_target_long value, tcg_target_long addend) |
118 | 131 |
{ |
119 | 132 |
switch (type) { |
120 | 133 |
case R_ARM_ABS32: |
121 |
*(uint32_t *) code_ptr = value;
|
|
134 |
reloc_abs32(code_ptr, value);
|
|
122 | 135 |
break; |
123 | 136 |
|
124 | 137 |
case R_ARM_CALL: |
... | ... | |
127 | 140 |
tcg_abort(); |
128 | 141 |
|
129 | 142 |
case R_ARM_PC24: |
130 |
*(uint32_t *) code_ptr = ((*(uint32_t *) code_ptr) & 0xff000000) | |
|
131 |
(((value - ((tcg_target_long) code_ptr + 8)) >> 2) & 0xffffff); |
|
143 |
reloc_pc24(code_ptr, value); |
|
132 | 144 |
break; |
133 | 145 |
} |
134 | 146 |
} |
... | ... | |
1031 | 1043 |
} |
1032 | 1044 |
|
1033 | 1045 |
label_ptr = (void *) s->code_ptr; |
1034 |
tcg_out_b(s, COND_EQ, 8);
|
|
1046 |
tcg_out_b_noaddr(s, COND_EQ);
|
|
1035 | 1047 |
|
1036 | 1048 |
/* TODO: move this code to where the constants pool will be */ |
1037 | 1049 |
if (addr_reg != TCG_REG_R0) { |
... | ... | |
1076 | 1088 |
break; |
1077 | 1089 |
} |
1078 | 1090 |
|
1079 |
*label_ptr += ((void *) s->code_ptr - (void *) label_ptr - 8) >> 2;
|
|
1091 |
reloc_pc24(label_ptr, (tcg_target_long)s->code_ptr);
|
|
1080 | 1092 |
#else /* !CONFIG_SOFTMMU */ |
1081 | 1093 |
if (GUEST_BASE) { |
1082 | 1094 |
uint32_t offset = GUEST_BASE; |
... | ... | |
1245 | 1257 |
} |
1246 | 1258 |
|
1247 | 1259 |
label_ptr = (void *) s->code_ptr; |
1248 |
tcg_out_b(s, COND_EQ, 8);
|
|
1260 |
tcg_out_b_noaddr(s, COND_EQ);
|
|
1249 | 1261 |
|
1250 | 1262 |
/* TODO: move this code to where the constants pool will be */ |
1251 | 1263 |
tcg_out_dat_reg(s, COND_AL, ARITH_MOV, |
... | ... | |
1317 | 1329 |
if (opc == 3) |
1318 | 1330 |
tcg_out_dat_imm(s, COND_AL, ARITH_ADD, TCG_REG_R13, TCG_REG_R13, 0x10); |
1319 | 1331 |
|
1320 |
*label_ptr += ((void *) s->code_ptr - (void *) label_ptr - 8) >> 2;
|
|
1332 |
reloc_pc24(label_ptr, (tcg_target_long)s->code_ptr);
|
|
1321 | 1333 |
#else /* !CONFIG_SOFTMMU */ |
1322 | 1334 |
if (GUEST_BASE) { |
1323 | 1335 |
uint32_t offset = GUEST_BASE; |
... | ... | |
1399 | 1411 |
/* Direct jump method */ |
1400 | 1412 |
#if defined(USE_DIRECT_JUMP) |
1401 | 1413 |
s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf; |
1402 |
tcg_out_b(s, COND_AL, 8);
|
|
1414 |
tcg_out_b_noaddr(s, COND_AL);
|
|
1403 | 1415 |
#else |
1404 | 1416 |
tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_PC, -4); |
1405 | 1417 |
s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf; |
Also available in: Unified diff