blob: 849043ce4ed6ad811d77decf3463238a1c9a6f82 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* 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
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
9#define KSYM_NAME_LEN 127
10
11#ifdef CONFIG_KALLSYMS
12/* Lookup the address for a symbol. Returns 0 if not found. */
13unsigned long kallsyms_lookup_name(const char *name);
14
15/* Lookup an address. modname is set to NULL if it's in the kernel. */
16const char *kallsyms_lookup(unsigned long addr,
17 unsigned long *symbolsize,
18 unsigned long *offset,
19 char **modname, char *namebuf);
20
21/* Replace "%s" in format with address, if found */
22extern void __print_symbol(const char *fmt, unsigned long address);
23
24#else /* !CONFIG_KALLSYMS */
25
26static inline unsigned long kallsyms_lookup_name(const char *name)
27{
28 return 0;
29}
30
31static inline const char *kallsyms_lookup(unsigned long addr,
32 unsigned long *symbolsize,
33 unsigned long *offset,
34 char **modname, char *namebuf)
35{
36 return NULL;
37}
38
39/* Stupid that this does nothing, but I didn't create this mess. */
40#define __print_symbol(fmt, addr)
41#endif /*CONFIG_KALLSYMS*/
42
43/* This macro allows us to keep printk typechecking */
44static void __check_printsym_format(const char *fmt, ...)
45__attribute__((format(printf,1,2)));
46static inline void __check_printsym_format(const char *fmt, ...)
47{
48}
49/* ia64 and ppc64 use function descriptors, which contain the real address */
50#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
51#define print_fn_descriptor_symbol(fmt, addr) \
52do { \
53 unsigned long *__faddr = (unsigned long*) addr; \
54 print_symbol(fmt, __faddr[0]); \
55} while (0)
56#else
57#define print_fn_descriptor_symbol(fmt, addr) print_symbol(fmt, addr)
58#endif
59
Heiko Carstensb02454f2006-07-03 00:24:06 -070060static inline void print_symbol(const char *fmt, unsigned long addr)
61{
62 __check_printsym_format(fmt, "");
63 __print_symbol(fmt, (unsigned long)
64 __builtin_extract_return_addr((void *)addr));
65}
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
Heiko Carstens8d8fdf52006-07-03 00:24:25 -070067#ifndef CONFIG_64BIT
68#define print_ip_sym(ip) \
69do { \
70 printk("[<%08lx>]", ip); \
71 print_symbol(" %s\n", ip); \
72} while(0)
73#else
74#define print_ip_sym(ip) \
75do { \
76 printk("[<%016lx>]", ip); \
77 print_symbol(" %s\n", ip); \
78} while(0)
79#endif
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081#endif /*_LINUX_KALLSYMS_H*/