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.

scripts: Fix the inclusion order in modpost

In the process of creating the source file of a module modpost injects a
set of includes that are not required if the compilation unit is
statically built into the kernel.

The order of inclusion of the headers can cause redefinition problems
(e.g.):

In file included from include/linux/elf.h:5:0,
from include/linux/module.h:18,
from crypto/arc4.mod.c:2:
#define ELF_OSABI ELFOSABI_LINUX

In file included from include/linux/elfnote.h:62:0,
from include/linux/build-salt.h:4,
from crypto/arc4.mod.c:1:
include/uapi/linux/elf.h:363:0: note: this is the location of
the previous definition
#define ELF_OSABI ELFOSABI_NONE

The issue was exposed during the development of the series [1].

[1] https://lore.kernel.org/lkml/20200306133242.26279-1-vincenzo.frascino@arm.com/

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Michal Marek <michal.lkml@markovi.net>
Link: https://lkml.kernel.org/r/20200320145351.32292-17-vincenzo.frascino@arm.com

authored by

Vincenzo Frascino and committed by
Thomas Gleixner
f58dd03b d8bb6993

+5 -1
+5 -1
scripts/mod/modpost.c
··· 2251 2251 **/ 2252 2252 static void add_header(struct buffer *b, struct module *mod) 2253 2253 { 2254 - buf_printf(b, "#include <linux/build-salt.h>\n"); 2255 2254 buf_printf(b, "#include <linux/module.h>\n"); 2255 + /* 2256 + * Include build-salt.h after module.h in order to 2257 + * inherit the definitions. 2258 + */ 2259 + buf_printf(b, "#include <linux/build-salt.h>\n"); 2256 2260 buf_printf(b, "#include <linux/vermagic.h>\n"); 2257 2261 buf_printf(b, "#include <linux/compiler.h>\n"); 2258 2262 buf_printf(b, "\n");