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

modpost: Fix modpost license checking of vmlinux.o

Commit f02e8a6596b7 ("module: Sort exported symbols") sorts symbols
placing each of them in its own elf section. This sorting and merging
into the canonical sections are done by the linker.

Unfortunately modpost to generate Module.symvers file parses vmlinux.o
(which is not linked yet) and all modules object files (which aren't
linked yet). These aren't sanitized by the linker yet. That breaks
modpost that can't detect license properly for modules.

This patch makes modpost aware of the new exported symbols structure.

[ This above is a slightly corrected version of the explanation of the
problem, copied from commit 62a2635610db ("modpost: Fix modpost's
license checking V3"). That commit fixed the problem for module
object files, but not for vmlinux.o. This patch fixes modpost for
vmlinux.o. ]

Signed-off-by: Frank Rowand <frank.rowand@am.sony.com>
Signed-off-by: Alessio Igor Bogani <abogani@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Frank Rowand and committed by
Linus Torvalds
258f7426 83dbbdbb

+6 -2
+5 -2
scripts/mod/modpost.c
··· 132 132 /* strip trailing .o */ 133 133 s = strrchr(p, '.'); 134 134 if (s != NULL) 135 - if (strcmp(s, ".o") == 0) 135 + if (strcmp(s, ".o") == 0) { 136 136 *s = '\0'; 137 + mod->is_dot_o = 1; 138 + } 137 139 138 140 /* add to list */ 139 141 mod->name = p; ··· 589 587 unsigned int crc; 590 588 enum export export; 591 589 592 - if (!is_vmlinux(mod->name) && strncmp(symname, "__ksymtab", 9) == 0) 590 + if ((!is_vmlinux(mod->name) || mod->is_dot_o) && 591 + strncmp(symname, "__ksymtab", 9) == 0) 593 592 export = export_from_secname(info, get_secindex(info, sym)); 594 593 else 595 594 export = export_from_sec(info, get_secindex(info, sym));
+1
scripts/mod/modpost.h
··· 113 113 int has_cleanup; 114 114 struct buffer dev_table_buf; 115 115 char srcversion[25]; 116 + int is_dot_o; 116 117 }; 117 118 118 119 struct elf_info {