kallsyms: unify 32- and 64-bit code
[GitHub/mt8127/android_kernel_alcatel_ttab.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
LT
15
16#ifdef CONFIG_KALLSYMS
17/* Lookup the address for a symbol. Returns 0 if not found. */
18unsigned long kallsyms_lookup_name(const char *name);
19
ffc50891
FBH
20extern int kallsyms_lookup_size_offset(unsigned long addr,
21 unsigned long *symbolsize,
22 unsigned long *offset);
23
1da177e4
LT
24/* Lookup an address. modname is set to NULL if it's in the kernel. */
25const char *kallsyms_lookup(unsigned long addr,
26 unsigned long *symbolsize,
27 unsigned long *offset,
28 char **modname, char *namebuf);
29
42e38083
RP
30/* Look up a kernel symbol and return it in a text buffer. */
31extern int sprint_symbol(char *buffer, unsigned long address);
32
33/* Look up a kernel symbol and print it to the kernel messages. */
1da177e4
LT
34extern void __print_symbol(const char *fmt, unsigned long address);
35
9d65cb4a 36int lookup_symbol_name(unsigned long addr, char *symname);
a5c43dae 37int lookup_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name);
9d65cb4a 38
1da177e4
LT
39#else /* !CONFIG_KALLSYMS */
40
41static inline unsigned long kallsyms_lookup_name(const char *name)
42{
43 return 0;
44}
45
ffc50891
FBH
46static inline int kallsyms_lookup_size_offset(unsigned long addr,
47 unsigned long *symbolsize,
48 unsigned long *offset)
49{
50 return 0;
51}
52
1da177e4
LT
53static inline const char *kallsyms_lookup(unsigned long addr,
54 unsigned long *symbolsize,
55 unsigned long *offset,
56 char **modname, char *namebuf)
57{
58 return NULL;
59}
60
42e38083
RP
61static inline int sprint_symbol(char *buffer, unsigned long addr)
62{
63 *buffer = '\0';
64 return 0;
65}
66
9d65cb4a
AD
67static inline int lookup_symbol_name(unsigned long addr, char *symname)
68{
69 return -ERANGE;
70}
71
a5c43dae
AD
72static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name)
73{
74 return -ERANGE;
75}
76
1da177e4
LT
77/* Stupid that this does nothing, but I didn't create this mess. */
78#define __print_symbol(fmt, addr)
79#endif /*CONFIG_KALLSYMS*/
80
81/* This macro allows us to keep printk typechecking */
82static void __check_printsym_format(const char *fmt, ...)
83__attribute__((format(printf,1,2)));
84static inline void __check_printsym_format(const char *fmt, ...)
85{
86}
1da177e4 87
b02454f4
HC
88static inline void print_symbol(const char *fmt, unsigned long addr)
89{
90 __check_printsym_format(fmt, "");
91 __print_symbol(fmt, (unsigned long)
92 __builtin_extract_return_addr((void *)addr));
93}
1da177e4 94
a442ac51
LT
95/*
96 * Pretty-print a function pointer.
97 *
98 * ia64 and ppc64 function pointers are really function descriptors,
99 * which contain a pointer the real address.
100 */
101static inline void print_fn_descriptor_symbol(const char *fmt, void *addr)
102{
103#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
104 addr = *(void **)addr;
105#endif
106 print_symbol(fmt, (unsigned long)addr);
107}
108
2711b793
VN
109static inline void print_ip_sym(unsigned long ip)
110{
111 printk("[<%p>]", (void *) ip);
112 print_symbol(" %s\n", ip);
113}
8d8fdf5c 114
1da177e4 115#endif /*_LINUX_KALLSYMS_H*/