diff --git a/riscv64-link.c b/riscv64-link.c index 625cccfd..d74777cb 100644 --- a/riscv64-link.c +++ b/riscv64-link.c @@ -408,6 +408,7 @@ ST_FUNC void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, case R_RISCV_TPREL_HI20: case R_RISCV_TPREL_LO12_I: { addr_t tls_start = 0; + int64_t tp_offset; int i; for (i = 1; i < s1->nb_sections; i++) { Section *s = s1->sections[i]; @@ -416,7 +417,7 @@ ST_FUNC void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, tls_start = s->sh_addr; } } - int64_t tp_offset = val - tls_start; + tp_offset = val - tls_start; if (type == R_RISCV_TPREL_HI20) { off64 = (int64_t)(tp_offset + 0x800) >> 12; if ((off64 + ((uint64_t)1 << 20)) >> 21)