Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

Link: https://lkml.kernel.org/r/20251128135920.217303-4-pmladek@suse.com
Signed-off-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Daniel Gomez <da.gomez@samsung.com>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
Cc: Aaron Tomlin <atomlin@atomlin.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkman <daniel@iogearbox.net>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: Kees Cook <kees@kernel.org>
Cc: Luis Chamberalin <mcgrof@kernel.org>
Cc: Marc Rutland <mark.rutland@arm.com>
Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Sami Tolvanen <samitolvanen@google.com>
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Petr Mladek and committed by
Andrew Morton
acfdbb4a fda024fb

+11 -7
+9
include/linux/module.h
··· 748 748 __mod ? __mod->name : "kernel"; \ 749 749 }) 750 750 751 + static inline const unsigned char *module_buildid(struct module *mod) 752 + { 753 + #ifdef CONFIG_STACKTRACE_BUILD_ID 754 + return mod->build_id; 755 + #else 756 + return NULL; 757 + #endif 758 + } 759 + 751 760 /* Dereference module function descriptor */ 752 761 void *dereference_module_function_descriptor(struct module *mod, void *ptr); 753 762
+2 -7
kernel/module/kallsyms.c
··· 334 334 if (mod) { 335 335 if (modname) 336 336 *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); 344 339 345 340 sym = find_kallsyms_symbol(mod, addr, size, offset); 346 341