diff options
author | Sami Tolvanen <samitolvanen@google.com> | 2020-12-11 21:46:27 +0300 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2021-01-14 19:21:09 +0300 |
commit | 7ac204b545f263c7595a8b5ec3797ae9f9954f82 (patch) | |
tree | 30f8fa6ccf3da68844968f83751dd7f2a7a1ff66 /scripts/mod/modpost.c | |
parent | 09a4e4d9c52a3c5e39e4f409b2c083ab13c6afc2 (diff) | |
download | linux-7ac204b545f263c7595a8b5ec3797ae9f9954f82.tar.xz |
modpost: lto: strip .lto from module names
With LTO, everything is compiled into LLVM bitcode, so we have to link
each module into native code before modpost. Kbuild uses the .lto.o
suffix for these files, which also ends up in module information. This
change strips the unnecessary .lto suffix from the module name.
Suggested-by: Bill Wendling <morbo@google.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20201211184633.3213045-11-samitolvanen@google.com
Diffstat (limited to 'scripts/mod/modpost.c')
-rw-r--r-- | scripts/mod/modpost.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index d6c81657d695..be0642126f53 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -17,7 +17,6 @@ #include <ctype.h> #include <string.h> #include <limits.h> -#include <stdbool.h> #include <errno.h> #include "modpost.h" #include "../../include/linux/license.h" @@ -84,14 +83,6 @@ modpost_log(enum loglevel loglevel, const char *fmt, ...) error_occurred = true; } -static inline bool strends(const char *str, const char *postfix) -{ - if (strlen(str) < strlen(postfix)) - return false; - - return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0; -} - void *do_nofail(void *ptr, const char *expr) { if (!ptr) @@ -1988,6 +1979,10 @@ static char *remove_dot(char *s) size_t m = strspn(s + n + 1, "0123456789"); if (m && (s[n + m] == '.' || s[n + m] == 0)) s[n] = 0; + + /* strip trailing .lto */ + if (strends(s, ".lto")) + s[strlen(s) - 4] = '\0'; } return s; } @@ -2011,6 +2006,9 @@ static void read_symbols(const char *modname) /* strip trailing .o */ tmp = NOFAIL(strdup(modname)); tmp[strlen(tmp) - 2] = '\0'; + /* strip trailing .lto */ + if (strends(tmp, ".lto")) + tmp[strlen(tmp) - 4] = '\0'; mod = new_module(tmp); free(tmp); } |