OSDN Git Service

riscv: module: move find_section to module.h
authorJisheng Zhang <jszhang@kernel.org>
Sat, 28 Jan 2023 17:28:50 +0000 (01:28 +0800)
committerPalmer Dabbelt <palmer@rivosinc.com>
Wed, 1 Feb 2023 07:29:39 +0000 (23:29 -0800)
Move find_section() to module.h so that the implementation can be shared
by the alternatives code. This will allow us to use alternatives in
the vdso.

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Link: https://lore.kernel.org/r/20230128172856.3814-8-jszhang@kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/include/asm/module.h
arch/riscv/kernel/module.c

index 76aa96a..0f3baaa 100644 (file)
@@ -5,6 +5,7 @@
 #define _ASM_RISCV_MODULE_H
 
 #include <asm-generic/module.h>
+#include <linux/elf.h>
 
 struct module;
 unsigned long module_emit_got_entry(struct module *mod, unsigned long val);
@@ -111,4 +112,19 @@ static inline struct plt_entry *get_plt_entry(unsigned long val,
 
 #endif /* CONFIG_MODULE_SECTIONS */
 
+static inline const Elf_Shdr *find_section(const Elf_Ehdr *hdr,
+                                          const Elf_Shdr *sechdrs,
+                                          const char *name)
+{
+       const Elf_Shdr *s, *se;
+       const char *secstrs = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
+
+       for (s = sechdrs, se = sechdrs + hdr->e_shnum; s < se; s++) {
+               if (strcmp(name, secstrs + s->sh_name) == 0)
+                       return s;
+       }
+
+       return NULL;
+}
+
 #endif /* _ASM_RISCV_MODULE_H */
index 91fe16b..76f4b9c 100644 (file)
@@ -429,21 +429,6 @@ void *module_alloc(unsigned long size)
 }
 #endif
 
-static const Elf_Shdr *find_section(const Elf_Ehdr *hdr,
-                                   const Elf_Shdr *sechdrs,
-                                   const char *name)
-{
-       const Elf_Shdr *s, *se;
-       const char *secstrs = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
-
-       for (s = sechdrs, se = sechdrs + hdr->e_shnum; s < se; s++) {
-               if (strcmp(name, secstrs + s->sh_name) == 0)
-                       return s;
-       }
-
-       return NULL;
-}
-
 int module_finalize(const Elf_Ehdr *hdr,
                    const Elf_Shdr *sechdrs,
                    struct module *me)