#include <linux/config.h>
#ifdef CONFIG_KALLSYMS
+/* Lookup the address for a symbol. Returns 0 if not found. */
+unsigned long kallsyms_lookup_name(const char *name);
+
/* Lookup an address. modname is set to NULL if it's in the kernel. */
const char *kallsyms_lookup(unsigned long addr,
unsigned long *symbolsize,
#else /* !CONFIG_KALLSYMS */
+static inline unsigned long kallsyms_lookup_name(const char *name)
+{
+ return 0;
+}
+
static inline const char *kallsyms_lookup(unsigned long addr,
unsigned long *symbolsize,
unsigned long *offset,
unsigned long *value,
char *type,
char namebuf[128]);
+
+/* Look for this name: can be of form module:name. */
+unsigned long module_kallsyms_lookup_name(const char *name);
+
int is_exported(const char *name, const struct module *mod);
extern void __module_put_and_exit(struct module *mod, long code)
return NULL;
}
+static inline unsigned long module_kallsyms_lookup_name(const char *name)
+{
+ return 0;
+}
+
static inline int is_exported(const char *name, const struct module *mod)
{
return 0;
return 0;
}
+/* Lookup the address for this symbol. Returns 0 if not found. */
+unsigned long kallsyms_lookup_name(const char *name)
+{
+ char namebuf[128];
+ unsigned long i;
+ char *knames;
+
+ for (i = 0, knames = kallsyms_names; i < kallsyms_num_syms; i++) {
+ unsigned prefix = *knames++;
+
+ strlcpy(namebuf + prefix, knames, 127 - prefix);
+ if (strcmp(namebuf, name) == 0)
+ return kallsyms_addresses[i];
+
+ knames += strlen(knames) + 1;
+ }
+ return module_kallsyms_lookup_name(name);
+}
+
/* Lookup an address. modname is set to NULL if it's in the kernel. */
const char *kallsyms_lookup(unsigned long addr,
unsigned long *symbolsize,
up(&module_mutex);
return NULL;
}
+
+static unsigned long mod_find_symname(struct module *mod, const char *name)
+{
+ unsigned int i;
+
+ for (i = 0; i < mod->num_symtab; i++)
+ if (strcmp(name, mod->strtab+mod->symtab[i].st_name) == 0)
+ return mod->symtab[i].st_value;
+ return 0;
+}
+
+/* Look for this name: can be of form module:name. */
+unsigned long module_kallsyms_lookup_name(const char *name)
+{
+ struct module *mod;
+ char *colon;
+ unsigned long ret = 0;
+
+ /* Don't lock: we're in enough trouble already. */
+ if ((colon = strchr(name, ':')) != NULL) {
+ *colon = '\0';
+ if ((mod = find_module(name)) != NULL)
+ ret = mod_find_symname(mod, colon+1);
+ *colon = ':';
+ } else {
+ list_for_each_entry(mod, &modules, list)
+ if ((ret = mod_find_symname(mod, name)) != 0)
+ break;
+ }
+ return ret;
+}
#endif /* CONFIG_KALLSYMS */
/* Called by the /proc file system to return a list of modules. */