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