History

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.

Meng Zhuo committed 5 months ago

Commit 14448431 parent 6b534651 file · +2 −1Browse files

Unified · Split

riscv64-link.c+2−1
@@ -408,6 +408,7 @@ ST_FUNC void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, · 407 unmodified lines
408 case R_RISCV_TPREL_HI20:408 case R_RISCV_TPREL_HI20:
409 case R_RISCV_TPREL_LO12_I: {409 case R_RISCV_TPREL_LO12_I: {
410 addr_t tls_start = 0;410 addr_t tls_start = 0;
411 int64_t tp_offset;
411 int i;412 int i;
412 for (i = 1; i < s1->nb_sections; i++) {413 for (i = 1; i < s1->nb_sections; i++) {
413 Section *s = s1->sections[i];414 Section *s = s1->sections[i];
@@ -416,7 +417,7 @@ ST_FUNC void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, · 2 unmodified lines
416 tls_start = s->sh_addr;417 tls_start = s->sh_addr;
417 }418 }
418 }419 }
419 int64_t tp_offset = val - tls_start;420 tp_offset = val - tls_start;
420 if (type == R_RISCV_TPREL_HI20) {421 if (type == R_RISCV_TPREL_HI20) {
421 off64 = (int64_t)(tp_offset + 0x800) >> 12;422 off64 = (int64_t)(tp_offset + 0x800) >> 12;
422 if ((off64 + ((uint64_t)1 << 20)) >> 21)423 if ((off64 + ((uint64_t)1 << 20)) >> 21)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t