From 1444843fd10120b71cec38f37697162afb5d744b Mon Sep 17 00:00:00 2001 From: Meng Zhuo Date: Sun, 31 May 2026 22:36:41 +0800 Subject: [PATCH] riscv64-link: fix C90 mixed declaration warning Fix -Wdeclaration-after-statement: move tp_offset declaration before the for-loop in R_RISCV_TPREL_HI20/LO12_I relocation handler. --- riscv64-link.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)