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

Configure Feed

Select the types of activity you want to include in your feed.

modpost: Produce extended MODVERSIONS information

Generate both the existing modversions format and the new extended one
when running modpost. Presence of this metadata in the final .ko is
guarded by CONFIG_EXTENDED_MODVERSIONS.

We no longer generate an error on long symbols in modpost if
CONFIG_EXTENDED_MODVERSIONS is set, as they can now be appropriately
encoded in the extended section. These symbols will be skipped in the
previous encoding. An error will still be generated if
CONFIG_EXTENDED_MODVERSIONS is not set.

Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Matthew Maurer <mmaurer@google.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

authored by

Matthew Maurer and committed by
Masahiro Yamada
fc7d5e32 54ac1ac8

+69 -4
+10
kernel/module/Kconfig
··· 207 207 assembly. This can be enabled only when the target architecture 208 208 supports it. 209 209 210 + config EXTENDED_MODVERSIONS 211 + bool "Extended Module Versioning Support" 212 + depends on MODVERSIONS 213 + help 214 + This enables extended MODVERSIONs support, allowing long symbol 215 + names to be versioned. 216 + 217 + The most likely reason you would enable this is to enable Rust 218 + support. If unsure, say N. 219 + 210 220 config MODULE_SRCVERSION_ALL 211 221 bool "Source checksum for all modules" 212 222 help
+1
scripts/Makefile.modpost
··· 43 43 modpost-args = \ 44 44 $(if $(CONFIG_MODULES),-M) \ 45 45 $(if $(CONFIG_MODVERSIONS),-m) \ 46 + $(if $(CONFIG_EXTENDED_MODVERSIONS),-x) \ 46 47 $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ 47 48 $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ 48 49 $(if $(KBUILD_MODPOST_WARN),-w) \
+58 -4
scripts/mod/modpost.c
··· 33 33 static bool modversions; 34 34 /* Is CONFIG_MODULE_SRCVERSION_ALL set? */ 35 35 static bool all_versions; 36 + /* Is CONFIG_EXTENDED_MODVERSIONS set? */ 37 + static bool extended_modversions; 36 38 /* If we are modposting external module set to 1 */ 37 39 static bool external_module; 38 40 /* Only warn about unresolved symbols */ ··· 1808 1806 } 1809 1807 1810 1808 /** 1809 + * Record CRCs for unresolved symbols, supporting long names 1810 + */ 1811 + static void add_extended_versions(struct buffer *b, struct module *mod) 1812 + { 1813 + struct symbol *s; 1814 + 1815 + if (!extended_modversions) 1816 + return; 1817 + 1818 + buf_printf(b, "\n"); 1819 + buf_printf(b, "static const u32 ____version_ext_crcs[]\n"); 1820 + buf_printf(b, "__used __section(\"__version_ext_crcs\") = {\n"); 1821 + list_for_each_entry(s, &mod->unresolved_symbols, list) { 1822 + if (!s->module) 1823 + continue; 1824 + if (!s->crc_valid) { 1825 + warn("\"%s\" [%s.ko] has no CRC!\n", 1826 + s->name, mod->name); 1827 + continue; 1828 + } 1829 + buf_printf(b, "\t0x%08x,\n", s->crc); 1830 + } 1831 + buf_printf(b, "};\n"); 1832 + 1833 + buf_printf(b, "static const char ____version_ext_names[]\n"); 1834 + buf_printf(b, "__used __section(\"__version_ext_names\") =\n"); 1835 + list_for_each_entry(s, &mod->unresolved_symbols, list) { 1836 + if (!s->module) 1837 + continue; 1838 + if (!s->crc_valid) 1839 + /* 1840 + * We already warned on this when producing the crc 1841 + * table. 1842 + * We need to skip its name too, as the indexes in 1843 + * both tables need to align. 1844 + */ 1845 + continue; 1846 + buf_printf(b, "\t\"%s\\0\"\n", s->name); 1847 + } 1848 + buf_printf(b, ";\n"); 1849 + } 1850 + 1851 + /** 1811 1852 * Record CRCs for unresolved symbols 1812 1853 **/ 1813 1854 static void add_versions(struct buffer *b, struct module *mod) ··· 1873 1828 continue; 1874 1829 } 1875 1830 if (strlen(s->name) >= MODULE_NAME_LEN) { 1876 - error("too long symbol \"%s\" [%s.ko]\n", 1877 - s->name, mod->name); 1878 - break; 1831 + if (extended_modversions) { 1832 + /* this symbol will only be in the extended info */ 1833 + continue; 1834 + } else { 1835 + error("too long symbol \"%s\" [%s.ko]\n", 1836 + s->name, mod->name); 1837 + break; 1838 + } 1879 1839 } 1880 1840 buf_printf(b, "\t{ 0x%08x, \"%s\" },\n", 1881 1841 s->crc, s->name); ··· 2011 1961 add_header(&buf, mod); 2012 1962 add_exported_symbols(&buf, mod); 2013 1963 add_versions(&buf, mod); 1964 + add_extended_versions(&buf, mod); 2014 1965 add_depends(&buf, mod); 2015 1966 2016 1967 buf_printf(&buf, "\n"); ··· 2177 2126 LIST_HEAD(dump_lists); 2178 2127 struct dump_list *dl, *dl2; 2179 2128 2180 - while ((opt = getopt(argc, argv, "ei:MmnT:to:au:WwENd:")) != -1) { 2129 + while ((opt = getopt(argc, argv, "ei:MmnT:to:au:WwENd:x")) != -1) { 2181 2130 switch (opt) { 2182 2131 case 'e': 2183 2132 external_module = true; ··· 2225 2174 break; 2226 2175 case 'd': 2227 2176 missing_namespace_deps = optarg; 2177 + break; 2178 + case 'x': 2179 + extended_modversions = true; 2228 2180 break; 2229 2181 default: 2230 2182 exit(1);