Skip to content

Commit 258f742

Browse files
Frank Rowandtorvalds
authored andcommitted
modpost: Fix modpost license checking of vmlinux.o
Commit f02e8a6 ("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 62a2635 ("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>
1 parent 83dbbdb commit 258f742

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎scripts/mod/modpost.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,10 @@ static struct module *new_module(char *modname)
132132
/* strip trailing .o */
133133
s = strrchr(p, '.');
134134
if (s != NULL)
135-
if (strcmp(s, ".o") == 0)
135+
if (strcmp(s, ".o") == 0) {
136136
*s = '\0';
137+
mod->is_dot_o = 1;
138+
}
137139

138140
/* add to list */
139141
mod->name = p;
@@ -587,7 +589,8 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
587589
unsigned int crc;
588590
enum export export;
589591

590-
if (!is_vmlinux(mod->name) && strncmp(symname, "__ksymtab", 9) == 0)
592+
if ((!is_vmlinux(mod->name) || mod->is_dot_o) &&
593+
strncmp(symname, "__ksymtab", 9) == 0)
591594
export = export_from_secname(info, get_secindex(info, sym));
592595
else
593596
export = export_from_sec(info, get_secindex(info, sym));

‎scripts/mod/modpost.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ struct module {
113113
int has_cleanup;
114114
struct buffer dev_table_buf;
115115
char srcversion[25];
116+
int is_dot_o;
116117
};
117118

118119
struct elf_info {

0 commit comments

Comments
 (0)