All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Michal Marek <michal.lkml@markovi.net>
Subject: Re: [PATCH 10/27] modpost: traverse unresolved symbols in order
Date: Sun, 1 May 2022 00:24:30 +0900	[thread overview]
Message-ID: <CAK7LNARmg6TipRSi8gnohPKjRgt9OB_sgR-o1LYy3beobf5WSg@mail.gmail.com> (raw)
In-Reply-To: <CAKwvOdnysRX_qp1KYSd331G7K863iH-Xiw3UOwKRSQm65u9i-Q@mail.gmail.com>

On Wed, Apr 27, 2022 at 2:08 AM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Sun, Apr 24, 2022 at 12:09 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > Currently, modpost manages unresolved in a singly liked list; it adds
>
> s/liked/linked/
>
> > a new node to the head, and traverses the list from new to old.
> >
> > Use a doubly linked list to keep the order in the symbol table in the
> > ELF file.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> >  scripts/mod/modpost.c | 20 ++++++++++++++------
> >  scripts/mod/modpost.h |  2 +-
> >  2 files changed, 15 insertions(+), 7 deletions(-)
> >
> > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> > index 1c7d2831e89d..e1eb188d6282 100644
> > --- a/scripts/mod/modpost.c
> > +++ b/scripts/mod/modpost.c
> > @@ -185,6 +185,8 @@ static struct module *new_module(const char *modname)
> >         mod = NOFAIL(malloc(sizeof(*mod) + strlen(modname) + 1));
> >         memset(mod, 0, sizeof(*mod));
> >
> > +       INIT_LIST_HEAD(&mod->unresolved_symbols);
> > +
> >         strcpy(mod->name, modname);
> >         mod->is_vmlinux = (strcmp(modname, "vmlinux") == 0);
> >         mod->gpl_compatible = true;
> > @@ -201,6 +203,7 @@ static struct module *new_module(const char *modname)
> >
> >  struct symbol {
> >         struct symbol *next;
> > +       struct list_head list;
>
> Isn't `list` meant to replace `next`?


No.  'next' is still used for the hash table.

modpost used it in various ways.
You need to read the code closely if you are interested in
how modpost works.

>
> >         struct module *module;
> >         unsigned int crc;
> >         bool crc_valid;
> > @@ -255,8 +258,12 @@ static struct symbol *new_symbol(const char *name, struct module *module,
> >
> >  static void sym_add_unresolved(const char *name, struct module *mod, bool weak)
> >  {
> > -       mod->unres = alloc_symbol(name, mod->unres);
> > -       mod->unres->weak = weak;
> > +       struct symbol *sym;
> > +
> > +       sym = alloc_symbol(name, NULL);
> > +       sym->weak = weak;
> > +
> > +       list_add_tail(&sym->list, &mod->unresolved_symbols);
>
> Because I was curious here why NULL was passed, rather than remove the
> assignment to struct symbol's next member in alloc_symbol.
> I get why you replace the `unres` member of struct module. I guess I'm
> curious then why yet another list is added to struct symbol, rather
> than replace the next member.


'next' is used for ad-hoc hash table implementation.
I will be cleaned up by a later commit.

See this patch:
https://patchwork.kernel.org/project/linux-kbuild/patch/20220424190811.1678416-20-masahiroy@kernel.org/



>
> Also, does adding a struct list_head member really not specify the
> _type_ of the next element?  I guess when I look at the definition of
> struct module, at the member unresolved symbols, I don't know whether
> it's a list of struct module* or a list of struct symbol*.


This is how include/linux/list.h works.
struct list_head is really generic, does not specify a specific type definition.



>
> <snip>
>
> > diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
> > index c3b5d2f0e2bb..6a90bfc08458 100644
> > --- a/scripts/mod/modpost.h
> > +++ b/scripts/mod/modpost.h
> > @@ -117,7 +117,7 @@ struct namespace_list {
> >  struct module {
> >         struct list_head list;
> >         int gpl_compatible;
> > -       struct symbol *unres;
> > +       struct list_head unresolved_symbols;
> >         bool from_dump;         /* true if module was loaded from *.symvers */
> >         bool is_vmlinux;
> >         bool seen;
> > --
> > 2.32.0
> >
>
>
> --
> Thanks,
> ~Nick Desaulniers



-- 
Best Regards
Masahiro Yamada

  reply	other threads:[~2022-04-30 15:26 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-24 19:07 [PATCH 00/27] kbuild: yet another series of cleanups (modpost and LTO) Masahiro Yamada
2022-04-24 19:07 ` [PATCH 01/27] modpost: use snprintf() instead of sprintf() for safety Masahiro Yamada
2022-04-25 18:11   ` Nick Desaulniers
2022-04-24 19:07 ` [PATCH 02/27] modpost: do not write out any file when error occurred Masahiro Yamada
2022-04-25 18:15   ` Nick Desaulniers
2022-04-26  3:47     ` Masahiro Yamada
2022-04-24 19:07 ` [PATCH 03/27] modpost: remove stale comment about sym_add_exported() Masahiro Yamada
2022-04-25 18:18   ` Nick Desaulniers
2022-04-24 19:07 ` [PATCH 04/27] modpost: add a separate error for exported symbols without definition Masahiro Yamada
2022-04-25 18:21   ` Nick Desaulniers
2022-04-24 19:07 ` [PATCH 05/27] modpost: retrieve the module dependency and CRCs in check_exports() Masahiro Yamada
2022-04-25 18:24   ` Nick Desaulniers
2022-04-24 19:07 ` [PATCH 06/27] modpost: use bool type where appropriate Masahiro Yamada
2022-04-25 18:34   ` Nick Desaulniers
2022-04-25 18:56     ` Nick Desaulniers
2022-04-29 18:30       ` Masahiro Yamada
2022-05-01 13:14     ` Masahiro Yamada
2022-04-24 19:07 ` [PATCH 07/27] modpost: import include/linux/list.h Masahiro Yamada
2022-04-25 18:42   ` Nick Desaulniers
2022-04-26  4:05     ` Masahiro Yamada
2022-04-26 16:29   ` Nick Desaulniers
2022-04-30 14:21     ` Masahiro Yamada
2022-04-24 19:07 ` [PATCH 08/27] modpost: traverse modules in order Masahiro Yamada
2022-04-26 16:49   ` Nick Desaulniers
2022-04-24 19:07 ` [PATCH 09/27] modpost: add sym_add_unresolved() helper Masahiro Yamada
2022-04-25 18:41   ` Nick Desaulniers
2022-04-26  3:58     ` Masahiro Yamada
2022-04-26 16:40       ` Nick Desaulniers
2022-04-24 19:07 ` [PATCH 10/27] modpost: traverse unresolved symbols in order Masahiro Yamada
2022-04-26 17:08   ` Nick Desaulniers
2022-04-30 15:24     ` Masahiro Yamada [this message]
2022-04-24 19:07 ` [PATCH 11/27] modpost: use doubly linked list for dump_lists Masahiro Yamada
2022-04-26 17:14   ` Nick Desaulniers
2022-04-24 19:07 ` [PATCH 12/27] modpost: move struct namespace_list to modpost.c Masahiro Yamada
2022-04-25 18:44   ` Nick Desaulniers
2022-04-24 19:07 ` [PATCH 13/27] modpost: traverse the namespace_list in order Masahiro Yamada
2022-04-26 17:20   ` Nick Desaulniers
2022-04-24 19:07 ` [PATCH 14/27] modpost: dump Module.symvers in the same order of modules.order Masahiro Yamada
2022-04-26 22:22   ` Nick Desaulniers
2022-04-24 19:07 ` [PATCH 15/27] modpost: move static EXPORT_SYMBOL check to check_exports() Masahiro Yamada
2022-04-24 19:08 ` [PATCH 16/27] modpost: make multiple export error Masahiro Yamada
2022-04-25 18:48   ` Nick Desaulniers
2022-04-26  4:08     ` Masahiro Yamada
2022-04-26 16:39       ` Nick Desaulniers
2022-04-26 18:33         ` Masahiro Yamada
2022-04-24 19:08 ` [PATCH 17/27] modpost: make sym_add_exported() always allocate a new symbol Masahiro Yamada
2022-04-24 19:08 ` [PATCH 18/27] modpost: make sym_add_exported() a void function Masahiro Yamada
2022-04-24 19:08 ` [PATCH 19/27] modpost: use hlist for hash table implementation Masahiro Yamada
2022-04-24 19:08 ` [PATCH 20/27] modpost: mitigate false-negatives for static EXPORT_SYMBOL checks Masahiro Yamada
2022-04-24 19:08 ` [PATCH 21/27] kbuild: record symbol versions in *.cmd files Masahiro Yamada
2022-04-27 20:08   ` Nicolas Schier
2022-04-24 19:08 ` [PATCH 22/27] kbuild: generate a list of objects in vmlinux Masahiro Yamada
2022-04-27 20:14   ` Nicolas Schier
2022-04-28  4:49     ` Masahiro Yamada
2022-04-24 19:08 ` [PATCH 23/27] modpost: retrieve symbol versions by parsing *.cmd files Masahiro Yamada
2022-04-24 19:08 ` [PATCH 24/27] modpost: generate linker script to collect symbol versions Masahiro Yamada
2022-04-28 21:49   ` Nick Desaulniers
2022-04-29  1:31     ` Masahiro Yamada
2022-04-24 19:08 ` [PATCH 25/27] kbuild: embed symbol versions at final link of vmlinux or modules Masahiro Yamada
2022-04-28  3:04   ` Nicolas Schier
2022-04-24 19:08 ` [PATCH 26/27] kbuild: stop generating *.symversions Masahiro Yamada
2022-04-28  3:15   ` Nicolas Schier
2022-04-28  4:46     ` Masahiro Yamada
2022-04-24 19:08 ` [PATCH 27/27] kbuild: do not create *.prelink.o for Clang LTO or IBT Masahiro Yamada
2022-04-28  3:30   ` Nicolas Schier
2022-04-28  4:38     ` Masahiro Yamada
2022-04-28  6:59       ` Nicolas Schier
2022-04-26 20:10 ` [PATCH 00/27] kbuild: yet another series of cleanups (modpost and LTO) Nicolas Schier
2022-04-27  3:18   ` Masahiro Yamada
2022-05-01  7:11     ` Masahiro Yamada

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=CAK7LNARmg6TipRSi8gnohPKjRgt9OB_sgR-o1LYy3beobf5WSg@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.