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
{{ message }}
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.
I am trying to write a minimal kernel driver based on this repo (without the bindgen) and I encountered some issue:
On recent kernel version, apparently you can't link a .a, so helloworld-objs := target/$(TARGET)/$(BUILD)/libhello_world.a does not work. I got a workaround by extracting the .o files with ar -x foo.a and linking the .o files into a single .o like this: ld -relocatable *.o -o final.o. It is this object that replaces the .a in the makefile.
The object files corresponding with libcore and family (all except the hello-*.o one) contain relocations of type R_X86_64_GOTPCREL. I don't know if this happened on older versions of rust, I use the most recent one as of today, which is rustc 1.53.0-nightly. These relocs end up in the .o amalgamation (final.o) and eventually in the resulting .ko module. The kernel is not able to resolve these relocations when it loads the module, failing withmodule: 8888: Unknown rela relocation: 9. 9 is the type of relocation mentioned above. I tried playing with the settings in the JSON target configuration, I tried changing the relocation model, adding -fplt to the pre-link gcc options and adding the "needs-plt": true. They seem to have no effect. The object file corresponding with the driver crate has a PLT and no GOTPCREL relocations invariantly, which is what I want, but the libcore objects contain those kind of relocations, which end up in the final module and make it unloadable by the kernel.
I would appreciate any help in this regard and it could lead eventually to make this repo work with recent versions of the kernel and rust.
Hi, thank you for this repository.
I am trying to write a minimal kernel driver based on this repo (without the bindgen) and I encountered some issue:
helloworld-objs := target/$(TARGET)/$(BUILD)/libhello_world.a
does not work. I got a workaround by extracting the .o files withar -x foo.a
and linking the .o files into a single .o like this:ld -relocatable *.o -o final.o
. It is this object that replaces the .a in the makefile.hello-*.o
one) contain relocations of typeR_X86_64_GOTPCREL
. I don't know if this happened on older versions of rust, I use the most recent one as of today, which isrustc 1.53.0-nightly
. These relocs end up in the .o amalgamation (final.o
) and eventually in the resulting.ko
module. The kernel is not able to resolve these relocations when it loads the module, failing withmodule: 8888: Unknown rela relocation: 9
. 9 is the type of relocation mentioned above. I tried playing with the settings in the JSON target configuration, I tried changing the relocation model, adding-fplt
to the pre-link gcc options and adding the"needs-plt": true
. They seem to have no effect. The object file corresponding with the driver crate has a PLT and noGOTPCREL
relocations invariantly, which is what I want, but the libcore objects contain those kind of relocations, which end up in the final module and make it unloadable by the kernel.I would appreciate any help in this regard and it could lead eventually to make this repo work with recent versions of the kernel and rust.
Related links
fishinabarrel/linux-kernel-module-rust#173
https://users.rust-lang.org/t/how-can-i-enable-plt-in-a-custom-target/57332
https://internals.rust-lang.org/t/function-calls-plt-vs-gotpcrel/8909
The text was updated successfully, but these errors were encountered: