Message ID | 20230514152739.962109-4-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 |
On Sun, May 14, 2023 at 8:27 AM Masahiro Yamada <masahiroy@kernel.org> wrote: > > This is the last user of get_pretty_name() - it is just used to > distinguish whether the symbol is a function or not. It is not > valuable information. I thought it's a nice touch. Not like it should slow things down unless there are extable warnings to report. May we keep it? > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > --- > > scripts/mod/modpost.c | 27 ++------------------------- > 1 file changed, 2 insertions(+), 25 deletions(-) > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > index bbe066f7adbc..371891d67175 100644 > --- a/scripts/mod/modpost.c > +++ b/scripts/mod/modpost.c > @@ -1207,23 +1207,6 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, > return near; > } > > -static int is_function(Elf_Sym *sym) > -{ > - if (sym) > - return ELF_ST_TYPE(sym->st_info) == STT_FUNC; > - else > - return -1; > -} > - > -static inline void get_pretty_name(int is_func, const char** name, const char** name_p) > -{ > - switch (is_func) { > - case 0: *name = "variable"; *name_p = ""; break; > - case 1: *name = "function"; *name_p = "()"; break; > - default: *name = "(unknown reference)"; *name_p = ""; break; > - } > -} > - > /* > * Print a warning about a section mismatch. > * Try to find symbols near it so user can find it. > @@ -1299,15 +1282,9 @@ static void report_extable_warnings(const char* modname, struct elf_info* elf, > { > Elf_Sym* tosym = find_elf_symbol(elf, r->r_addend, sym); > const char* tosym_name = sym_name(elf, tosym); > - const char* to_pretty_name; > - const char* to_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 to the %s %s:%s%s\n", > - modname, fromsec, (long)r->r_offset, > - to_pretty_name, tosec, tosym_name, to_pretty_name_p); > + warn("%s(%s+0x%lx): Section mismatch in reference to the %s:%s\n", > + modname, fromsec, (long)r->r_offset, tosec, tosym_name); > > if (!match(tosec, mismatch->bad_tosec) && > is_executable_section(elf, get_secindex(elf, sym))) > -- > 2.39.2 >
On Thu, May 18, 2023 at 6:44 AM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Sun, May 14, 2023 at 8:27 AM Masahiro Yamada <masahiroy@kernel.org> wrote: > > > > This is the last user of get_pretty_name() - it is just used to > > distinguish whether the symbol is a function or not. It is not > > valuable information. > > I thought it's a nice touch. Not like it should slow things down > unless there are extable warnings to report. May we keep it? I do not think so. The ex_table quite often points to assembly code, where the distinction of function/data is not so important. The extable has a lot of code just to print annoyingly long error messages.
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index bbe066f7adbc..371891d67175 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1207,23 +1207,6 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, return near; } -static int is_function(Elf_Sym *sym) -{ - if (sym) - return ELF_ST_TYPE(sym->st_info) == STT_FUNC; - else - return -1; -} - -static inline void get_pretty_name(int is_func, const char** name, const char** name_p) -{ - switch (is_func) { - case 0: *name = "variable"; *name_p = ""; break; - case 1: *name = "function"; *name_p = "()"; break; - default: *name = "(unknown reference)"; *name_p = ""; break; - } -} - /* * Print a warning about a section mismatch. * Try to find symbols near it so user can find it. @@ -1299,15 +1282,9 @@ static void report_extable_warnings(const char* modname, struct elf_info* elf, { Elf_Sym* tosym = find_elf_symbol(elf, r->r_addend, sym); const char* tosym_name = sym_name(elf, tosym); - const char* to_pretty_name; - const char* to_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 to the %s %s:%s%s\n", - modname, fromsec, (long)r->r_offset, - to_pretty_name, tosec, tosym_name, to_pretty_name_p); + warn("%s(%s+0x%lx): Section mismatch in reference to the %s:%s\n", + modname, fromsec, (long)r->r_offset, tosec, tosym_name); if (!match(tosec, mismatch->bad_tosec) && is_executable_section(elf, get_secindex(elf, sym)))
This is the last user of get_pretty_name() - it is just used to distinguish whether the symbol is a function or not. It is not valuable information. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> --- scripts/mod/modpost.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-)