diff mbox series

[v5,10/21] modpost: rename find_elf_symbol() and find_elf_symbol2()

Message ID 20230514152739.962109-11-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series Unify <linux/export.h> and <asm/export.h>, remove EXPORT_DATA_SYMBOL(), faster TRIM_UNUSED_KSYMS | expand

Commit Message

Masahiro Yamada May 14, 2023, 3:27 p.m. UTC
find_elf_symbol() and find_elf_symbol2() are not good names.

Rename them to find_tosym(), find_fromsym(), respectively.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

Changes in v5:
  - Change the names

 scripts/mod/modpost.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Nick Desaulniers May 17, 2023, 9:14 p.m. UTC | #1
On Sun, May 14, 2023 at 8:28 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> find_elf_symbol() and find_elf_symbol2() are not good names.
>
> Rename them to find_tosym(), find_fromsym(), respectively.

The comments maybe could be updated, too. The end of the comment looks
wrong for both.

Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
> Changes in v5:
>   - Change the names
>
>  scripts/mod/modpost.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 3b7b78e69137..0d2c2aff2c03 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -1124,8 +1124,8 @@ static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym)
>   * In other cases the symbol needs to be looked up in the symbol table
>   * based on section and address.
>   *  **/
> -static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
> -                               Elf_Sym *relsym)
> +static Elf_Sym *find_tosym(struct elf_info *elf, Elf64_Sword addr,
> +                          Elf_Sym *relsym)
>  {
>         Elf_Sym *sym;
>         Elf_Sym *near = NULL;
> @@ -1168,8 +1168,8 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
>   * The ELF format may have a better way to detect what type of symbol
>   * it is, but this works for now.
>   **/
> -static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,
> -                                unsigned int secndx)
> +static Elf_Sym *find_fromsym(struct elf_info *elf, Elf_Addr addr,
> +                            unsigned int secndx)
>  {
>         Elf_Sym *sym;
>         Elf_Sym *near = NULL;
> @@ -1207,10 +1207,10 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
>         const char *tosym;
>         const char *fromsym;
>
> -       from = find_elf_symbol2(elf, r->r_offset, fsecndx);
> +       from = find_fromsym(elf, r->r_offset, fsecndx);
>         fromsym = sym_name(elf, from);
>
> -       to = find_elf_symbol(elf, r->r_addend, sym);
> +       to = find_tosym(elf, r->r_addend, sym);
>         tosym = sym_name(elf, to);
>
>         /* check whitelist - we may ignore it */
> --
> 2.39.2
>
Masahiro Yamada May 20, 2023, 1:27 p.m. UTC | #2
On Thu, May 18, 2023 at 6:14 AM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Sun, May 14, 2023 at 8:28 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > find_elf_symbol() and find_elf_symbol2() are not good names.
> >
> > Rename them to find_tosym(), find_fromsym(), respectively.
>
> The comments maybe could be updated, too. The end of the comment looks
> wrong for both.


What do you mean?

Please tell me which part should be changed, and how.






> Thanks for the patch!
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
>
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> > Changes in v5:
> >   - Change the names
> >
> >  scripts/mod/modpost.c | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> > index 3b7b78e69137..0d2c2aff2c03 100644
> > --- a/scripts/mod/modpost.c
> > +++ b/scripts/mod/modpost.c
> > @@ -1124,8 +1124,8 @@ static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym)
> >   * In other cases the symbol needs to be looked up in the symbol table
> >   * based on section and address.
> >   *  **/
> > -static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
> > -                               Elf_Sym *relsym)
> > +static Elf_Sym *find_tosym(struct elf_info *elf, Elf64_Sword addr,
> > +                          Elf_Sym *relsym)
> >  {
> >         Elf_Sym *sym;
> >         Elf_Sym *near = NULL;
> > @@ -1168,8 +1168,8 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
> >   * The ELF format may have a better way to detect what type of symbol
> >   * it is, but this works for now.
> >   **/
> > -static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,
> > -                                unsigned int secndx)
> > +static Elf_Sym *find_fromsym(struct elf_info *elf, Elf_Addr addr,
> > +                            unsigned int secndx)
> >  {
> >         Elf_Sym *sym;
> >         Elf_Sym *near = NULL;
> > @@ -1207,10 +1207,10 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
> >         const char *tosym;
> >         const char *fromsym;
> >
> > -       from = find_elf_symbol2(elf, r->r_offset, fsecndx);
> > +       from = find_fromsym(elf, r->r_offset, fsecndx);
> >         fromsym = sym_name(elf, from);
> >
> > -       to = find_elf_symbol(elf, r->r_addend, sym);
> > +       to = find_tosym(elf, r->r_addend, sym);
> >         tosym = sym_name(elf, to);
> >
> >         /* check whitelist - we may ignore it */
> > --
> > 2.39.2
> >
>
>
> --
> Thanks,
> ~Nick Desaulniers
Nick Desaulniers May 22, 2023, 4:59 p.m. UTC | #3
On Sat, May 20, 2023 at 6:28 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Thu, May 18, 2023 at 6:14 AM Nick Desaulniers
> <ndesaulniers@google.com> wrote:
> >
> > On Sun, May 14, 2023 at 8:28 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > >
> > > find_elf_symbol() and find_elf_symbol2() are not good names.
> > >
> > > Rename them to find_tosym(), find_fromsym(), respectively.
> >
> > The comments maybe could be updated, too. The end of the comment looks
> > wrong for both.
>
>
> What do you mean?
>
> Please tell me which part should be changed, and how.

Attached the comment style changes.  I didn't have precise wording in
mind for the comments; I was suggesting to see if the comments could
be updated to clarify what the functions are doing.

>
>
>
>
>
>
> > Thanks for the patch!
> > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> >
> > >
> > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > > ---
> > >
> > > Changes in v5:
> > >   - Change the names
> > >
> > >  scripts/mod/modpost.c | 12 ++++++------
> > >  1 file changed, 6 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> > > index 3b7b78e69137..0d2c2aff2c03 100644
> > > --- a/scripts/mod/modpost.c
> > > +++ b/scripts/mod/modpost.c
> > > @@ -1124,8 +1124,8 @@ static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym)
> > >   * In other cases the symbol needs to be looked up in the symbol table
> > >   * based on section and address.
> > >   *  **/
> > > -static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
> > > -                               Elf_Sym *relsym)
> > > +static Elf_Sym *find_tosym(struct elf_info *elf, Elf64_Sword addr,
> > > +                          Elf_Sym *relsym)
> > >  {
> > >         Elf_Sym *sym;
> > >         Elf_Sym *near = NULL;
> > > @@ -1168,8 +1168,8 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
> > >   * The ELF format may have a better way to detect what type of symbol
> > >   * it is, but this works for now.
> > >   **/
> > > -static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,
> > > -                                unsigned int secndx)
> > > +static Elf_Sym *find_fromsym(struct elf_info *elf, Elf_Addr addr,
> > > +                            unsigned int secndx)
> > >  {
> > >         Elf_Sym *sym;
> > >         Elf_Sym *near = NULL;
> > > @@ -1207,10 +1207,10 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
> > >         const char *tosym;
> > >         const char *fromsym;
> > >
> > > -       from = find_elf_symbol2(elf, r->r_offset, fsecndx);
> > > +       from = find_fromsym(elf, r->r_offset, fsecndx);
> > >         fromsym = sym_name(elf, from);
> > >
> > > -       to = find_elf_symbol(elf, r->r_addend, sym);
> > > +       to = find_tosym(elf, r->r_addend, sym);
> > >         tosym = sym_name(elf, to);
> > >
> > >         /* check whitelist - we may ignore it */
> > > --
> > > 2.39.2
> > >
> >
> >
> > --
> > Thanks,
> > ~Nick Desaulniers
>
>
>
> --
> Best Regards
> Masahiro Yamada
Masahiro Yamada May 23, 2023, 12:04 p.m. UTC | #4
On Tue, May 23, 2023 at 1:59 AM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Sat, May 20, 2023 at 6:28 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > On Thu, May 18, 2023 at 6:14 AM Nick Desaulniers
> > <ndesaulniers@google.com> wrote:
> > >
> > > On Sun, May 14, 2023 at 8:28 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > > >
> > > > find_elf_symbol() and find_elf_symbol2() are not good names.
> > > >
> > > > Rename them to find_tosym(), find_fromsym(), respectively.
> > >
> > > The comments maybe could be updated, too. The end of the comment looks
> > > wrong for both.
> >
> >
> > What do you mean?
> >
> > Please tell me which part should be changed, and how.
>
> Attached the comment style changes.  I didn't have precise wording in
> mind for the comments; I was suggesting to see if the comments could
> be updated to clarify what the functions are doing.

Ah, I understood what you meant.

I think some parts of the comments are stale.
Anyway, these comment blocks will be removed by a later commit.

https://patchwork.kernel.org/project/linux-kbuild/patch/20230521160426.1881124-6-masahiroy@kernel.org/
diff mbox series

Patch

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 3b7b78e69137..0d2c2aff2c03 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1124,8 +1124,8 @@  static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym)
  * In other cases the symbol needs to be looked up in the symbol table
  * based on section and address.
  *  **/
-static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
-				Elf_Sym *relsym)
+static Elf_Sym *find_tosym(struct elf_info *elf, Elf64_Sword addr,
+			   Elf_Sym *relsym)
 {
 	Elf_Sym *sym;
 	Elf_Sym *near = NULL;
@@ -1168,8 +1168,8 @@  static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
  * The ELF format may have a better way to detect what type of symbol
  * it is, but this works for now.
  **/
-static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,
-				 unsigned int secndx)
+static Elf_Sym *find_fromsym(struct elf_info *elf, Elf_Addr addr,
+			     unsigned int secndx)
 {
 	Elf_Sym *sym;
 	Elf_Sym *near = NULL;
@@ -1207,10 +1207,10 @@  static void default_mismatch_handler(const char *modname, struct elf_info *elf,
 	const char *tosym;
 	const char *fromsym;
 
-	from = find_elf_symbol2(elf, r->r_offset, fsecndx);
+	from = find_fromsym(elf, r->r_offset, fsecndx);
 	fromsym = sym_name(elf, from);
 
-	to = find_elf_symbol(elf, r->r_addend, sym);
+	to = find_tosym(elf, r->r_addend, sym);
 	tosym = sym_name(elf, to);
 
 	/* check whitelist - we may ignore it */