Commit 7ce3e410 authored by Masahiro Yamada's avatar Masahiro Yamada

modpost: remove useless export_from_sec()

With commit 1743694e ("modpost: stop symbol preloading for
modversion CRC") applied, now export_from_sec() is useless.

handle_symbol() is called for every symbol in the ELF.

When 'symname' does not start with "__ksymtab", export_from_sec() is
called, and the returned value is stored in 'export'.

It is used in the last part of handle_symbol():

    if (strstarts(symname, "__ksymtab_")) {
            name = symname + strlen("__ksymtab_");
            sym_add_exported(name, mod, export);
    }

'export' is used only when 'symname' starts with "__ksymtab_".

So, the value returned by export_from_sec() is never used.

Remove useless export_from_sec(). This makes further cleanups possible.

I put the temporary code:

    export = export_unknown;

Otherwise, I would get the compiler warning:

    warning: 'export' may be used uninitialized in this function [-Wmaybe-uninitialized]

This is apparently false positive because

    if (strstarts(symname, "__ksymtab_")

... is a stronger condition than:

    if (strstarts(symname, "__ksymtab")

Anyway, this part will be cleaned up by the next commit.
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
parent dc6dc3e7
...@@ -369,16 +369,6 @@ static enum export export_from_secname(struct elf_info *elf, unsigned int sec) ...@@ -369,16 +369,6 @@ static enum export export_from_secname(struct elf_info *elf, unsigned int sec)
return export_unknown; return export_unknown;
} }
static enum export export_from_sec(struct elf_info *elf, unsigned int sec)
{
if (sec == elf->export_sec)
return export_plain;
else if (sec == elf->export_gpl_sec)
return export_gpl;
else
return export_unknown;
}
static const char *namespace_from_kstrtabns(const struct elf_info *info, static const char *namespace_from_kstrtabns(const struct elf_info *info,
const Elf_Sym *sym) const Elf_Sym *sym)
{ {
...@@ -576,10 +566,7 @@ static int parse_elf(struct elf_info *info, const char *filename) ...@@ -576,10 +566,7 @@ static int parse_elf(struct elf_info *info, const char *filename)
fatal("%s has NOBITS .modinfo\n", filename); fatal("%s has NOBITS .modinfo\n", filename);
info->modinfo = (void *)hdr + sechdrs[i].sh_offset; info->modinfo = (void *)hdr + sechdrs[i].sh_offset;
info->modinfo_len = sechdrs[i].sh_size; info->modinfo_len = sechdrs[i].sh_size;
} else if (strcmp(secname, "__ksymtab") == 0) }
info->export_sec = i;
else if (strcmp(secname, "__ksymtab_gpl") == 0)
info->export_gpl_sec = i;
if (sechdrs[i].sh_type == SHT_SYMTAB) { if (sechdrs[i].sh_type == SHT_SYMTAB) {
unsigned int sh_link_idx; unsigned int sh_link_idx;
...@@ -703,7 +690,7 @@ static void handle_symbol(struct module *mod, struct elf_info *info, ...@@ -703,7 +690,7 @@ static void handle_symbol(struct module *mod, struct elf_info *info,
if (strstarts(symname, "__ksymtab")) if (strstarts(symname, "__ksymtab"))
export = export_from_secname(info, get_secindex(info, sym)); export = export_from_secname(info, get_secindex(info, sym));
else else
export = export_from_sec(info, get_secindex(info, sym)); export = export_unknown;
switch (sym->st_shndx) { switch (sym->st_shndx) {
case SHN_COMMON: case SHN_COMMON:
......
...@@ -138,8 +138,6 @@ struct elf_info { ...@@ -138,8 +138,6 @@ struct elf_info {
Elf_Shdr *sechdrs; Elf_Shdr *sechdrs;
Elf_Sym *symtab_start; Elf_Sym *symtab_start;
Elf_Sym *symtab_stop; Elf_Sym *symtab_stop;
Elf_Section export_sec;
Elf_Section export_gpl_sec;
char *strtab; char *strtab;
char *modinfo; char *modinfo;
unsigned int modinfo_len; unsigned int modinfo_len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment