aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kallsyms.c19
-rw-r--r--kernel/module.c19
2 files changed, 38 insertions, 0 deletions
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 7b8b0f21a5b1..374faf9bfdc7 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -161,6 +161,25 @@ unsigned long kallsyms_lookup_name(const char *name)
161 return module_kallsyms_lookup_name(name); 161 return module_kallsyms_lookup_name(name);
162} 162}
163 163
164int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
165 unsigned long),
166 void *data)
167{
168 char namebuf[KSYM_NAME_LEN];
169 unsigned long i;
170 unsigned int off;
171 int ret;
172
173 for (i = 0, off = 0; i < kallsyms_num_syms; i++) {
174 off = kallsyms_expand_symbol(off, namebuf);
175 ret = fn(data, namebuf, NULL, kallsyms_addresses[i]);
176 if (ret != 0)
177 return ret;
178 }
179 return module_kallsyms_on_each_symbol(fn, data);
180}
181EXPORT_SYMBOL_GPL(kallsyms_on_each_symbol);
182
164static unsigned long get_symbol_pos(unsigned long addr, 183static unsigned long get_symbol_pos(unsigned long addr,
165 unsigned long *symbolsize, 184 unsigned long *symbolsize,
166 unsigned long *offset) 185 unsigned long *offset)
diff --git a/kernel/module.c b/kernel/module.c
index 8ddca629e079..dd4389be9152 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2612,6 +2612,25 @@ unsigned long module_kallsyms_lookup_name(const char *name)
2612 preempt_enable(); 2612 preempt_enable();
2613 return ret; 2613 return ret;
2614} 2614}
2615
2616int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
2617 struct module *, unsigned long),
2618 void *data)
2619{
2620 struct module *mod;
2621 unsigned int i;
2622 int ret;
2623
2624 list_for_each_entry(mod, &modules, list) {
2625 for (i = 0; i < mod->num_symtab; i++) {
2626 ret = fn(data, mod->strtab + mod->symtab[i].st_name,
2627 mod, mod->symtab[i].st_value);
2628 if (ret != 0)
2629 return ret;
2630 }
2631 }
2632 return 0;
2633}
2615#endif /* CONFIG_KALLSYMS */ 2634#endif /* CONFIG_KALLSYMS */
2616 2635
2617static char *module_flags(struct module *mod, char *buf) 2636static char *module_flags(struct module *mod, char *buf)