arm64: module: move find_section to header
authorJoey Gouly <joey.gouly@arm.com>
Tue, 30 Aug 2022 10:48:31 +0000 (11:48 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 9 Sep 2022 11:27:25 +0000 (12:27 +0100)
Move it to the header so that the implementation can be shared
by the alternatives code.

Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Cc: Will Deacon <will@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20220830104833.34636-2-joey.gouly@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/module.h
arch/arm64/kernel/module.c

index 4e7fa2623896b008afb775c2cd4d41f7a72491c5..22f1be47cc923bdbd43fd12e1f2a6f893b11a6c5 100644 (file)
@@ -65,4 +65,19 @@ static inline bool plt_entry_is_initialized(const struct plt_entry *e)
        return e->adrp || e->add || e->br;
 }
 
+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_MODULE_H */
index f2d4bb14bfabe28e7fa79333c6c290bc9a3043c4..76b41e4ca9fa3a06d72849717c1354e9a92ced8e 100644 (file)
@@ -476,21 +476,6 @@ overflow:
        return -ENOEXEC;
 }
 
-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;
-}
-
 static inline void __init_plt(struct plt_entry *plt, unsigned long addr)
 {
        *plt = get_plt_entry(addr, plt);