modpost: move export_from_secname() call to more relevant place
authorMasahiro Yamada <masahiroy@kernel.org>
Tue, 5 Apr 2022 11:33:52 +0000 (20:33 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Sat, 7 May 2022 18:16:58 +0000 (03:16 +0900)
The assigned 'export' is only used when

    if (strstarts(symname, "__ksymtab_"))

is met. The else-part of the assignment is the dead code.

Move the export_from_secname() call to where it is used.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
scripts/mod/modpost.c

index eebb3268981692953d86a758c1f3990e882e2fe8..f9e54247ae1ddbc03fd9295cc12bc5e7648e8d77 100644 (file)
@@ -684,14 +684,8 @@ static void handle_modversion(const struct module *mod,
 static void handle_symbol(struct module *mod, struct elf_info *info,
                          const Elf_Sym *sym, const char *symname)
 {
-       enum export export;
        const char *name;
 
-       if (strstarts(symname, "__ksymtab"))
-               export = export_from_secname(info, get_secindex(info, sym));
-       else
-               export = export_unknown;
-
        switch (sym->st_shndx) {
        case SHN_COMMON:
                if (strstarts(symname, "__gnu_lto_")) {
@@ -726,7 +720,11 @@ static void handle_symbol(struct module *mod, struct elf_info *info,
        default:
                /* All exported symbols */
                if (strstarts(symname, "__ksymtab_")) {
+                       enum export export;
+
                        name = symname + strlen("__ksymtab_");
+                       export = export_from_secname(info,
+                                                    get_secindex(info, sym));
                        sym_add_exported(name, mod, export);
                }
                if (strcmp(symname, "init_module") == 0)