Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 258f7426 authored by Frank Rowand's avatar Frank Rowand Committed by Linus Torvalds
Browse files

modpost: Fix modpost license checking of vmlinux.o



Commit f02e8a65 ("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 62a26356 ("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: default avatarFrank Rowand <frank.rowand@am.sony.com>
Signed-off-by: default avatarAlessio Igor Bogani <abogani@kernel.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 83dbbdbb
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -132,8 +132,10 @@ static struct module *new_module(char *modname)
	/* strip trailing .o */
	/* strip trailing .o */
	s = strrchr(p, '.');
	s = strrchr(p, '.');
	if (s != NULL)
	if (s != NULL)
		if (strcmp(s, ".o") == 0)
		if (strcmp(s, ".o") == 0) {
			*s = '\0';
			*s = '\0';
			mod->is_dot_o = 1;
		}


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


	if (!is_vmlinux(mod->name) && strncmp(symname, "__ksymtab", 9) == 0)
	if ((!is_vmlinux(mod->name) || mod->is_dot_o) &&
	    strncmp(symname, "__ksymtab", 9) == 0)
		export = export_from_secname(info, get_secindex(info, sym));
		export = export_from_secname(info, get_secindex(info, sym));
	else
	else
		export = export_from_sec(info, get_secindex(info, sym));
		export = export_from_sec(info, get_secindex(info, sym));
+1 −0
Original line number Original line Diff line number Diff line
@@ -113,6 +113,7 @@ struct module {
	int has_cleanup;
	int has_cleanup;
	struct buffer dev_table_buf;
	struct buffer dev_table_buf;
	char	     srcversion[25];
	char	     srcversion[25];
	int is_dot_o;
};
};


struct elf_info {
struct elf_info {