From 2701dcfb0673d910014c120c4bbca56417714984 Mon Sep 17 00:00:00 2001 From: herman ten brugge Date: Sun, 7 Jan 2024 07:45:31 +0100 Subject: [PATCH] Add some relocations to riscv64-link.c dlltest failed on a riscv machine. --- riscv64-link.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/riscv64-link.c b/riscv64-link.c index 34bfeb049..39c0c5d20 100644 --- a/riscv64-link.c +++ b/riscv64-link.c @@ -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: @@ -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; @@ -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;