lto: Handle LTO common symbols in module loader
authorJoe Mario <jmario@redhat.com>
Sat, 8 Feb 2014 08:01:09 +0000 (09:01 +0100)
committerH. Peter Anvin <hpa@linux.intel.com>
Fri, 14 Feb 2014 04:24:50 +0000 (20:24 -0800)
Here is the workaround I made for having the kernel not reject modules
built with -flto.  The clean solution would be to get the compiler to not
emit the symbol.  Or if it has to emit the symbol, then emit it as
initialized data but put it into a comdat/linkonce section.

Minor tweaks by AK over Joe's patch.

Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Link: http://lkml.kernel.org/r/1391846481-31491-5-git-send-email-ak@linux.intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
kernel/module.c

index d24fcf29cb64c16029857a89dbcdeaa1ef9d724a..b99e80119eef85469cf666cfa063f83ad9053280 100644 (file)
@@ -1948,6 +1948,10 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
 
                switch (sym[i].st_shndx) {
                case SHN_COMMON:
+                       /* Ignore common symbols */
+                       if (!strncmp(name, "__gnu_lto", 9))
+                               break;
+
                        /* We compiled with -fno-common.  These are not
                           supposed to happen.  */
                        pr_debug("Common symbol: %s\n", name);