Skip to content

Commit 1444843

Browse files
committed
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.
1 parent 6b53465 commit 1444843

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎riscv64-link.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ ST_FUNC void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr,
408408
case R_RISCV_TPREL_HI20:
409409
case R_RISCV_TPREL_LO12_I: {
410410
addr_t tls_start = 0;
411+
int64_t tp_offset;
411412
int i;
412413
for (i = 1; i < s1->nb_sections; i++) {
413414
Section *s = s1->sections[i];
@@ -416,7 +417,7 @@ ST_FUNC void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr,
416417
tls_start = s->sh_addr;
417418
}
418419
}
419-
int64_t tp_offset = val - tls_start;
420+
tp_offset = val - tls_start;
420421
if (type == R_RISCV_TPREL_HI20) {
421422
off64 = (int64_t)(tp_offset + 0x800) >> 12;
422423
if ((off64 + ((uint64_t)1 << 20)) >> 21)

0 commit comments

Comments
 (0)