[RFC PATCH V3 14/43] rv64ilp32_abi: riscv: Adapt kernel module code

guoren
2025-03-25T12:20:06Z

Because riscv_insn_valid_32bit_offset is always true for ILP32,
use BITS_PER_LONG instead of CONFIG_64BIT.

Signed-off-by: Guo Ren (Alibaba DAMO Academy) <guoren@kernel.org>
---
arch/riscv/kernel/module.c | 2 +-
include/asm-generic/module.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
index 47d0ebeec93c..d7360878e618 100644
--- a/arch/riscv/kernel/module.c
+++ b/arch/riscv/kernel/module.c
@@ -45,7 +45,7 @@ struct relocation_handlers {
*/
static bool riscv_insn_valid_32bit_offset(ptrdiff_t val)
{
-#ifdef CONFIG_32BIT
+#if BITS_PER_LONG == 32
return true;
#else
return (-(1L << 31) - (1L << 11)) <= val && val < ((1L << 31) - (1L << 11));
diff --git a/include/asm-generic/module.h b/include/asm-generic/module.h
index 98e1541b72b7..f870171b14a8 100644
--- a/include/asm-generic/module.h
+++ b/include/asm-generic/module.h
@@ -12,7 +12,7 @@ struct mod_arch_specific
};
#endif

-#ifdef CONFIG_64BIT
+#if BITS_PER_LONG == 64
#define Elf_Shdr Elf64_Shdr
#define Elf_Phdr Elf64_Phdr
#define Elf_Sym Elf64_Sym
--
2.40.1