1
2
3
4
5#ifndef _LINUX_KALLSYMS_H
6#define _LINUX_KALLSYMS_H
7
8#include <linux/errno.h>
9#include <linux/kernel.h>
10#include <linux/stddef.h>
11
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)
15
16struct module;
17
18#ifdef CONFIG_KALLSYMS
19
20unsigned long kallsyms_lookup_name(const char *name);
21
22
23int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
24 unsigned long),
25 void *data);
26
27extern int kallsyms_lookup_size_offset(unsigned long addr,
28 unsigned long *symbolsize,
29 unsigned long *offset);
30
31
32const char *kallsyms_lookup(unsigned long addr,
33 unsigned long *symbolsize,
34 unsigned long *offset,
35 char **modname, char *namebuf);
36
37
38extern int sprint_symbol(char *buffer, unsigned long address);
39extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
40extern int sprint_backtrace(char *buffer, unsigned long address);
41
42
43extern void __print_symbol(const char *fmt, unsigned long address);
44
45int lookup_symbol_name(unsigned long addr, char *symname);
46int lookup_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name);
47
48#else
49
50static inline unsigned long kallsyms_lookup_name(const char *name)
51{
52 return 0;
53}
54
55static inline int kallsyms_on_each_symbol(int (*fn)(void *, const char *,
56 struct module *,
57 unsigned long),
58 void *data)
59{
60 return 0;
61}
62
63static inline int kallsyms_lookup_size_offset(unsigned long addr,
64 unsigned long *symbolsize,
65 unsigned long *offset)
66{
67 return 0;
68}
69
70static inline const char *kallsyms_lookup(unsigned long addr,
71 unsigned long *symbolsize,
72 unsigned long *offset,
73 char **modname, char *namebuf)
74{
75 return NULL;
76}
77
78static inline int sprint_symbol(char *buffer, unsigned long addr)
79{
80 *buffer = '\0';
81 return 0;
82}
83
84static inline int sprint_symbol_no_offset(char *buffer, unsigned long addr)
85{
86 *buffer = '\0';
87 return 0;
88}
89
90static inline int sprint_backtrace(char *buffer, unsigned long addr)
91{
92 *buffer = '\0';
93 return 0;
94}
95
96static inline int lookup_symbol_name(unsigned long addr, char *symname)
97{
98 return -ERANGE;
99}
100
101static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name)
102{
103 return -ERANGE;
104}
105
106
107#define __print_symbol(fmt, addr)
108#endif
109
110
111static __printf(1, 2)
112void __check_printsym_format(const char *fmt, ...)
113{
114}
115
116static inline void print_symbol(const char *fmt, unsigned long addr)
117{
118 __check_printsym_format(fmt, "");
119 __print_symbol(fmt, (unsigned long)
120 __builtin_extract_return_addr((void *)addr));
121}
122
123static inline void print_ip_sym(unsigned long ip)
124{
125 printk("[<%p>] %pS\n", (void *) ip, (void *) ip);
126}
127
128#endif
129