[Git][ghc/ghc][wip/supersven/riscv64-ncg] 3 commits: Linker: Fix R_RISCV_SET8

Sven Tennie (@supersven) gitlab at gitlab.haskell.org
Sun Feb 11 15:08:52 UTC 2024



Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC


Commits:
611435bd by Sven Tennie at 2024-02-11T16:06:30+01:00
Linker: Fix R_RISCV_SET8

- - - - -
bd109a09 by Sven Tennie at 2024-02-11T16:07:32+01:00
Linker: Fix U-Type assertion

Instructions are 32 bits wide in RISCV(64).

- - - - -
2632c35c by Sven Tennie at 2024-02-11T16:08:18+01:00
Linker: Delete unused variable

- - - - -


1 changed file:

- rts/linker/elf_reloc_riscv64.c


Changes:

=====================================
rts/linker/elf_reloc_riscv64.c
=====================================
@@ -88,7 +88,7 @@ uint32_t setLO12_S(uint32_t insn, uint32_t imm) {
 }
 
 void setUType(inst_t *loc, uint32_t val) {
-  const unsigned bits = 64;
+  const unsigned bits = 32;
   uint64_t hi = val + 0x800;
   checkInt(loc, SignExtend64(hi, bits) >> 12, 20);
   write32le(loc, (read32le(loc) & 0xFFF) | (hi & 0xFFFFF000));
@@ -163,7 +163,6 @@ void setCJType(cinst_t *loc, uint32_t val) {
 
 bool encodeAddendRISCV64(Section *section, Elf_Rel *rel, int64_t addend) {
   addr_t P = (addr_t)((uint8_t *)section->start + rel->r_offset);
-  int exp_shift = -1;
   switch (ELF64_R_TYPE(rel->r_info)) {
   case R_RISCV_32_PCREL:
   case R_RISCV_32:
@@ -242,7 +241,7 @@ bool encodeAddendRISCV64(Section *section, Elf_Rel *rel, int64_t addend) {
     break;
   }
   case R_RISCV_SET8:
-    write8le((uint8_t *)P, read8le((uint8_t *)P) - addend);
+    write8le((uint8_t *)P, addend);
     break;
   case R_RISCV_SET16:
     write16le((cinst_t *)P, addend);



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/14ad1df38ae3077aea1cb58c785349cba5c7e128...2632c35cf73f9889603ed6adb0c0599bfb2d1887

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/14ad1df38ae3077aea1cb58c785349cba5c7e128...2632c35cf73f9889603ed6adb0c0599bfb2d1887
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240211/38cc5223/attachment-0001.html>


More information about the ghc-commits mailing list