]>
git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/blob - include/linux/kallsyms.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Rewritten and vastly simplified by Rusty Russell for in-kernel
4 * Copyright 2002 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation
6 #ifndef _LINUX_KALLSYMS_H
7 #define _LINUX_KALLSYMS_H
9 #include <linux/errno.h>
10 #include <linux/kernel.h>
11 #include <linux/stddef.h>
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)
18 # define KALLSYM_FMT "%08lx"
20 # define KALLSYM_FMT "%016lx"
25 #ifdef CONFIG_KALLSYMS
26 /* Lookup the address for a symbol. Returns 0 if not found. */
27 unsigned long kallsyms_lookup_name(const char *name
);
29 /* Call a function on each kallsyms symbol in the core kernel */
30 int kallsyms_on_each_symbol(int (*fn
)(void *, const char *, struct module
*,
34 extern int kallsyms_lookup_size_offset(unsigned long addr
,
35 unsigned long *symbolsize
,
36 unsigned long *offset
);
38 /* Lookup an address. modname is set to NULL if it's in the kernel. */
39 const char *kallsyms_lookup(unsigned long addr
,
40 unsigned long *symbolsize
,
41 unsigned long *offset
,
42 char **modname
, char *namebuf
);
44 /* Look up a kernel symbol and return it in a text buffer. */
45 extern int sprint_symbol(char *buffer
, unsigned long address
);
46 extern int sprint_symbol_no_offset(char *buffer
, unsigned long address
);
47 extern int sprint_backtrace(char *buffer
, unsigned long address
);
49 /* Look up a kernel symbol and print it to the kernel messages. */
50 extern void __print_symbol(const char *fmt
, unsigned long address
);
52 int lookup_symbol_name(unsigned long addr
, char *symname
);
53 int lookup_symbol_attrs(unsigned long addr
, unsigned long *size
, unsigned long *offset
, char *modname
, char *name
);
55 /* How and when do we show kallsyms values? */
56 extern int kallsyms_show_value(void);
58 #else /* !CONFIG_KALLSYMS */
60 static inline unsigned long kallsyms_lookup_name(const char *name
)
65 static inline int kallsyms_on_each_symbol(int (*fn
)(void *, const char *,
73 static inline int kallsyms_lookup_size_offset(unsigned long addr
,
74 unsigned long *symbolsize
,
75 unsigned long *offset
)
80 static inline const char *kallsyms_lookup(unsigned long addr
,
81 unsigned long *symbolsize
,
82 unsigned long *offset
,
83 char **modname
, char *namebuf
)
88 static inline int sprint_symbol(char *buffer
, unsigned long addr
)
94 static inline int sprint_symbol_no_offset(char *buffer
, unsigned long addr
)
100 static inline int sprint_backtrace(char *buffer
, unsigned long addr
)
106 static inline int lookup_symbol_name(unsigned long addr
, char *symname
)
111 static inline int lookup_symbol_attrs(unsigned long addr
, unsigned long *size
, unsigned long *offset
, char *modname
, char *name
)
116 static inline int kallsyms_show_value(void)
121 /* Stupid that this does nothing, but I didn't create this mess. */
122 #define __print_symbol(fmt, addr)
123 #endif /*CONFIG_KALLSYMS*/
125 /* This macro allows us to keep printk typechecking */
126 static __printf(1, 2)
127 void __check_printsym_format(const char *fmt
, ...)
131 static inline void print_symbol(const char *fmt
, unsigned long addr
)
133 __check_printsym_format(fmt
, "");
134 __print_symbol(fmt
, (unsigned long)
135 __builtin_extract_return_addr((void *)addr
));
138 static inline void print_ip_sym(unsigned long ip
)
140 printk("[<%p>] %pS\n", (void *) ip
, (void *) ip
);
143 #endif /*_LINUX_KALLSYMS_H*/