You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a prototype of a toy Linux kernel module written in Rust. I previously had it working until recently when I rebuilt it with a newer version of Rust and LLVM and insmod module.ko started throwing an error in dmesg logs about unknown rela relocation 9. I did a readelf and realized that all of the extern "C" functions I'd declared were generating ELF entries with the R_X86_64_GOTPCREL relocation entry type which is defined as having a value of 9. This is apparently illegal for kernel modules after looking at the allowable ELF relocation types in the kernel module infrastructure.
I have a few questions:
Is this change recent?
If so, was this a change on the Rust side or LLVM side?
Would you be willing to work with me on either finding a linking-based solution (if possible) or a PR for tuning the resulting relocation type of extern-declared functions?
I am not sure if there's a simple linking flag I'm missing but the ones I've tested, as well as using any of the relocation strategies available through codegen options, yield the same results.
The text was updated successfully, but these errors were encountered:
Hey @jason-ni, thank you so much for your help! I was able to resolve this with the following options on newer Rust compilers: --crate-type=staticlib -C relocation-model=static -C code-model=kernel -Z plt=y. I'm gonna close this out.
I have a prototype of a toy Linux kernel module written in Rust. I previously had it working until recently when I rebuilt it with a newer version of Rust and LLVM and
insmod module.ko
started throwing an error in dmesg logs aboutunknown rela relocation 9
. I did areadelf
and realized that all of theextern "C"
functions I'd declared were generating ELF entries with theR_X86_64_GOTPCREL
relocation entry type which is defined as having a value of 9. This is apparently illegal for kernel modules after looking at the allowable ELF relocation types in the kernel module infrastructure.I have a few questions:
I am not sure if there's a simple linking flag I'm missing but the ones I've tested, as well as using any of the relocation strategies available through codegen options, yield the same results.
The text was updated successfully, but these errors were encountered: