]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
modpost: use sym_get_data() to get module device_table data
authorMasahiro Yamada <masahiroy@kernel.org>
Tue, 19 Jul 2022 16:53:00 +0000 (01:53 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Wed, 27 Jul 2022 12:18:00 +0000 (21:18 +0900)
Use sym_get_data() to replace the long code.

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

index cbd6b0f48b4edb111c1e53ea995120e1283486ab..80d973144fded3b181e07612450b074e83925cfe 100644 (file)
@@ -1571,9 +1571,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
                zeros = calloc(1, sym->st_size);
                symval = zeros;
        } else {
-               symval = (void *)info->hdr
-                       + info->sechdrs[get_secindex(info, sym)].sh_offset
-                       + sym->st_value;
+               symval = sym_get_data(info, sym);
        }
 
        /* First handle the "special" cases */
index 75aa10413ad40f33aebe237dbe25b27e92d4a3d8..08411fff3e178aa03b5ab4a993d17c262ea05ef4 100644 (file)
@@ -324,7 +324,7 @@ static void *sym_get_data_by_offset(const struct elf_info *info,
        return (void *)info->hdr + sechdr->sh_offset + offset;
 }
 
-static void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym)
+void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym)
 {
        return sym_get_data_by_offset(info, get_secindex(info, sym),
                                      sym->st_value);
index 044bdfb894b720fcefb786512f2d8b6728d9f6a8..4d8a1ae1d1e3607666e1dd9952a6dfec6e8d230f 100644 (file)
@@ -187,6 +187,7 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen);
 /* from modpost.c */
 char *read_text_file(const char *filename);
 char *get_line(char **stringp);
+void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym);
 
 enum loglevel {
        LOG_WARN,