[PATCH] WE-22 : prevent information leak on 64 bit
[linux-2.6] / 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
9 #define KSYM_NAME_LEN 127
10
11 #ifdef CONFIG_KALLSYMS
12 /* Lookup the address for a symbol. Returns 0 if not found. */
13 unsigned long kallsyms_lookup_name(const char *name);
14
15 extern int kallsyms_lookup_size_offset(unsigned long addr,
16                                   unsigned long *symbolsize,
17                                   unsigned long *offset);
18
19 /* Lookup an address.  modname is set to NULL if it's in the kernel. */
20 const char *kallsyms_lookup(unsigned long addr,
21                             unsigned long *symbolsize,
22                             unsigned long *offset,
23                             char **modname, char *namebuf);
24
25 /* Replace "%s" in format with address, if found */
26 extern void __print_symbol(const char *fmt, unsigned long address);
27
28 #else /* !CONFIG_KALLSYMS */
29
30 static inline unsigned long kallsyms_lookup_name(const char *name)
31 {
32         return 0;
33 }
34
35 static inline int kallsyms_lookup_size_offset(unsigned long addr,
36                                               unsigned long *symbolsize,
37                                               unsigned long *offset)
38 {
39         return 0;
40 }
41
42 static inline const char *kallsyms_lookup(unsigned long addr,
43                                           unsigned long *symbolsize,
44                                           unsigned long *offset,
45                                           char **modname, char *namebuf)
46 {
47         return NULL;
48 }
49
50 /* Stupid that this does nothing, but I didn't create this mess. */
51 #define __print_symbol(fmt, addr)
52 #endif /*CONFIG_KALLSYMS*/
53
54 /* This macro allows us to keep printk typechecking */
55 static void __check_printsym_format(const char *fmt, ...)
56 __attribute__((format(printf,1,2)));
57 static inline void __check_printsym_format(const char *fmt, ...)
58 {
59 }
60 /* ia64 and ppc64 use function descriptors, which contain the real address */
61 #if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
62 #define print_fn_descriptor_symbol(fmt, addr)           \
63 do {                                            \
64         unsigned long *__faddr = (unsigned long*) addr;         \
65         print_symbol(fmt, __faddr[0]);          \
66 } while (0)
67 #else
68 #define print_fn_descriptor_symbol(fmt, addr) print_symbol(fmt, addr)
69 #endif
70
71 static inline void print_symbol(const char *fmt, unsigned long addr)
72 {
73         __check_printsym_format(fmt, "");
74         __print_symbol(fmt, (unsigned long)
75                        __builtin_extract_return_addr((void *)addr));
76 }
77
78 #ifndef CONFIG_64BIT
79 #define print_ip_sym(ip)                \
80 do {                                    \
81         printk("[<%08lx>]", ip);        \
82         print_symbol(" %s\n", ip);      \
83 } while(0)
84 #else
85 #define print_ip_sym(ip)                \
86 do {                                    \
87         printk("[<%016lx>]", ip);       \
88         print_symbol(" %s\n", ip);      \
89 } while(0)
90 #endif
91
92 #endif /*_LINUX_KALLSYMS_H*/