tcg: Change relocation offsets to intptr_t
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
parent
2f2f244d02
commit
2ba7fae29e
@ -88,7 +88,7 @@ static inline void reloc_pc19(void *code_ptr, tcg_target_long target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void patch_reloc(uint8_t *code_ptr, int type,
|
static inline void patch_reloc(uint8_t *code_ptr, int type,
|
||||||
tcg_target_long value, tcg_target_long addend)
|
intptr_t value, intptr_t addend)
|
||||||
{
|
{
|
||||||
value += addend;
|
value += addend;
|
||||||
|
|
||||||
|
@ -108,21 +108,21 @@ static const int tcg_target_call_oarg_regs[2] = {
|
|||||||
|
|
||||||
#define TCG_REG_TMP TCG_REG_R12
|
#define TCG_REG_TMP TCG_REG_R12
|
||||||
|
|
||||||
static inline void reloc_abs32(void *code_ptr, tcg_target_long target)
|
static inline void reloc_abs32(void *code_ptr, intptr_t target)
|
||||||
{
|
{
|
||||||
*(uint32_t *) code_ptr = target;
|
*(uint32_t *) code_ptr = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void reloc_pc24(void *code_ptr, tcg_target_long target)
|
static inline void reloc_pc24(void *code_ptr, intptr_t target)
|
||||||
{
|
{
|
||||||
uint32_t offset = ((target - ((tcg_target_long) code_ptr + 8)) >> 2);
|
uint32_t offset = ((target - ((intptr_t)code_ptr + 8)) >> 2);
|
||||||
|
|
||||||
*(uint32_t *) code_ptr = ((*(uint32_t *) code_ptr) & ~0xffffff)
|
*(uint32_t *) code_ptr = ((*(uint32_t *) code_ptr) & ~0xffffff)
|
||||||
| (offset & 0xffffff);
|
| (offset & 0xffffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void patch_reloc(uint8_t *code_ptr, int type,
|
static void patch_reloc(uint8_t *code_ptr, int type,
|
||||||
tcg_target_long value, tcg_target_long addend)
|
intptr_t value, intptr_t addend)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case R_ARM_ABS32:
|
case R_ARM_ABS32:
|
||||||
|
@ -149,14 +149,14 @@ static int reassemble_21(int as21)
|
|||||||
#define R_PARISC_PCREL12F R_PARISC_NONE
|
#define R_PARISC_PCREL12F R_PARISC_NONE
|
||||||
|
|
||||||
static void patch_reloc(uint8_t *code_ptr, int type,
|
static void patch_reloc(uint8_t *code_ptr, int type,
|
||||||
tcg_target_long value, tcg_target_long addend)
|
intptr_t value, intptr_t addend)
|
||||||
{
|
{
|
||||||
uint32_t *insn_ptr = (uint32_t *)code_ptr;
|
uint32_t *insn_ptr = (uint32_t *)code_ptr;
|
||||||
uint32_t insn = *insn_ptr;
|
uint32_t insn = *insn_ptr;
|
||||||
tcg_target_long pcrel;
|
intptr_t pcrel;
|
||||||
|
|
||||||
value += addend;
|
value += addend;
|
||||||
pcrel = (value - ((tcg_target_long)code_ptr + 8)) >> 2;
|
pcrel = (value - ((intptr_t)code_ptr + 8)) >> 2;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case R_PARISC_PCREL12F:
|
case R_PARISC_PCREL12F:
|
||||||
|
@ -112,7 +112,7 @@ static bool have_cmov;
|
|||||||
static uint8_t *tb_ret_addr;
|
static uint8_t *tb_ret_addr;
|
||||||
|
|
||||||
static void patch_reloc(uint8_t *code_ptr, int type,
|
static void patch_reloc(uint8_t *code_ptr, int type,
|
||||||
tcg_target_long value, tcg_target_long addend)
|
intptr_t value, intptr_t addend)
|
||||||
{
|
{
|
||||||
value += addend;
|
value += addend;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
|
@ -668,16 +668,16 @@ static inline uint64_t tcg_opc_x3(int qp, uint64_t opc, uint64_t imm)
|
|||||||
* Relocations
|
* Relocations
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline void reloc_pcrel21b (void *pc, tcg_target_long target)
|
static inline void reloc_pcrel21b(void *pc, intptr_t target)
|
||||||
{
|
{
|
||||||
uint64_t imm;
|
uint64_t imm;
|
||||||
int64_t disp;
|
int64_t disp;
|
||||||
int slot;
|
int slot;
|
||||||
|
|
||||||
slot = (tcg_target_long) pc & 3;
|
slot = (intptr_t)pc & 3;
|
||||||
pc = (void *)((tcg_target_long) pc & ~3);
|
pc = (void *)((intptr_t)pc & ~3);
|
||||||
|
|
||||||
disp = target - (tcg_target_long) pc;
|
disp = target - (intptr_t)pc;
|
||||||
imm = (uint64_t) disp >> 4;
|
imm = (uint64_t) disp >> 4;
|
||||||
|
|
||||||
switch(slot) {
|
switch(slot) {
|
||||||
@ -728,12 +728,12 @@ static inline uint64_t get_reloc_pcrel21b (void *pc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void reloc_pcrel60b (void *pc, tcg_target_long target)
|
static inline void reloc_pcrel60b(void *pc, intptr_t target)
|
||||||
{
|
{
|
||||||
int64_t disp;
|
int64_t disp;
|
||||||
uint64_t imm;
|
uint64_t imm;
|
||||||
|
|
||||||
disp = target - (tcg_target_long) pc;
|
disp = target - (intptr_t)pc;
|
||||||
imm = (uint64_t) disp >> 4;
|
imm = (uint64_t) disp >> 4;
|
||||||
|
|
||||||
*(uint64_t *)(pc + 8) = (*(uint64_t *)(pc + 8) & 0xf700000fff800000ull)
|
*(uint64_t *)(pc + 8) = (*(uint64_t *)(pc + 8) & 0xf700000fff800000ull)
|
||||||
@ -759,7 +759,7 @@ static inline uint64_t get_reloc_pcrel60b (void *pc)
|
|||||||
|
|
||||||
|
|
||||||
static void patch_reloc(uint8_t *code_ptr, int type,
|
static void patch_reloc(uint8_t *code_ptr, int type,
|
||||||
tcg_target_long value, tcg_target_long addend)
|
intptr_t value, intptr_t addend)
|
||||||
{
|
{
|
||||||
value += addend;
|
value += addend;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -108,33 +108,33 @@ static const TCGReg tcg_target_call_oarg_regs[2] = {
|
|||||||
|
|
||||||
static uint8_t *tb_ret_addr;
|
static uint8_t *tb_ret_addr;
|
||||||
|
|
||||||
static inline uint32_t reloc_lo16_val (void *pc, tcg_target_long target)
|
static inline uint32_t reloc_lo16_val(void *pc, intptr_t target)
|
||||||
{
|
{
|
||||||
return target & 0xffff;
|
return target & 0xffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void reloc_lo16 (void *pc, tcg_target_long target)
|
static inline void reloc_lo16(void *pc, intptr_t target)
|
||||||
{
|
{
|
||||||
*(uint32_t *) pc = (*(uint32_t *) pc & ~0xffff)
|
*(uint32_t *) pc = (*(uint32_t *) pc & ~0xffff)
|
||||||
| reloc_lo16_val(pc, target);
|
| reloc_lo16_val(pc, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t reloc_hi16_val (void *pc, tcg_target_long target)
|
static inline uint32_t reloc_hi16_val(void *pc, intptr_t target)
|
||||||
{
|
{
|
||||||
return (target >> 16) & 0xffff;
|
return (target >> 16) & 0xffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void reloc_hi16 (void *pc, tcg_target_long target)
|
static inline void reloc_hi16(void *pc, intptr_t target)
|
||||||
{
|
{
|
||||||
*(uint32_t *) pc = (*(uint32_t *) pc & ~0xffff)
|
*(uint32_t *) pc = (*(uint32_t *) pc & ~0xffff)
|
||||||
| reloc_hi16_val(pc, target);
|
| reloc_hi16_val(pc, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t reloc_pc16_val (void *pc, tcg_target_long target)
|
static inline uint32_t reloc_pc16_val(void *pc, intptr_t target)
|
||||||
{
|
{
|
||||||
int32_t disp;
|
int32_t disp;
|
||||||
|
|
||||||
disp = target - (tcg_target_long) pc - 4;
|
disp = target - (intptr_t)pc - 4;
|
||||||
if (disp != (disp << 14) >> 14) {
|
if (disp != (disp << 14) >> 14) {
|
||||||
tcg_abort ();
|
tcg_abort ();
|
||||||
}
|
}
|
||||||
@ -157,14 +157,14 @@ static inline uint32_t reloc_26_val (void *pc, tcg_target_long target)
|
|||||||
return (target >> 2) & 0x3ffffff;
|
return (target >> 2) & 0x3ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void reloc_pc26 (void *pc, tcg_target_long target)
|
static inline void reloc_pc26(void *pc, intptr_t target)
|
||||||
{
|
{
|
||||||
*(uint32_t *) pc = (*(uint32_t *) pc & ~0x3ffffff)
|
*(uint32_t *) pc = (*(uint32_t *) pc & ~0x3ffffff)
|
||||||
| reloc_26_val(pc, target);
|
| reloc_26_val(pc, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void patch_reloc(uint8_t *code_ptr, int type,
|
static void patch_reloc(uint8_t *code_ptr, int type,
|
||||||
tcg_target_long value, tcg_target_long addend)
|
intptr_t value, intptr_t addend)
|
||||||
{
|
{
|
||||||
value += addend;
|
value += addend;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
|
@ -204,7 +204,7 @@ static void reloc_pc14 (void *pc, tcg_target_long target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void patch_reloc(uint8_t *code_ptr, int type,
|
static void patch_reloc(uint8_t *code_ptr, int type,
|
||||||
tcg_target_long value, tcg_target_long addend)
|
intptr_t value, intptr_t addend)
|
||||||
{
|
{
|
||||||
value += addend;
|
value += addend;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -208,7 +208,7 @@ static void reloc_pc14 (void *pc, tcg_target_long target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void patch_reloc (uint8_t *code_ptr, int type,
|
static void patch_reloc (uint8_t *code_ptr, int type,
|
||||||
tcg_target_long value, tcg_target_long addend)
|
intptr_t value, intptr_t addend)
|
||||||
{
|
{
|
||||||
value += addend;
|
value += addend;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -351,10 +351,10 @@ static uint8_t *tb_ret_addr;
|
|||||||
static uint64_t facilities;
|
static uint64_t facilities;
|
||||||
|
|
||||||
static void patch_reloc(uint8_t *code_ptr, int type,
|
static void patch_reloc(uint8_t *code_ptr, int type,
|
||||||
tcg_target_long value, tcg_target_long addend)
|
intptr_t value, intptr_t addend)
|
||||||
{
|
{
|
||||||
tcg_target_long code_ptr_tl = (tcg_target_long)code_ptr;
|
intptr_t code_ptr_tl = (intptr_t)code_ptr;
|
||||||
tcg_target_long pcrel2;
|
intptr_t pcrel2;
|
||||||
|
|
||||||
/* ??? Not the usual definition of "addend". */
|
/* ??? Not the usual definition of "addend". */
|
||||||
pcrel2 = (value - (code_ptr_tl + addend)) >> 1;
|
pcrel2 = (value - (code_ptr_tl + addend)) >> 1;
|
||||||
|
@ -252,7 +252,7 @@ static inline int check_fit_i32(uint32_t val, unsigned int bits)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void patch_reloc(uint8_t *code_ptr, int type,
|
static void patch_reloc(uint8_t *code_ptr, int type,
|
||||||
tcg_target_long value, tcg_target_long addend)
|
intptr_t value, intptr_t addend)
|
||||||
{
|
{
|
||||||
uint32_t insn;
|
uint32_t insn;
|
||||||
value += addend;
|
value += addend;
|
||||||
@ -264,7 +264,7 @@ static void patch_reloc(uint8_t *code_ptr, int type,
|
|||||||
*(uint32_t *)code_ptr = value;
|
*(uint32_t *)code_ptr = value;
|
||||||
break;
|
break;
|
||||||
case R_SPARC_WDISP16:
|
case R_SPARC_WDISP16:
|
||||||
value -= (long)code_ptr;
|
value -= (intptr_t)code_ptr;
|
||||||
if (!check_fit_tl(value >> 2, 16)) {
|
if (!check_fit_tl(value >> 2, 16)) {
|
||||||
tcg_abort();
|
tcg_abort();
|
||||||
}
|
}
|
||||||
@ -274,7 +274,7 @@ static void patch_reloc(uint8_t *code_ptr, int type,
|
|||||||
*(uint32_t *)code_ptr = insn;
|
*(uint32_t *)code_ptr = insn;
|
||||||
break;
|
break;
|
||||||
case R_SPARC_WDISP19:
|
case R_SPARC_WDISP19:
|
||||||
value -= (long)code_ptr;
|
value -= (intptr_t)code_ptr;
|
||||||
if (!check_fit_tl(value >> 2, 19)) {
|
if (!check_fit_tl(value >> 2, 19)) {
|
||||||
tcg_abort();
|
tcg_abort();
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
static void tcg_target_init(TCGContext *s);
|
static void tcg_target_init(TCGContext *s);
|
||||||
static void tcg_target_qemu_prologue(TCGContext *s);
|
static void tcg_target_qemu_prologue(TCGContext *s);
|
||||||
static void patch_reloc(uint8_t *code_ptr, int type,
|
static void patch_reloc(uint8_t *code_ptr, int type,
|
||||||
tcg_target_long value, tcg_target_long addend);
|
intptr_t value, intptr_t addend);
|
||||||
|
|
||||||
/* The CIE and FDE header definitions will be common to all hosts. */
|
/* The CIE and FDE header definitions will be common to all hosts. */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -143,7 +143,7 @@ static inline void tcg_out64(TCGContext *s, uint64_t v)
|
|||||||
/* label relocation processing */
|
/* label relocation processing */
|
||||||
|
|
||||||
static void tcg_out_reloc(TCGContext *s, uint8_t *code_ptr, int type,
|
static void tcg_out_reloc(TCGContext *s, uint8_t *code_ptr, int type,
|
||||||
int label_index, long addend)
|
int label_index, intptr_t addend)
|
||||||
{
|
{
|
||||||
TCGLabel *l;
|
TCGLabel *l;
|
||||||
TCGRelocation *r;
|
TCGRelocation *r;
|
||||||
@ -169,11 +169,12 @@ static void tcg_out_label(TCGContext *s, int label_index, void *ptr)
|
|||||||
{
|
{
|
||||||
TCGLabel *l;
|
TCGLabel *l;
|
||||||
TCGRelocation *r;
|
TCGRelocation *r;
|
||||||
tcg_target_long value = (tcg_target_long)ptr;
|
intptr_t value = (intptr_t)ptr;
|
||||||
|
|
||||||
l = &s->labels[label_index];
|
l = &s->labels[label_index];
|
||||||
if (l->has_value)
|
if (l->has_value) {
|
||||||
tcg_abort();
|
tcg_abort();
|
||||||
|
}
|
||||||
r = l->u.first_reloc;
|
r = l->u.first_reloc;
|
||||||
while (r != NULL) {
|
while (r != NULL) {
|
||||||
patch_reloc(r->ptr, r->type, value, r->addend);
|
patch_reloc(r->ptr, r->type, value, r->addend);
|
||||||
|
@ -139,13 +139,13 @@ typedef struct TCGRelocation {
|
|||||||
struct TCGRelocation *next;
|
struct TCGRelocation *next;
|
||||||
int type;
|
int type;
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
tcg_target_long addend;
|
intptr_t addend;
|
||||||
} TCGRelocation;
|
} TCGRelocation;
|
||||||
|
|
||||||
typedef struct TCGLabel {
|
typedef struct TCGLabel {
|
||||||
int has_value;
|
int has_value;
|
||||||
union {
|
union {
|
||||||
tcg_target_ulong value;
|
uintptr_t value;
|
||||||
TCGRelocation *first_reloc;
|
TCGRelocation *first_reloc;
|
||||||
} u;
|
} u;
|
||||||
} TCGLabel;
|
} TCGLabel;
|
||||||
|
@ -370,7 +370,7 @@ static const char *const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void patch_reloc(uint8_t *code_ptr, int type,
|
static void patch_reloc(uint8_t *code_ptr, int type,
|
||||||
tcg_target_long value, tcg_target_long addend)
|
intptr_t value, intptr_t addend)
|
||||||
{
|
{
|
||||||
/* tcg_out_reloc always uses the same type, addend. */
|
/* tcg_out_reloc always uses the same type, addend. */
|
||||||
assert(type == sizeof(tcg_target_long));
|
assert(type == sizeof(tcg_target_long));
|
||||||
|
Loading…
Reference in New Issue
Block a user