]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - include/linux/kallsyms.h
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
9 #define KSYM_NAME_LEN 127
11 #ifdef CONFIG_KALLSYMS
12 /* Lookup the address for a symbol. Returns 0 if not found. */
13 unsigned long kallsyms_lookup_name(const char *name
);
15 extern int kallsyms_lookup_size_offset(unsigned long addr
,
16 unsigned long *symbolsize
,
17 unsigned long *offset
);
19 /* Lookup an address. modname is set to NULL if it's in the kernel. */
20 const char *kallsyms_lookup(unsigned long addr
,
21 unsigned long *symbolsize
,
22 unsigned long *offset
,
23 char **modname
, char *namebuf
);
25 /* Replace "%s" in format with address, if found */
26 extern void __print_symbol(const char *fmt
, unsigned long address
);
28 #else /* !CONFIG_KALLSYMS */
30 static inline unsigned long kallsyms_lookup_name(const char *name
)
35 static inline int kallsyms_lookup_size_offset(unsigned long addr
,
36 unsigned long *symbolsize
,
37 unsigned long *offset
)
42 static inline const char *kallsyms_lookup(unsigned long addr
,
43 unsigned long *symbolsize
,
44 unsigned long *offset
,
45 char **modname
, char *namebuf
)
50 /* Stupid that this does nothing, but I didn't create this mess. */
51 #define __print_symbol(fmt, addr)
52 #endif /*CONFIG_KALLSYMS*/
54 /* This macro allows us to keep printk typechecking */
55 static void __check_printsym_format(const char *fmt
, ...)
56 __attribute__((format(printf
,1,2)));
57 static inline void __check_printsym_format(const char *fmt
, ...)
60 /* ia64 and ppc64 use function descriptors, which contain the real address */
61 #if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
62 #define print_fn_descriptor_symbol(fmt, addr) \
64 unsigned long *__faddr = (unsigned long*) addr; \
65 print_symbol(fmt, __faddr[0]); \
68 #define print_fn_descriptor_symbol(fmt, addr) print_symbol(fmt, addr)
71 static inline void print_symbol(const char *fmt
, unsigned long addr
)
73 __check_printsym_format(fmt
, "");
74 __print_symbol(fmt
, (unsigned long)
75 __builtin_extract_return_addr((void *)addr
));
79 #define print_ip_sym(ip) \
81 printk("[<%08lx>]", ip); \
82 print_symbol(" %s\n", ip); \
85 #define print_ip_sym(ip) \
87 printk("[<%016lx>]", ip); \
88 print_symbol(" %s\n", ip); \
92 #endif /*_LINUX_KALLSYMS_H*/