Skip to content

Feature request: tunable for extern function definition ELF relocation type #57390

@jbaublitz

Description

@jbaublitz

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:

  1. Is this change recent?
  2. If so, was this a change on the Rust side or LLVM side?
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesO-linuxOperating system: Linux

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions