This invention relates to a method for cross-version binary compatibility of
Linux kernel modules, belonging to the field of computer
operating system kernels. It includes the following steps: During the compilation phase, the
compiler identifies specific keywords (__kabi_reloc_member, __kabi_check_member, __kabi_sizeof) and records instruction offsets, type identifiers,
member variable name offsets, and
relocation types, generating a .kabi_relocs segment. During the loading phase, the
loader parses the .kabi_relocs segment, combines it with module BTF and kernel BTF information, and dynamically repairs instructions based on the
relocation type. This invention achieves "compile once, run anywhere" binary compatibility for kernel modules, with the repair operation completed at
load time, having no
impact on runtime performance.