History

riscv: Handle more relocs

those happen on SUSE systems.

Michael Matz committed 7 years ago

Commit 5fcb8711 parent 93095851 file · +30 −0Browse files

Unified · Split

riscv64-link.c+30−0
@@ -37,8 +37,14 @@ int code_reloc (int reloc_type) · 36 unmodified lines
3737 case R_RISCV_PCREL_LO12_I:
3838 case R_RISCV_PCREL_LO12_S:
3939 case R_RISCV_32_PCREL:
40+ case R_RISCV_SET6:
41+ case R_RISCV_SUB6:
42+ case R_RISCV_ADD16:
4043 case R_RISCV_ADD32:
44+ case R_RISCV_ADD64:
45+ case R_RISCV_SUB16:
4146 case R_RISCV_SUB32:
47+ case R_RISCV_SUB64:
4248 case R_RISCV_32:
4349 case R_RISCV_64:
4450 return 0;
@@ -61,6 +67,10 @@ int gotplt_entry_type (int reloc_type) · 16 unmodified lines
6167 case R_RISCV_RVC_BRANCH:
6268 case R_RISCV_RVC_JUMP:
6369 case R_RISCV_JUMP_SLOT:
70+ case R_RISCV_SET6:
71+ case R_RISCV_SUB6:
72+ case R_RISCV_ADD16:
73+ case R_RISCV_SUB16:
6474 return NO_GOTPLT_ENTRY;
6575
6676 case R_RISCV_BRANCH:
@@ -70,7 +80,9 @@ int gotplt_entry_type (int reloc_type) · 3 unmodified lines
7080 case R_RISCV_PCREL_LO12_S:
7181 case R_RISCV_32_PCREL:
7282 case R_RISCV_ADD32:
83+ case R_RISCV_ADD64:
7384 case R_RISCV_SUB32:
85+ case R_RISCV_SUB64:
7486 case R_RISCV_32:
7587 case R_RISCV_64:
7688 case R_RISCV_JAL:
@@ -287,12 +299,30 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, · 210 unmodified lines
287299 case R_RISCV_64:
288300 write64le(ptr, val);
289301 return;
302+ case R_RISCV_ADD64:
303+ write64le(ptr, read64le(ptr) + val);
304+ return;
290305 case R_RISCV_ADD32:
291306 write32le(ptr, read32le(ptr) + val);
292307 return;
308+ case R_RISCV_SUB64:
309+ write64le(ptr, read64le(ptr) - val);
310+ return;
293311 case R_RISCV_SUB32:
294312 write32le(ptr, read32le(ptr) - val);
295313 return;
314+ case R_RISCV_ADD16:
315+ write16le(ptr, read16le(ptr) + val);
316+ return;
317+ case R_RISCV_SUB16:
318+ write16le(ptr, read16le(ptr) - val);
319+ return;
320+ case R_RISCV_SET6:
321+ *ptr = (*ptr & ~0x3f) | (val & 0x3f);
322+ return;
323+ case R_RISCV_SUB6:
324+ *ptr = (*ptr & ~0x3f) | ((*ptr - val) & 0x3f);
325+ return;
296326
297327 case R_RISCV_32_PCREL:
298328 case R_RISCV_COPY: