1 /* Rewritten and vastly simplified by Rusty Russell for in-kernel
3 * Copyright 2002 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation
5 #ifndef _LINUX_KALLSYMS_H
6 #define _LINUX_KALLSYMS_H
8 #include <linux/errno.h>
9 #include <linux/kernel.h>
10 #include <linux/stddef.h>
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)
16 #ifdef CONFIG_KALLSYMS
17 /* Lookup the address for a symbol. Returns 0 if not found. */
18 unsigned long kallsyms_lookup_name(const char *name
);
20 extern int kallsyms_lookup_size_offset(unsigned long addr
,
21 unsigned long *symbolsize
,
22 unsigned long *offset
);
24 /* Lookup an address. modname is set to NULL if it's in the kernel. */
25 const char *kallsyms_lookup(unsigned long addr
,
26 unsigned long *symbolsize
,
27 unsigned long *offset
,
28 char **modname
, char *namebuf
);
30 /* Look up a kernel symbol and return it in a text buffer. */
31 extern int sprint_symbol(char *buffer
, unsigned long address
);
33 /* Look up a kernel symbol and print it to the kernel messages. */
34 extern void __print_symbol(const char *fmt
, unsigned long address
);
36 int lookup_symbol_name(unsigned long addr
, char *symname
);
37 int lookup_symbol_attrs(unsigned long addr
, unsigned long *size
, unsigned long *offset
, char *modname
, char *name
);
39 #else /* !CONFIG_KALLSYMS */
41 static inline unsigned long kallsyms_lookup_name(const char *name
)
46 static inline int kallsyms_lookup_size_offset(unsigned long addr
,
47 unsigned long *symbolsize
,
48 unsigned long *offset
)
53 static inline const char *kallsyms_lookup(unsigned long addr
,
54 unsigned long *symbolsize
,
55 unsigned long *offset
,
56 char **modname
, char *namebuf
)
61 static inline int sprint_symbol(char *buffer
, unsigned long addr
)
67 static inline int lookup_symbol_name(unsigned long addr
, char *symname
)
72 static inline int lookup_symbol_attrs(unsigned long addr
, unsigned long *size
, unsigned long *offset
, char *modname
, char *name
)
77 /* Stupid that this does nothing, but I didn't create this mess. */
78 #define __print_symbol(fmt, addr)
79 #endif /*CONFIG_KALLSYMS*/
81 /* This macro allows us to keep printk typechecking */
82 static void __check_printsym_format(const char *fmt
, ...)
83 __attribute__((format(printf
,1,2)));
84 static inline void __check_printsym_format(const char *fmt
, ...)
88 static inline void print_symbol(const char *fmt
, unsigned long addr
)
90 __check_printsym_format(fmt
, "");
91 __print_symbol(fmt
, (unsigned long)
92 __builtin_extract_return_addr((void *)addr
));
96 * Pretty-print a function pointer.
98 * ia64 and ppc64 function pointers are really function descriptors,
99 * which contain a pointer the real address.
101 static inline void print_fn_descriptor_symbol(const char *fmt
, void *addr
)
103 #if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
104 addr
= *(void **)addr
;
106 print_symbol(fmt
, (unsigned long)addr
);
109 static inline void print_ip_sym(unsigned long ip
)
111 printk("[<%p>] %pS\n", (void *) ip
, (void *) ip
);
114 #endif /*_LINUX_KALLSYMS_H*/