Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kbuild: Remove 'kmod_' prefix from __KBUILD_MODNAME

In preparation for the objtool klp diff subcommand, remove the arbitrary
'kmod_' prefix from __KBUILD_MODNAME and instead add it explicitly in
the __initcall_id() macro.

This change supports the standardization of "unique" symbol naming by
ensuring the non-unique portion of the name comes before the unique
part. That will enable objtool to properly correlate symbols across
builds.

Cc: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Petr Mladek <pmladek@suse.com>
Tested-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

+3 -2
+2 -1
include/linux/init.h
··· 200 200 201 201 /* Format: <modname>__<counter>_<line>_<fn> */ 202 202 #define __initcall_id(fn) \ 203 + __PASTE(kmod_, \ 203 204 __PASTE(__KBUILD_MODNAME, \ 204 205 __PASTE(__, \ 205 206 __PASTE(__COUNTER__, \ 206 207 __PASTE(_, \ 207 208 __PASTE(__LINE__, \ 208 - __PASTE(_, fn)))))) 209 + __PASTE(_, fn))))))) 209 210 210 211 /* Format: __<prefix>__<iid><id> */ 211 212 #define __initcall_name(prefix, __iid, id) \
+1 -1
scripts/Makefile.lib
··· 20 20 name-fix = $(call stringify,$(call name-fix-token,$1)) 21 21 basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) 22 22 modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) \ 23 - -D__KBUILD_MODNAME=kmod_$(call name-fix-token,$(modname)) 23 + -D__KBUILD_MODNAME=$(call name-fix-token,$(modname)) 24 24 modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile)) 25 25 26 26 _c_flags = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), \