From 061016a66950d6e717bd87e53b4b1e9685aaa249 Mon Sep 17 00:00:00 2001 From: Vincenzo Frascino Date: Fri, 20 Mar 2020 14:53:41 +0000 Subject: [PATCH] UPSTREAM: 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 Signed-off-by: Vincenzo Frascino Signed-off-by: Thomas Gleixner Cc: Masahiro Yamada Cc: Michal Marek Link: https://lkml.kernel.org/r/20200320145351.32292-17-vincenzo.frascino@arm.com (cherry picked from commit f58dd03b1157bdf3b64c36e9525f8d7f69c25df2) Signed-off-by: Mark Salyzyn Bug: 154668398 Change-Id: I4e1bd72315263f155f485431de5eb69824e2b398 --- scripts/mod/modpost.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index f9ab34811dbf..cc1b7ece676e 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2164,8 +2164,12 @@ static int check_modname_len(struct module *mod) **/ static void add_header(struct buffer *b, struct module *mod) { - buf_printf(b, "#include \n"); buf_printf(b, "#include \n"); + /* + * Include build-salt.h after module.h in order to + * inherit the definitions. + */ + buf_printf(b, "#include \n"); buf_printf(b, "#include \n"); buf_printf(b, "#include \n"); buf_printf(b, "\n");