From: Masahiro Yamada <masahiroy@kernel.org>
To: Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>
Cc: Michal Marek <michal.lkml@markovi.net>,
Nick Desaulniers <ndesaulniers@google.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/5] modpost: get the *.mod file path more simply
Date: Tue, 31 Aug 2021 10:41:05 +0900 [thread overview]
Message-ID: <CAK7LNATUL4G5N8h1c9GmNcrPeYzuF2Pon4nxB2V32S_2NCXoYA@mail.gmail.com> (raw)
In-Reply-To: <20210828095103.2617393-1-masahiroy@kernel.org>
On Sat, Aug 28, 2021 at 6:51 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> get_src_version() strips 'o' or 'lto.o' from the end of the object file
> path (so, postfixlen is 1 or 5), then adds 'mod'.
>
> If you look at the code closely, mod->name already holds the base path
> with the extension stripped.
>
> Most of the code changes made by commit 7ac204b545f2 ("modpost: lto:
> strip .lto from module names") was actually unneeded.
>
> sumversion.c does not need strends(), so it can get back local in
> modpost.c again.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
Applied this to linux-kbuild.
(only 1/5 and 3/5)
> scripts/mod/modpost.c | 11 ++++++++++-
> scripts/mod/modpost.h | 9 ---------
> scripts/mod/sumversion.c | 7 +------
> 3 files changed, 11 insertions(+), 16 deletions(-)
>
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 270a7df898e2..a26139aa57fd 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -17,6 +17,7 @@
> #include <ctype.h>
> #include <string.h>
> #include <limits.h>
> +#include <stdbool.h>
> #include <errno.h>
> #include "modpost.h"
> #include "../../include/linux/license.h"
> @@ -89,6 +90,14 @@ 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)
> @@ -2060,7 +2069,7 @@ static void read_symbols(const char *modname)
> if (!mod->is_vmlinux) {
> version = get_modinfo(&info, "version");
> if (version || all_versions)
> - get_src_version(modname, mod->srcversion,
> + get_src_version(mod->name, mod->srcversion,
> sizeof(mod->srcversion) - 1);
> }
>
> diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
> index c1a895c0d682..0c47ff95c0e2 100644
> --- a/scripts/mod/modpost.h
> +++ b/scripts/mod/modpost.h
> @@ -2,7 +2,6 @@
> #include <stdio.h>
> #include <stdlib.h>
> #include <stdarg.h>
> -#include <stdbool.h>
> #include <string.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> @@ -178,14 +177,6 @@ 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 760e6baa7eda..905c0ec291e1 100644
> --- a/scripts/mod/sumversion.c
> +++ b/scripts/mod/sumversion.c
> @@ -391,14 +391,9 @@ 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) - postfix_len, modname);
> + snprintf(filelist, sizeof(filelist), "%s.mod", modname);
>
> buf = read_text_file(filelist);
>
> --
> 2.30.2
>
--
Best Regards
Masahiro Yamada
prev parent reply other threads:[~2021-08-31 1:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-28 9:50 [PATCH 1/5] modpost: get the *.mod file path more simply Masahiro Yamada
2021-08-28 9:51 ` [PATCH 2/5] kbuild: detect objtool changes correctly without .SECONDEXPANSION Masahiro Yamada
2021-08-31 1:43 ` Masahiro Yamada
2021-08-28 9:51 ` [PATCH 3/5] kbuild: clean up objtool_args slightly Masahiro Yamada
2021-08-31 1:41 ` Masahiro Yamada
2021-08-28 9:51 ` [PATCH 4/5] kbuild: merge objtool_args into objtool in scripts/Makefile.build Masahiro Yamada
2021-08-28 9:51 ` [PATCH 5/5] kbuild: rebuild *.lto.o when objtool is changed Masahiro Yamada
2021-08-31 1:41 ` Masahiro Yamada [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAK7LNATUL4G5N8h1c9GmNcrPeYzuF2Pon4nxB2V32S_2NCXoYA@mail.gmail.com \
--to=masahiroy@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.lkml@markovi.net \
--cc=ndesaulniers@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).