Skip to content

Commit f3304ec

Browse files
committed
linux/export: use inline assembler to populate symbol CRCs
Since commit 7b45371 ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS"), the module versioning on the (non-upstreamed-yet) kvx Linux port is broken due to unexpected padding for __crc_* symbols. The kvx GCC adds padding so u32 gets 8-byte alignment instead of 4. I do not know if this happens for upstream architectures in general, but any compiler has the freedom to insert padding for faster access. Use the inline assembler to directly specify the wanted data layout. This is how we previously did before the breakage. Link: https://lore.kernel.org/lkml/[email protected]/ Link: https://lore.kernel.org/linux-kbuild/[email protected]/ Fixes: 7b45371 ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS") Reported-by: Yann Sionneau <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> Tested-by: Yann Sionneau <[email protected]>
1 parent 9ec6ab6 commit f3304ec

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

include/linux/export-internal.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
#include <linux/compiler.h>
1111
#include <linux/types.h>
1212

13-
/* __used is needed to keep __crc_* for LTO */
1413
#define SYMBOL_CRC(sym, crc, sec) \
15-
u32 __section("___kcrctab" sec "+" #sym) __used __crc_##sym = crc
14+
asm(".section \"___kcrctab" sec "+" #sym "\",\"a\"" "\n" \
15+
"__crc_" #sym ":" "\n" \
16+
".long " #crc "\n" \
17+
".previous" "\n")
1618

1719
#endif /* __LINUX_EXPORT_INTERNAL_H__ */

0 commit comments

Comments
 (0)