]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* Rewritten and vastly simplified by Rusty Russell for in-kernel |
2 | * module loader: | |
3 | * Copyright 2002 Rusty Russell <[email protected]> IBM Corporation | |
4 | */ | |
5 | #ifndef _LINUX_KALLSYMS_H | |
6 | #define _LINUX_KALLSYMS_H | |
7 | ||
40e48eed | 8 | #include <linux/errno.h> |
2711b793 | 9 | #include <linux/kernel.h> |
5a75983e | 10 | #include <linux/stddef.h> |
1da177e4 | 11 | |
9281acea TH |
12 | #define KSYM_NAME_LEN 128 |
13 | #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \ | |
14 | 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1) | |
1da177e4 | 15 | |
75a66614 AK |
16 | struct module; |
17 | ||
1da177e4 LT |
18 | #ifdef CONFIG_KALLSYMS |
19 | /* Lookup the address for a symbol. Returns 0 if not found. */ | |
20 | unsigned long kallsyms_lookup_name(const char *name); | |
21 | ||
75a66614 AK |
22 | /* Call a function on each kallsyms symbol in the core kernel */ |
23 | int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, | |
24 | unsigned long), | |
25 | void *data); | |
26 | ||
ffc50891 FBH |
27 | extern int kallsyms_lookup_size_offset(unsigned long addr, |
28 | unsigned long *symbolsize, | |
29 | unsigned long *offset); | |
30 | ||
1da177e4 LT |
31 | /* Lookup an address. modname is set to NULL if it's in the kernel. */ |
32 | const char *kallsyms_lookup(unsigned long addr, | |
33 | unsigned long *symbolsize, | |
34 | unsigned long *offset, | |
35 | char **modname, char *namebuf); | |
36 | ||
42e38083 RP |
37 | /* Look up a kernel symbol and return it in a text buffer. */ |
38 | extern int sprint_symbol(char *buffer, unsigned long address); | |
39 | ||
40 | /* Look up a kernel symbol and print it to the kernel messages. */ | |
1da177e4 LT |
41 | extern void __print_symbol(const char *fmt, unsigned long address); |
42 | ||
9d65cb4a | 43 | int lookup_symbol_name(unsigned long addr, char *symname); |
a5c43dae | 44 | int lookup_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name); |
9d65cb4a | 45 | |
1da177e4 LT |
46 | #else /* !CONFIG_KALLSYMS */ |
47 | ||
48 | static inline unsigned long kallsyms_lookup_name(const char *name) | |
49 | { | |
50 | return 0; | |
51 | } | |
52 | ||
75a66614 AK |
53 | static inline int kallsyms_on_each_symbol(int (*fn)(void *, const char *, |
54 | struct module *, | |
55 | unsigned long), | |
56 | void *data) | |
57 | { | |
58 | return 0; | |
59 | } | |
60 | ||
ffc50891 FBH |
61 | static inline int kallsyms_lookup_size_offset(unsigned long addr, |
62 | unsigned long *symbolsize, | |
63 | unsigned long *offset) | |
64 | { | |
65 | return 0; | |
66 | } | |
67 | ||
1da177e4 LT |
68 | static inline const char *kallsyms_lookup(unsigned long addr, |
69 | unsigned long *symbolsize, | |
70 | unsigned long *offset, | |
71 | char **modname, char *namebuf) | |
72 | { | |
73 | return NULL; | |
74 | } | |
75 | ||
42e38083 RP |
76 | static inline int sprint_symbol(char *buffer, unsigned long addr) |
77 | { | |
78 | *buffer = '\0'; | |
79 | return 0; | |
80 | } | |
81 | ||
9d65cb4a AD |
82 | static inline int lookup_symbol_name(unsigned long addr, char *symname) |
83 | { | |
84 | return -ERANGE; | |
85 | } | |
86 | ||
a5c43dae AD |
87 | static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name) |
88 | { | |
89 | return -ERANGE; | |
90 | } | |
91 | ||
1da177e4 LT |
92 | /* Stupid that this does nothing, but I didn't create this mess. */ |
93 | #define __print_symbol(fmt, addr) | |
94 | #endif /*CONFIG_KALLSYMS*/ | |
95 | ||
96 | /* This macro allows us to keep printk typechecking */ | |
97 | static void __check_printsym_format(const char *fmt, ...) | |
98 | __attribute__((format(printf,1,2))); | |
99 | static inline void __check_printsym_format(const char *fmt, ...) | |
100 | { | |
101 | } | |
1da177e4 | 102 | |
b02454f4 HC |
103 | static inline void print_symbol(const char *fmt, unsigned long addr) |
104 | { | |
105 | __check_printsym_format(fmt, ""); | |
106 | __print_symbol(fmt, (unsigned long) | |
107 | __builtin_extract_return_addr((void *)addr)); | |
108 | } | |
1da177e4 | 109 | |
2711b793 VN |
110 | static inline void print_ip_sym(unsigned long ip) |
111 | { | |
3f1712ba | 112 | printk("[<%p>] %pS\n", (void *) ip, (void *) ip); |
2711b793 | 113 | } |
8d8fdf5c | 114 | |
1da177e4 | 115 | #endif /*_LINUX_KALLSYMS_H*/ |