Skip to content

Commit bb9de5c

Browse files
pmladekKernel Patches Daemon
authored andcommitted
module: Add helper function for reading module_buildid()
Add a helper function for reading the optional "build_id" member of struct module. It is going to be used also in ftrace_mod_address_lookup(). Use "#ifdef" instead of "#if IS_ENABLED()" to match the declaration of the optional field in struct module. Reviewed-by: Daniel Gomez <[email protected]> Reviewed-by: Petr Pavlu <[email protected]> Signed-off-by: Petr Mladek <[email protected]>
1 parent ac3061b commit bb9de5c

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

include/linux/module.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,15 @@ static inline void __module_get(struct module *module)
747747
__mod ? __mod->name : "kernel"; \
748748
})
749749

750+
static inline const unsigned char *module_buildid(struct module *mod)
751+
{
752+
#ifdef CONFIG_STACKTRACE_BUILD_ID
753+
return mod->build_id;
754+
#else
755+
return NULL;
756+
#endif
757+
}
758+
750759
/* Dereference module function descriptor */
751760
void *dereference_module_function_descriptor(struct module *mod, void *ptr);
752761

kernel/module/kallsyms.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,8 @@ int module_address_lookup(unsigned long addr,
334334
if (mod) {
335335
if (modname)
336336
*modname = mod->name;
337-
if (modbuildid) {
338-
#if IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID)
339-
*modbuildid = mod->build_id;
340-
#else
341-
*modbuildid = NULL;
342-
#endif
343-
}
337+
if (modbuildid)
338+
*modbuildid = module_buildid(mod);
344339

345340
sym = find_kallsyms_symbol(mod, addr, size, offset);
346341

0 commit comments

Comments
 (0)