Skip to content

Commit

Permalink
Add some relocations to riscv64-link.c
Browse files Browse the repository at this point in the history
dlltest failed on a riscv machine.
  • Loading branch information
hermantb committed Jan 7, 2024
1 parent c13bbb5 commit 2701dcf
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions riscv64-link.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ int code_reloc (int reloc_type)
case R_RISCV_PCREL_LO12_S:
case R_RISCV_32_PCREL:
case R_RISCV_SET6:
case R_RISCV_SET8:
case R_RISCV_SET16:
case R_RISCV_SUB6:
case R_RISCV_ADD16:
case R_RISCV_ADD32:
case R_RISCV_ADD64:
case R_RISCV_SUB8:
case R_RISCV_SUB16:
case R_RISCV_SUB32:
case R_RISCV_SUB64:
Expand All @@ -68,8 +71,11 @@ int gotplt_entry_type (int reloc_type)
case R_RISCV_RVC_JUMP:
case R_RISCV_JUMP_SLOT:
case R_RISCV_SET6:
case R_RISCV_SET8:
case R_RISCV_SET16:
case R_RISCV_SUB6:
case R_RISCV_ADD16:
case R_RISCV_SUB8:
case R_RISCV_SUB16:
return NO_GOTPLT_ENTRY;

Expand Down Expand Up @@ -328,12 +334,21 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr,
case R_RISCV_ADD16:
write16le(ptr, read16le(ptr) + val);
return;
case R_RISCV_SUB8:
*ptr -= val;
return;
case R_RISCV_SUB16:
write16le(ptr, read16le(ptr) - val);
return;
case R_RISCV_SET6:
*ptr = (*ptr & ~0x3f) | (val & 0x3f);
return;
case R_RISCV_SET8:
*ptr = (*ptr & ~0xff) | (val & 0xff);
return;
case R_RISCV_SET16:
*ptr = (*ptr & ~0xffff) | (val & 0xffff);
return;
case R_RISCV_SUB6:
*ptr = (*ptr & ~0x3f) | ((*ptr - val) & 0x3f);
return;
Expand Down

0 comments on commit 2701dcf

Please sign in to comment.