summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiko Carstens <hca@linux.ibm.com>2024-09-13 15:05:40 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2024-09-13 17:28:36 +0200
commita919390e9194209bac163ec8e19520bdb3fb738b (patch)
tree659f1c5c9fcffdd81c94c552d82e7934eb8f67d5
parents390/facility: Let test_facility() generate static branch if possible (diff)
downloadlinux-a919390e9194209bac163ec8e19520bdb3fb738b.tar.xz
linux-a919390e9194209bac163ec8e19520bdb3fb738b.zip
s390/module: Provide find_section() helper
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>
-rw-r--r--arch/s390/include/asm/module.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/arch/s390/include/asm/module.h b/arch/s390/include/asm/module.h
index 9f1eea15872c..916ab59e458a 100644
--- a/arch/s390/include/asm/module.h
+++ b/arch/s390/include/asm/module.h
@@ -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 */