ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / linux / kallsyms.h
1 /* Rewritten and vastly simplified by Rusty Russell for in-kernel
2  * module loader:
3  *   Copyright 2002 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation
4  */
5 #ifndef _LINUX_KALLSYMS_H
6 #define _LINUX_KALLSYMS_H
7
8 #include <linux/config.h>
9
10 #ifdef CONFIG_KALLSYMS
11 /* Lookup the address for a symbol. Returns 0 if not found. */
12 unsigned long kallsyms_lookup_name(const char *name);
13
14 /* Lookup an address.  modname is set to NULL if it's in the kernel. */
15 const char *kallsyms_lookup(unsigned long addr,
16                             unsigned long *symbolsize,
17                             unsigned long *offset,
18                             char **modname, char *namebuf);
19
20 /* Replace "%s" in format with address, if found */
21 extern void __print_symbol(const char *fmt, unsigned long address);
22
23 #else /* !CONFIG_KALLSYMS */
24
25 static inline unsigned long kallsyms_lookup_name(const char *name)
26 {
27         return 0;
28 }
29
30 static inline const char *kallsyms_lookup(unsigned long addr,
31                                           unsigned long *symbolsize,
32                                           unsigned long *offset,
33                                           char **modname, char *namebuf)
34 {
35         return NULL;
36 }
37
38 /* Stupid that this does nothing, but I didn't create this mess. */
39 #define __print_symbol(fmt, addr)
40 #endif /*CONFIG_KALLSYMS*/
41
42 /* This macro allows us to keep printk typechecking */
43 static void __check_printsym_format(const char *fmt, ...)
44 __attribute__((format(printf,1,2)));
45 static inline void __check_printsym_format(const char *fmt, ...)
46 {
47 }
48
49 #define print_symbol(fmt, addr)                 \
50 do {                                            \
51         __check_printsym_format(fmt, "");       \
52         __print_symbol(fmt, addr);              \
53 } while(0)
54
55 #endif /*_LINUX_KALLSYMS_H*/