]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
s390/module: Provide find_section() helper
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 13 Sep 2024 13:05:40 +0000 (15:05 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 13 Sep 2024 15:28:36 +0000 (17:28 +0200)
Provide find_section() helper function which can be used to find a
section by name, similar to other architectures.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
arch/s390/include/asm/module.h

index 9f1eea15872ca36a720a0c5963f21ebb26b64627..916ab59e458a02530e6165316ddbee6999351e96 100644 (file)
@@ -38,4 +38,18 @@ struct mod_arch_specific {
 #endif /* CONFIG_FUNCTION_TRACER */
 };
 
+static inline const Elf_Shdr *find_section(const Elf_Ehdr *hdr,
+                                          const Elf_Shdr *sechdrs,
+                                          const char *name)
+{
+       const char *secstrs = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
+       const Elf_Shdr *s, *se;
+
+       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_S390_MODULE_H */