@@ -605,6 +605,7 @@ struct module *find_module(const char *name);
int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
char *name, char *module_name, int *exported);
+unsigned long kallsyms_lookup_name_in_module(const char *module_name, const char *name);
/* Look for this name: can be of form module:name. */
unsigned long module_kallsyms_lookup_name(const char *name);
@@ -783,6 +784,12 @@ static inline int module_get_kallsym(unsigned int symnum, unsigned long *value,
return -ERANGE;
}
+static inline unsigned long kallsyms_lookup_name_in_module(const char *module_name,
+ const char *name)
+{
+ return 0;
+}
+
static inline unsigned long module_kallsyms_lookup_name(const char *name)
{
return 0;
@@ -482,6 +482,22 @@ static unsigned long __module_kallsyms_lookup_name(const char *name)
return 0;
}
+unsigned long kallsyms_lookup_name_in_module(const char *module_name, const char *name)
+{
+ unsigned long ret;
+ struct module *mod;
+
+ preempt_disable();
+ mod = find_module_all(module_name, strlen(module_name), false);
+ if (mod)
+ ret = find_kallsyms_symbol_value(mod, name);
+ else
+ ret = 0;
+ preempt_enable();
+ return ret;
+
+}
+
/* Look for this name: can be of form module:name. */
unsigned long module_kallsyms_lookup_name(const char *name)
{
Until now, the only way to look up a symbol in kallsyms of a particular module was using the "module_kallsyms_lookup_name" function with the "module:symbol" string passed as a parameter. This syntax often requires to build the parameter string on stack, needlessly wasting space. This commit introduces function "kallsyms_lookup_name_in_module" which takes the module and the symbol names as separate parameters and therefore allows more space-efficient lookup. Signed-off-by: Viktor Malik <vmalik@redhat.com> --- include/linux/module.h | 7 +++++++ kernel/module/kallsyms.c | 16 ++++++++++++++++ 2 files changed, 23 insertions(+)