Skip to contentSkip to conversation

nios2: ksyms: Export __divsi3_table

PATCH In review Sasha Levin 2 participants 2 messages Oct 26 – Oct 27 NIOS2 architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nios2: ksyms: Export __divsi3_table

lib/lz4 is built with -O3, and at -O3 GCC enables -mfast-sw-div, which expands divisions by small numbers using __divsi3_table, a lookup table in libgcc. Without CONFIG_NIOS2_HW_DIV_SUPPORT that leaves lz4_compress.ko with a reference modpost cannot resolve:

ERROR: modpost: lib/lz4/lz4_compress.ko: symbol '__divsi3_table' undefined!

libgcc is linked into vmlinux, so built-in code finds the table, but it is not exported to modules. Export it next to __divsi3.

The error predates commit 2180d11e06fb ("nios2: ksyms: Declare __mulsi3 export"), which only made it visible: before that commit, modpost used up its ten unresolved symbol reports on __mulsi3 and suppressed the rest.

---
 arch/nios2/kernel/nios2_ksyms.c | 1 +
 1 file changed, 1 insertion(+)
arch/nios2/kernel/nios2_ksyms.c +1 -0
index e8710a269b398..b7152258430a6 100644
@@ -31,6 +31,7 @@ EXPORT_SYMBOL(flush_icache_range);
 
 DECLARE_EXPORT(__gcc_bcmp);
 DECLARE_EXPORT(__divsi3);
+DECLARE_EXPORT(__divsi3_table);
 DECLARE_EXPORT(__moddi3);
 DECLARE_EXPORT(__modsi3);
 DECLARE_EXPORT(__udivmoddi4);

base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e

Signature · 1 line
2.53.0
#1 lore raw
Quoted 14 lines · Sasha Levin

lib/lz4 is built with -O3, and at -O3 GCC enables -mfast-sw-div, which expands divisions by small numbers using __divsi3_table, a lookup table in libgcc. Without CONFIG_NIOS2_HW_DIV_SUPPORT that leaves lz4_compress.ko with a reference modpost cannot resolve:

ERROR: modpost: lib/lz4/lz4_compress.ko: symbol '__divsi3_table' undefined!

libgcc is linked into vmlinux, so built-in code finds the table, but it is not exported to modules. Export it next to __divsi3.

The error predates commit 2180d11e06fb ("nios2: ksyms: Declare __mulsi3 export"), which only made it visible: before that commit, modpost used up its ten unresolved symbol reports on __mulsi3 and suppressed the rest.

Quoted 5 lines
Fixes 2fc8483fdcde ("nios2: Build infrastructure")

Closes:
https://lore.kernel.org/oe-kbuild-all/[email protected]/

I hope we can address this using a copy of libgcc like the other architectures:

https://lore.kernel.org/lkml/20261020123149.cyjzz4uo25oiiu2m@dev-vm-schuster/

Your patch is otherwise correct of course, but it may end up clashing with the other fix.

Arnd