Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp879254ybt; Wed, 24 Jun 2020 13:37:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwY1KnfEJUQoQKBBE6bIaZLWk+btN1UFZJcy5+R7gAROApx8VFlvIw8GnlarP8rj94/E1+f X-Received: by 2002:a17:906:4c48:: with SMTP id d8mr3907709ejw.331.1593031044828; Wed, 24 Jun 2020 13:37:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593031044; cv=none; d=google.com; s=arc-20160816; b=sqGaqcMK3Y51g963HpUNiiRAKhIW7HF4YURWqwBe2o/H9eGcNMRxLAOtcTRpWiBZye rKoJCjZq6kxqlnx7ZBwoCPi2oGmX7CE5n2hMBrcdgiqPsfIlwc5HfnFUhHcETOHqp+4Z DK3yBqFr/xFtg4+IaB1YqBERAQ2UiGBVD+x6xaUPpSgY2fciOvLjCmhQtRKawfZP+P4F P04x/E7WxuzAvOZpUkxpuZ++BiZhIeKrjjWDoqzFkdzh+7USo9IIjDZelGHjaP+/o9No 11jnfuyOCjfEVDOz+0Ouh0dIE7KoLRJmCuREqbn4IoXckREcAmDDDZvb+rsE9qHQ13XE q5TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=79pxKTlkNWyJf2vmlsIGe03zgp7TGuVtfyoMyMkArK8=; b=hwzOTs1qcO7wU2CnFDTzrcXJ9suAAc4k+0GMVMEHi9YMHXhZnnL69EUZQS1hQaWdws eTick0fTdhP5hFm4ra1JM25ta0CoKe75KhV0+nnjt3fDCZf3T3rc6G8IaGbm0ulNOOhL x01+qSQXw/QRhz6+aD01YQphZjtD9Y9ukyBtaA+fKsa7n4Ze3jcyuWP6hr3T9B8003gs Dc2f2UYB+FUp0FuHhyIePNAde5NTmrDn/WzuGhXVyHVlDyMT4QdKKpfyMPMHdyWWeFXf qo5+kDbh/Hn3d6Bq+BMLhq7ge34bfj3DKJzGafoSrro1Bc6RNOkRuHKrJmtjn1jBGFWS fWxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=btHNoJ4L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a1si3364789edb.90.2020.06.24.13.37.01; Wed, 24 Jun 2020 13:37:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=btHNoJ4L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406663AbgFXUeR (ORCPT + 99 others); Wed, 24 Jun 2020 16:34:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406516AbgFXUdV (ORCPT ); Wed, 24 Jun 2020 16:33:21 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87D5DC061798 for ; Wed, 24 Jun 2020 13:33:20 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id u93so2430362qtd.8 for ; Wed, 24 Jun 2020 13:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=79pxKTlkNWyJf2vmlsIGe03zgp7TGuVtfyoMyMkArK8=; b=btHNoJ4LCTKmKU6iX1nY/p97V+Ay3nMJGlrn7bXF/L/XPTDGtt58AsD3Mh0Aeg8xli i/d+HGMtV5Jn6jA8Cx1FqZSW6wKGv/sOjgspsd/CVSg+LkYGEeeEYLFxrYYGQ8I8QOWM Cf5JM3EZjmGV5qQFBgWfzxMp2Kdb9qPFRU+2kPmr0e4ZXejzdyDXKQQDGqzly1C9+syM lYUlij36WBcULQ7G2HzWI/6+G60YtbxUYFeFxnsxSan8nd8WAH4jUNFN9Tmd4BJJC3/J 4MhqOa97DkCrf9Gdui9rH2qj5BT7xXSCfX6fHqyZfik5WekbjJGEyd8PzAGt7HITNkeO mMPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=79pxKTlkNWyJf2vmlsIGe03zgp7TGuVtfyoMyMkArK8=; b=PbT0OR03LITs1r2481pji13N9ZFGz1877UCNCYKxxC4jJXhty2OIYlhifstr5vXTFQ DcK2M1Sb6+uNOAISNl9bDQCS9HzWr4CeWdnvNoAtQ3LTHyAFYCuqj21VcC6ld4zUs5a8 hG1JA+W0kI8VDME0430fTLyN8mUwu3inDze7V+aChr248H7z6qhd66ZSaE3ri6koogV1 KnScYQPkpXo0k/m0MQTDWxfJA5z1UbU0mnwdNLuttijm7KzjMr+8j5ey5iTO29DQHlWt XCnR3gb6sHzmr382/qVlfyRXJFyQ0Fo8aM6/bnYL/fRmud3NnoUOqHP4y8hh1WRffX82 9EpA== X-Gm-Message-State: AOAM532sw/2A87tp+cFL+9hlQeAzTcQ3H9DGCsjXkeJlNPHidiQU23Al VKZG/rIxB1iva0dtht3z/zOevNHmyy05P/hvUh0= X-Received: by 2002:a0c:f109:: with SMTP id i9mr18665621qvl.154.1593030799673; Wed, 24 Jun 2020 13:33:19 -0700 (PDT) Date: Wed, 24 Jun 2020 13:31:50 -0700 In-Reply-To: <20200624203200.78870-1-samitolvanen@google.com> Message-Id: <20200624203200.78870-13-samitolvanen@google.com> Mime-Version: 1.0 References: <20200624203200.78870-1-samitolvanen@google.com> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog Subject: [PATCH 12/22] modpost: lto: strip .lto from module names From: Sami Tolvanen To: Masahiro Yamada , Will Deacon Cc: Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , Nick Desaulniers , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, x86@kernel.org, Sami Tolvanen , Bill Wendling Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Sami Tolvanen --- scripts/mod/modpost.c | 16 +++++++--------- scripts/mod/modpost.h | 9 +++++++++ scripts/mod/sumversion.c | 6 +++++- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 6aea65c65745..8352f8a1a138 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include "modpost.h" #include "../../include/linux/license.h" @@ -80,14 +79,6 @@ modpost_log(enum loglevel loglevel, const char *fmt, ...) exit(1); } -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) @@ -1975,6 +1966,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; } @@ -1998,6 +1993,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); } diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 3aa052722233..fab30d201f9e 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -180,6 +181,14 @@ static inline unsigned int get_secindex(const struct elf_info *info, return info->symtab_shndx_start[sym - info->symtab_start]; } +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; +} + /* file2alias.c */ extern unsigned int cross_build; void handle_moddevtable(struct module *mod, struct elf_info *info, diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index d587f40f1117..760e6baa7eda 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c @@ -391,10 +391,14 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen) struct md4_ctx md; char *fname; char filelist[PATH_MAX + 1]; + int postfix_len = 1; + + if (strends(modname, ".lto.o")) + postfix_len = 5; /* objects for a module are listed in the first line of *.mod file. */ snprintf(filelist, sizeof(filelist), "%.*smod", - (int)strlen(modname) - 1, modname); + (int)strlen(modname) - postfix_len, modname); buf = read_text_file(filelist); -- 2.27.0.212.ge8ba1cc988-goog