diff mbox series

[v5,02/21] modpost: remove fromsym info in __ex_table section mismatch warning

Message ID 20230514152739.962109-3-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
report_extable_warnings() prints "from" in a pretty form, but we know
it is always located in the __ex_table section, i.e. a collection of
struct exception_table_entry.

It is very likely to fail to get the symbol name and ends up with
meaningless message:

  ... in reference from the (unknown reference) (unknown) to ...

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

 scripts/mod/modpost.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

Comments

Nick Desaulniers May 17, 2023, 6:53 p.m. UTC | #1
On Sun, May 14, 2023 at 8:27 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> report_extable_warnings() prints "from" in a pretty form, but we know
> it is always located in the __ex_table section, i.e. a collection of
> struct exception_table_entry.

Would it still be helpful to have "from __ex_table" somewhere in the
error string that may be shown to developers?

>
> It is very likely to fail to get the symbol name and ends up with
> meaningless message:
>
>   ... in reference from the (unknown reference) (unknown) to ...
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
>  scripts/mod/modpost.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index ba4577aa4f1d..bbe066f7adbc 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -1297,23 +1297,16 @@ static void report_extable_warnings(const char* modname, struct elf_info* elf,
>                                     Elf_Rela* r, Elf_Sym* sym,
>                                     const char* fromsec, const char* tosec)
>  {
> -       Elf_Sym* fromsym = find_elf_symbol2(elf, r->r_offset, fromsec);
> -       const char* fromsym_name = sym_name(elf, fromsym);
>         Elf_Sym* tosym = find_elf_symbol(elf, r->r_addend, sym);
>         const char* tosym_name = sym_name(elf, tosym);
> -       const char* from_pretty_name;
> -       const char* from_pretty_name_p;
>         const char* to_pretty_name;
>         const char* to_pretty_name_p;
>
> -       get_pretty_name(is_function(fromsym),
> -                       &from_pretty_name, &from_pretty_name_p);
>         get_pretty_name(is_function(tosym),
>                         &to_pretty_name, &to_pretty_name_p);
>
> -       warn("%s(%s+0x%lx): Section mismatch in reference from the %s %s%s to the %s %s:%s%s\n",
> -            modname, fromsec, (long)r->r_offset, from_pretty_name,
> -            fromsym_name, from_pretty_name_p,
> +       warn("%s(%s+0x%lx): Section mismatch in reference to the %s %s:%s%s\n",
> +            modname, fromsec, (long)r->r_offset,
>              to_pretty_name, tosec, tosym_name, to_pretty_name_p);
>
>         if (!match(tosec, mismatch->bad_tosec) &&
> --
> 2.39.2
>
Masahiro Yamada May 20, 2023, 1:11 p.m. UTC | #2
On Thu, May 18, 2023 at 3:53 AM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Sun, May 14, 2023 at 8:27 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > report_extable_warnings() prints "from" in a pretty form, but we know
> > it is always located in the __ex_table section, i.e. a collection of
> > struct exception_table_entry.
>
> Would it still be helpful to have "from __ex_table" somewhere in the
> error string that may be shown to developers?


See the code.

The variable, 'fromsec' (i.e. "__ex_table") is remaining.

It prints a warning message as you wish.




> >
> > It is very likely to fail to get the symbol name and ends up with
> > meaningless message:
> >
> >   ... in reference from the (unknown reference) (unknown) to ...
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> >  scripts/mod/modpost.c | 11 ++---------
> >  1 file changed, 2 insertions(+), 9 deletions(-)
> >
> > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> > index ba4577aa4f1d..bbe066f7adbc 100644
> > --- a/scripts/mod/modpost.c
> > +++ b/scripts/mod/modpost.c
> > @@ -1297,23 +1297,16 @@ static void report_extable_warnings(const char* modname, struct elf_info* elf,
> >                                     Elf_Rela* r, Elf_Sym* sym,
> >                                     const char* fromsec, const char* tosec)
> >  {
> > -       Elf_Sym* fromsym = find_elf_symbol2(elf, r->r_offset, fromsec);
> > -       const char* fromsym_name = sym_name(elf, fromsym);
> >         Elf_Sym* tosym = find_elf_symbol(elf, r->r_addend, sym);
> >         const char* tosym_name = sym_name(elf, tosym);
> > -       const char* from_pretty_name;
> > -       const char* from_pretty_name_p;
> >         const char* to_pretty_name;
> >         const char* to_pretty_name_p;
> >
> > -       get_pretty_name(is_function(fromsym),
> > -                       &from_pretty_name, &from_pretty_name_p);
> >         get_pretty_name(is_function(tosym),
> >                         &to_pretty_name, &to_pretty_name_p);
> >
> > -       warn("%s(%s+0x%lx): Section mismatch in reference from the %s %s%s to the %s %s:%s%s\n",
> > -            modname, fromsec, (long)r->r_offset, from_pretty_name,
> > -            fromsym_name, from_pretty_name_p,
> > +       warn("%s(%s+0x%lx): Section mismatch in reference to the %s %s:%s%s\n",
> > +            modname, fromsec, (long)r->r_offset,
> >              to_pretty_name, tosec, tosym_name, to_pretty_name_p);
> >
> >         if (!match(tosec, mismatch->bad_tosec) &&
> > --
> > 2.39.2
> >
>
>
> --
> Thanks,
> ~Nick Desaulniers
diff mbox series

Patch

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index ba4577aa4f1d..bbe066f7adbc 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1297,23 +1297,16 @@  static void report_extable_warnings(const char* modname, struct elf_info* elf,
 				    Elf_Rela* r, Elf_Sym* sym,
 				    const char* fromsec, const char* tosec)
 {
-	Elf_Sym* fromsym = find_elf_symbol2(elf, r->r_offset, fromsec);
-	const char* fromsym_name = sym_name(elf, fromsym);
 	Elf_Sym* tosym = find_elf_symbol(elf, r->r_addend, sym);
 	const char* tosym_name = sym_name(elf, tosym);
-	const char* from_pretty_name;
-	const char* from_pretty_name_p;
 	const char* to_pretty_name;
 	const char* to_pretty_name_p;
 
-	get_pretty_name(is_function(fromsym),
-			&from_pretty_name, &from_pretty_name_p);
 	get_pretty_name(is_function(tosym),
 			&to_pretty_name, &to_pretty_name_p);
 
-	warn("%s(%s+0x%lx): Section mismatch in reference from the %s %s%s to the %s %s:%s%s\n",
-	     modname, fromsec, (long)r->r_offset, from_pretty_name,
-	     fromsym_name, from_pretty_name_p,
+	warn("%s(%s+0x%lx): Section mismatch in reference to the %s %s:%s%s\n",
+	     modname, fromsec, (long)r->r_offset,
 	     to_pretty_name, tosec, tosym_name, to_pretty_name_p);
 
 	if (!match(tosec, mismatch->bad_tosec) &&