Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp931995ybt; Wed, 24 Jun 2020 15:10:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgConJGq9IEGik2PsPNSHL+/vPC93iWcc+O77erNui/RL+4u1ocmd8DXKe4b9X1NOf+Af5 X-Received: by 2002:a17:906:fcba:: with SMTP id qw26mr13716408ejb.112.1593036645373; Wed, 24 Jun 2020 15:10:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593036645; cv=none; d=google.com; s=arc-20160816; b=IpljDPrH9w7jCKLB8rNjmNneYPPBaJTvQgYh7IedWgPsIq6e4rfAlDdDLLkPDZTc90 EB1LHjLgEg9EFwQ9njXngWBpP63JMcVkjRVM0GPRlqH4eCJwWrqiV+7zP+OwmMBorhmS Z/UopAPsKw8qgnoHxbCx7zYssbpJTgVBlKtMBuyPPpCb3lV8qL9dkWMyrhFllBMfxNFP X48Mxj0vCgZg9W93w08FBOdY5SaPUb0SflHFUxXWhVd0GtQ1YMXOHlpX0gO8j03+kXTc xShaLM11vf3R0YMEB4P3nfyMxGCuqXY+lGpULR+83yb8M/RRWWdLqa1t3mYlv4+sYG+m /eWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=xltSa+pOLgf6vSXNCg3Iy8gwRMudEIRX75C87X2gOqg=; b=pgRgNSSsrc6veo9tfH42zTid94IB3J8NDj3Ha8K9j/Mk8aW6aIW4c2SmYnCmjUdFkS FgqOI5SAN4o3rTr5mUe9sCpPK7/0t9PSDpTPDSxNchKu5oXlREow3dcaw5llIE/IN8W3 U2OzJHitCTfOJRI2VvszlzgsMtPE4urgphssT0Xp9DyjvhtN+yQXOfr+AqUxOEfg+Qb6 +eVDOX6hbIKgGPODT1263jkzyLBUESX+dWEl8VfLJhJoUmqlXvflIS6OeSym5lauEs/t ZqHjiMQvct6I0bdlFdqG+Irnh7z4iAyBmlxiPS8AckBf0J8trSuVMKqmPVYlFOb1dFcv TkrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=MgAD5Kdk; 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 bc21si3906104edb.51.2020.06.24.15.10.22; Wed, 24 Jun 2020 15:10:45 -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=MgAD5Kdk; 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 S2388686AbgFXWFk (ORCPT + 99 others); Wed, 24 Jun 2020 18:05:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388383AbgFXWFj (ORCPT ); Wed, 24 Jun 2020 18:05:39 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CAB7C0613ED for ; Wed, 24 Jun 2020 15:05:39 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id u8so1808469pje.4 for ; Wed, 24 Jun 2020 15:05:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xltSa+pOLgf6vSXNCg3Iy8gwRMudEIRX75C87X2gOqg=; b=MgAD5KdkoqXJfDMbYByeG9yy1WHD48fSG3E81h/9u2g6EmmOWXUynVOutBJ7t4vwAB psHe+EScWfsNCT5NBNrD4GqWZP9tUl+Kpp9FOICNYptFXA/r3FSM00oRybctU7BcYLkc xYuC/5NF2tPShhkqyHcGrMMH1bG1eOdc5yVDaWWtA6Pacgr2HqQK7HSqkFcx8JuPz7+l Bh6GmKIzyu2FWzCTSTFxVBAp3kMrEdSubXvgyg8U9SuaeGoSsA+M/E/Cs06190t4Npt5 nJfTobePwPdZokQYEfx1V+EhA02ju497XZgaKKA3UcFgUsazmRzB5B+R1GtnDyuhmE5I 0efw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xltSa+pOLgf6vSXNCg3Iy8gwRMudEIRX75C87X2gOqg=; b=sekJd05k2YkRATjxi/H0wA2zXj2YdQNb1G/f2A4HD3gKqYZhMZDBH5KCZCdP4zQGae QV6QdFN8eqtPSnj8OfphrYQqHFWAyyKYiTBqYycEIsNG50g6BJ4ixCwW+lAxpbAIYFxa Xot9jLg/zOgvO8CrMADyWln5hTp2tzHU+3urdPfoCYrjcmFF5tjz1hTfBcyY17vXLj9B mB/VITgOKELqa+zDux7G2F0cSHwZy+M8OtTS7fQUEVAgiSeM1S5estndawIoymJbKe4e qis7WDA5g8dVkI9CfiBJ/mj5vQTppNP0/yr0dZYMxADjjZFI7SXmkmnjKmkB+bcyM6LS Qr+A== X-Gm-Message-State: AOAM530VP3cmgXoVdBQ2gfWYRY4wLNUXaQxI5j1OmtmcjwwrNfXXL9A7 ApU8mX5fQwena1TvhVwxXyMU29II+T5xZsuKoWbJTQ== X-Received: by 2002:a17:902:ab8d:: with SMTP id f13mr19785027plr.119.1593036338270; Wed, 24 Jun 2020 15:05:38 -0700 (PDT) MIME-Version: 1.0 References: <20200624203200.78870-1-samitolvanen@google.com> <20200624203200.78870-13-samitolvanen@google.com> In-Reply-To: <20200624203200.78870-13-samitolvanen@google.com> From: Nick Desaulniers Date: Wed, 24 Jun 2020 15:05:26 -0700 Message-ID: Subject: Re: [PATCH 12/22] modpost: lto: strip .lto from module names To: Sami Tolvanen Cc: Masahiro Yamada , Will Deacon , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , clang-built-linux , Kernel Hardening , linux-arch , Linux ARM , Linux Kbuild mailing list , LKML , linux-pci@vger.kernel.org, "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , 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 On Wed, Jun 24, 2020 at 1:33 PM Sami Tolvanen wrote: > > 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 It looks like `bool` is used in the function signatures of other functions in this TU, I'm not the biggest fan of hoisting the includes out of the .c source into the header (I'd keep it in both), but I don't feel strongly enough to NACK. Reviewed-by: Nick Desaulniers > #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 > -- Thanks, ~Nick Desaulniers