openrisc: Add support for more module relocations
authorStafford Horne <shorne@gmail.com>
Thu, 11 Apr 2024 16:23:25 +0000 (17:23 +0100)
committerStafford Horne <shorne@gmail.com>
Mon, 15 Apr 2024 14:20:39 +0000 (15:20 +0100)
When testing modules in OpenRISC I found R_OR1K_AHI16 (signed adjusted
high 16-bit) and R_OR1K_SLO16 (split low 16-bit) relocations are used in
modules but not implemented yet.

This patch implements the relocations. I have tested with a few modules.

Signed-off-by: Stafford Horne <shorne@gmail.com>
arch/openrisc/kernel/module.c

index 292f0afe27b98eacf8435483f580ce3edbf6df3f..c9ff4c4a0b29ba01ffd75515ab60d890eede1d7a 100644 (file)
@@ -55,6 +55,16 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
                        value |= *location & 0xfc000000;
                        *location = value;
                        break;
+               case R_OR1K_AHI16:
+                       /* Adjust the operand to match with a signed LO16.  */
+                       value += 0x8000;
+                       *((uint16_t *)location + 1) = value >> 16;
+                       break;
+               case R_OR1K_SLO16:
+                       /* Split value lower 16-bits.  */
+                       value = ((value & 0xf800) << 10) | (value & 0x7ff);
+                       *location = (*location & ~0x3e007ff) | value;
+                       break;
                default:
                        pr_err("module %s: Unknown relocation: %u\n",
                               me->name, ELF32_R_TYPE(rel[i].r_info));