]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/kallsyms.h
rhashtable: Mark internal/private inline functions as such
[mirror_ubuntu-bionic-kernel.git] / include / linux / kallsyms.h
CommitLineData
1da177e4
LT
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
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
16struct module;
17
1da177e4
LT
18#ifdef CONFIG_KALLSYMS
19/* Lookup the address for a symbol. Returns 0 if not found. */
20unsigned long kallsyms_lookup_name(const char *name);
21
75a66614
AK
22/* Call a function on each kallsyms symbol in the core kernel */
23int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
24 unsigned long),
25 void *data);
26
ffc50891
FBH
27extern 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. */
32const 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. */
38extern int sprint_symbol(char *buffer, unsigned long address);
4796dd20 39extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
0f77a8d3 40extern int sprint_backtrace(char *buffer, unsigned long address);
42e38083
RP
41
42/* Look up a kernel symbol and print it to the kernel messages. */
1da177e4
LT
43extern void __print_symbol(const char *fmt, unsigned long address);
44
9d65cb4a 45int lookup_symbol_name(unsigned long addr, char *symname);
a5c43dae 46int lookup_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name);
9d65cb4a 47
1da177e4
LT
48#else /* !CONFIG_KALLSYMS */
49
50static inline unsigned long kallsyms_lookup_name(const char *name)
51{
52 return 0;
53}
54
75a66614
AK
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
ffc50891
FBH
63static inline int kallsyms_lookup_size_offset(unsigned long addr,
64 unsigned long *symbolsize,
65 unsigned long *offset)
66{
67 return 0;
68}
69
1da177e4
LT
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
42e38083
RP
78static inline int sprint_symbol(char *buffer, unsigned long addr)
79{
80 *buffer = '\0';
81 return 0;
82}
83
4796dd20
SB
84static inline int sprint_symbol_no_offset(char *buffer, unsigned long addr)
85{
86 *buffer = '\0';
87 return 0;
88}
89
0f77a8d3
NK
90static inline int sprint_backtrace(char *buffer, unsigned long addr)
91{
92 *buffer = '\0';
93 return 0;
94}
95
9d65cb4a
AD
96static inline int lookup_symbol_name(unsigned long addr, char *symname)
97{
98 return -ERANGE;
99}
100
a5c43dae
AD
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
1da177e4
LT
106/* Stupid that this does nothing, but I didn't create this mess. */
107#define __print_symbol(fmt, addr)
108#endif /*CONFIG_KALLSYMS*/
109
110/* This macro allows us to keep printk typechecking */
b9075fa9
JP
111static __printf(1, 2)
112void __check_printsym_format(const char *fmt, ...)
1da177e4
LT
113{
114}
1da177e4 115
b02454f4
HC
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}
1da177e4 122
2711b793
VN
123static inline void print_ip_sym(unsigned long ip)
124{
3f1712ba 125 printk("[<%p>] %pS\n", (void *) ip, (void *) ip);
2711b793 126}
8d8fdf5c 127
1da177e4 128#endif /*_LINUX_KALLSYMS_H*/