Changeset View
Changeset View
Standalone View
Standalone View
sys/riscv/riscv/elf_machdep.c
| Show First 20 Lines • Show All 265 Lines • ▼ Show 20 Lines | for (i = 0; i < sizeof(t2s) / sizeof(t2s[0]); ++i) { | ||||
| if (type == t2s[i].type) | if (type == t2s[i].type) | ||||
| return t2s[i].str; | return t2s[i].str; | ||||
| } | } | ||||
| return "*unknown*"; | return "*unknown*"; | ||||
| } | } | ||||
| bool | bool | ||||
| elf_is_ifunc_reloc(Elf_Size r_info __unused) | elf_is_ifunc_reloc(Elf_Size r_info) | ||||
| { | { | ||||
| return (false); | return (ELF_R_TYPE(r_info) == R_RISCV_IRELATIVE); | ||||
| } | } | ||||
| /* | /* | ||||
| * Currently kernel loadable module for RISCV is compiled with -fPIC option. | * Currently kernel loadable module for RISCV is compiled with -fPIC option. | ||||
| * (see also additional CFLAGS definition for RISCV in sys/conf/kmod.mk) | * (see also additional CFLAGS definition for RISCV in sys/conf/kmod.mk) | ||||
| * Only R_RISCV_64, R_RISCV_JUMP_SLOT and RISCV_RELATIVE are emitted in | * Only R_RISCV_64, R_RISCV_JUMP_SLOT and RISCV_RELATIVE are emitted in | ||||
| * the module. Other relocations will be processed when kernel loadable | * the module. Other relocations will be processed when kernel loadable | ||||
| * modules are built in non-PIC. | * modules are built in non-PIC. | ||||
| ▲ Show 20 Lines • Show All 210 Lines • ▼ Show 20 Lines | case R_RISCV_LO12_S: | ||||
| before32 = *insn32p; | before32 = *insn32p; | ||||
| *insn32p = insert_imm(*insn32p, addr, 11, 5, 25); | *insn32p = insert_imm(*insn32p, addr, 11, 5, 25); | ||||
| *insn32p = insert_imm(*insn32p, addr, 4, 0, 7); | *insn32p = insert_imm(*insn32p, addr, 4, 0, 7); | ||||
| if (debug_kld) | if (debug_kld) | ||||
| printf("%p %c %-24s %08x -> %08x\n", where, | printf("%p %c %-24s %08x -> %08x\n", where, | ||||
| (local ? 'l' : 'g'), reloctype_to_str(rtype), | (local ? 'l' : 'g'), reloctype_to_str(rtype), | ||||
| before32, *insn32p); | before32, *insn32p); | ||||
| break; | break; | ||||
| case R_RISCV_IRELATIVE: | |||||
| addr = relocbase + addend; | |||||
| val = ((Elf64_Addr (*)(void))addr)(); | |||||
jrtc27: Should we not be passing hwcap and 0s like userspace? Otherwise any use of DEFINE_UIFUNC will… | |||||
mhorneAuthorUnsubmitted Done Inline ActionsFrom my understanding, DEFINE_UIFUNC should not be used in the kernel. mhorne: From my understanding, DEFINE_UIFUNC should not be used in the kernel. | |||||
| if (*where != val) | |||||
| *where = val; | |||||
| break; | |||||
| default: | default: | ||||
| printf("kldload: unexpected relocation type %ld, " | printf("kldload: unexpected relocation type %ld, " | ||||
| "symbol index %ld\n", rtype, symidx); | "symbol index %ld\n", rtype, symidx); | ||||
| return (-1); | return (-1); | ||||
| } | } | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| Show All 37 Lines | |||||
Should we not be passing hwcap and 0s like userspace? Otherwise any use of DEFINE_UIFUNC will have junk in the registers.