Skip to content

Commit a919390

Browse files
hcahcazx2c4
authored andcommitted
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 <[email protected]> Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 94c7755 commit a919390

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

arch/s390/include/asm/module.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,18 @@ struct mod_arch_specific {
3838
#endif /* CONFIG_FUNCTION_TRACER */
3939
};
4040

41+
static inline const Elf_Shdr *find_section(const Elf_Ehdr *hdr,
42+
const Elf_Shdr *sechdrs,
43+
const char *name)
44+
{
45+
const char *secstrs = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
46+
const Elf_Shdr *s, *se;
47+
48+
for (s = sechdrs, se = sechdrs + hdr->e_shnum; s < se; s++) {
49+
if (strcmp(name, secstrs + s->sh_name) == 0)
50+
return s;
51+
}
52+
return NULL;
53+
}
54+
4155
#endif /* _ASM_S390_MODULE_H */

0 commit comments

Comments
 (0)