linux/export.h: make <linux/export.h> independent of CONFIG_MODULES

Currently, all files with EXPORT_SYMBOL() are rebuilt when CONFIG_MODULES
is flipped due to <linux/export.h> depending on CONFIG_MODULES.

Now that modpost can make a final decision about export symbols,
<linux/export.h> does not need to make EXPORT_SYMBOL() no-op.
Instead, modpost can skip emitting KSYMTAB when CONFIG_MODULES is unset.

This commit will reduce the number of recompilation when CONFIG_MODULES
is toggled.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
Masahiro Yamada 2023-07-16 19:15:54 +09:00
parent c40e60f00c
commit 481461f510
3 changed files with 9 additions and 4 deletions

View file

@ -50,7 +50,7 @@ extern struct module __this_module;
__EXPORT_SYMBOL_REF(sym) ASM_NL \ __EXPORT_SYMBOL_REF(sym) ASM_NL \
.previous .previous
#if !defined(CONFIG_MODULES) || defined(__DISABLE_EXPORTS) #if defined(__DISABLE_EXPORTS)
/* /*
* Allow symbol exports to be disabled completely so that C code may * Allow symbol exports to be disabled completely so that C code may
@ -75,7 +75,7 @@ extern struct module __this_module;
__ADDRESSABLE(sym) \ __ADDRESSABLE(sym) \
asm(__stringify(___EXPORT_SYMBOL(sym, license, ns))) asm(__stringify(___EXPORT_SYMBOL(sym, license, ns)))
#endif /* CONFIG_MODULES */ #endif
#ifdef DEFAULT_SYMBOL_NAMESPACE #ifdef DEFAULT_SYMBOL_NAMESPACE
#define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, __stringify(DEFAULT_SYMBOL_NAMESPACE)) #define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, __stringify(DEFAULT_SYMBOL_NAMESPACE))

View file

@ -41,6 +41,7 @@ include $(srctree)/scripts/Kbuild.include
MODPOST = scripts/mod/modpost MODPOST = scripts/mod/modpost
modpost-args = \ modpost-args = \
$(if $(CONFIG_MODULES),-M) \
$(if $(CONFIG_MODVERSIONS),-m) \ $(if $(CONFIG_MODVERSIONS),-m) \
$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \
$(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \

View file

@ -24,6 +24,7 @@
#include "../../include/linux/license.h" #include "../../include/linux/license.h"
#include "../../include/linux/module_symbol.h" #include "../../include/linux/module_symbol.h"
static bool module_enabled;
/* Are we using CONFIG_MODVERSIONS? */ /* Are we using CONFIG_MODVERSIONS? */
static bool modversions; static bool modversions;
/* Is CONFIG_MODULE_SRCVERSION_ALL set? */ /* Is CONFIG_MODULE_SRCVERSION_ALL set? */
@ -1242,7 +1243,7 @@ static void check_section_mismatch(struct module *mod, struct elf_info *elf,
const char *tosec = sec_name(elf, get_secindex(elf, sym)); const char *tosec = sec_name(elf, get_secindex(elf, sym));
const struct sectioncheck *mismatch; const struct sectioncheck *mismatch;
if (elf->export_symbol_secndx == fsecndx) { if (module_enabled && elf->export_symbol_secndx == fsecndx) {
check_export_symbol(mod, elf, faddr, tosec, sym); check_export_symbol(mod, elf, faddr, tosec, sym);
return; return;
} }
@ -2272,7 +2273,7 @@ int main(int argc, char **argv)
LIST_HEAD(dump_lists); LIST_HEAD(dump_lists);
struct dump_list *dl, *dl2; struct dump_list *dl, *dl2;
while ((opt = getopt(argc, argv, "ei:mnT:to:au:WwENd:")) != -1) { while ((opt = getopt(argc, argv, "ei:MmnT:to:au:WwENd:")) != -1) {
switch (opt) { switch (opt) {
case 'e': case 'e':
external_module = true; external_module = true;
@ -2282,6 +2283,9 @@ int main(int argc, char **argv)
dl->file = optarg; dl->file = optarg;
list_add_tail(&dl->list, &dump_lists); list_add_tail(&dl->list, &dump_lists);
break; break;
case 'M':
module_enabled = true;
break;
case 'm': case 'm':
modversions = true; modversions = true;
break; break;