On 1/21/26 10:04 PM, Josh Poimboeuf wrote:
> On Wed, Jan 21, 2026 at 09:28:16AM +0100, Petr Pavlu wrote:
>> +void *klp_locate_section_objs(const struct module *mod, const char *name,
>> + size_t object_size, unsigned int *nr_objs)
>> +{
>> + struct klp_modinfo *info = mod->klp_info;
>> +
>> + for (int i = 1; i < info->hdr.e_shnum; i++) {
>> + Elf_Shdr *shdr = &info->sechdrs[i];
>> +
>> + if (strcmp(info->secstrings + shdr->sh_name, name))
>> + continue;
>> +
>> + *nr_objs = shdr->sh_size / object_size;
>> + return (void *)shdr->sh_addr;
>> + }
>> +
>> + *nr_objs = 0;
>> + return NULL;
>> +}
>> +EXPORT_SYMBOL_GPL(klp_locate_section_objs);
>
> How about we make it even more generic with something like
>
> void *klp_find_section_by_name(const struct module *mod, const char *name,
> size_t *sec_size);
>
> ?
>
> I think that would help the code read more clearly.
Ok, I'll update it.
--
Thanks,
Petr