Various information about modules is compiled into the info sections. For that a dedicated .mod.c file is generated by modpost for each module and then linked into the module. However most of the information in the .mod.c is the same for all modules, internal and external. Split the shared information into a dedicated source file that is compiled once and then linked into all modules. This avoids frequent rebuilds for all .mod.c files when using CONFIG_LOCALVERSION_AUTO because the local version ends up in .mod.c through UTS_RELEASE and VERMAGIC_STRING. The modules are still relinked in this case. The code is also easier to maintain as it's now in a proper source file instead of an inline string literal.
Showing the changes to scripts/mod (1 of 3 files). Show all
Unified · Split
| @@ -1755,26 +1755,9 @@ static void check_modname_len(struct module *mod) · 1754 unmodified lines | |||
| 1755 | static void add_header(struct buffer *b, struct module *mod) | 1755 | static void add_header(struct buffer *b, struct module *mod) |
| 1756 | { | 1756 | { |
| 1757 | buf_printf(b, "#include <linux/module.h>\n"); | 1757 | buf_printf(b, "#include <linux/module.h>\n"); |
| 1758 | /* | ||
| 1759 | * Include build-salt.h after module.h in order to | ||
| 1760 | * inherit the definitions. | ||
| 1761 | */ | ||
| 1762 | buf_printf(b, "#define INCLUDE_VERMAGIC\n"); | ||
| 1763 | buf_printf(b, "#include <linux/build-salt.h>\n"); | ||
| 1764 | buf_printf(b, "#include <linux/elfnote-lto.h>\n"); | ||
| 1765 | buf_printf(b, "#include <linux/export-internal.h>\n"); | 1758 | buf_printf(b, "#include <linux/export-internal.h>\n"); |
| 1766 | buf_printf(b, "#include <linux/vermagic.h>\n"); | ||
| 1767 | buf_printf(b, "#include <linux/compiler.h>\n"); | 1759 | buf_printf(b, "#include <linux/compiler.h>\n"); |
| 1768 | buf_printf(b, "\n"); | 1760 | buf_printf(b, "\n"); |
| 1769 | buf_printf(b, "#ifdef CONFIG_UNWINDER_ORC\n"); | ||
| 1770 | buf_printf(b, "#include <asm/orc_header.h>\n"); | ||
| 1771 | buf_printf(b, "ORC_HEADER;\n"); | ||
| 1772 | buf_printf(b, "#endif\n"); | ||
| 1773 | buf_printf(b, "\n"); | ||
| 1774 | buf_printf(b, "BUILD_SALT;\n"); | ||
| 1775 | buf_printf(b, "BUILD_LTO_INFO;\n"); | ||
| 1776 | buf_printf(b, "\n"); | ||
| 1777 | buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n"); | ||
| 1778 | buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n"); | 1761 | buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n"); |
| 1779 | buf_printf(b, "\n"); | 1762 | buf_printf(b, "\n"); |
| 1780 | buf_printf(b, "__visible struct module __this_module\n"); | 1763 | buf_printf(b, "__visible struct module __this_module\n"); |
| @@ -1792,12 +1775,6 @@ static void add_header(struct buffer *b, struct module *mod) · 11 unmodified lines | |||
| 1792 | if (!external_module) | 1775 | if (!external_module) |
| 1793 | buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n"); | 1776 | buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n"); |
| 1794 | 1777 | ||
| 1795 | buf_printf(b, | ||
| 1796 | "\n" | ||
| 1797 | "#ifdef CONFIG_MITIGATION_RETPOLINE\n" | ||
| 1798 | "MODULE_INFO(retpoline, \"Y\");\n" | ||
| 1799 | "#endif\n"); | ||
| 1800 | |||
| 1801 | if (strstarts(mod->name, "drivers/staging")) | 1778 | if (strstarts(mod->name, "drivers/staging")) |
| 1802 | buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n"); | 1779 | buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n"); |
| 1803 | 1780 | ||