aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/kallsyms.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/kallsyms.c')
-rw-r--r--kernel/kallsyms.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 38fc10ac7541..e694afa0eb8c 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -30,20 +30,19 @@
30#define all_var 0 30#define all_var 0
31#endif 31#endif
32 32
33/* These will be re-linked against their real values during the second link stage */ 33extern const unsigned long kallsyms_addresses[];
34extern const unsigned long kallsyms_addresses[] __attribute__((weak)); 34extern const u8 kallsyms_names[];
35extern const u8 kallsyms_names[] __attribute__((weak));
36 35
37/* tell the compiler that the count isn't in the small data section if the arch 36/* tell the compiler that the count isn't in the small data section if the arch
38 * has one (eg: FRV) 37 * has one (eg: FRV)
39 */ 38 */
40extern const unsigned long kallsyms_num_syms 39extern const unsigned long kallsyms_num_syms
41__attribute__((weak, section(".rodata"))); 40 __attribute__((__section__(".rodata")));
42 41
43extern const u8 kallsyms_token_table[] __attribute__((weak)); 42extern const u8 kallsyms_token_table[];
44extern const u16 kallsyms_token_index[] __attribute__((weak)); 43extern const u16 kallsyms_token_index[];
45 44
46extern const unsigned long kallsyms_markers[] __attribute__((weak)); 45extern const unsigned long kallsyms_markers[];
47 46
48static inline int is_kernel_inittext(unsigned long addr) 47static inline int is_kernel_inittext(unsigned long addr)
49{ 48{
@@ -168,9 +167,6 @@ static unsigned long get_symbol_pos(unsigned long addr,
168 unsigned long symbol_start = 0, symbol_end = 0; 167 unsigned long symbol_start = 0, symbol_end = 0;
169 unsigned long i, low, high, mid; 168 unsigned long i, low, high, mid;
170 169
171 /* This kernel should never had been booted. */
172 BUG_ON(!kallsyms_addresses);
173
174 /* do a binary search on the sorted kallsyms_addresses array */ 170 /* do a binary search on the sorted kallsyms_addresses array */
175 low = 0; 171 low = 0;
176 high = kallsyms_num_syms; 172 high = kallsyms_num_syms;
@@ -260,7 +256,6 @@ const char *kallsyms_lookup(unsigned long addr,
260 /* see if it's in a module */ 256 /* see if it's in a module */
261 return module_address_lookup(addr, symbolsize, offset, modname, 257 return module_address_lookup(addr, symbolsize, offset, modname,
262 namebuf); 258 namebuf);
263 return NULL;
264} 259}
265 260
266int lookup_symbol_name(unsigned long addr, char *symname) 261int lookup_symbol_name(unsigned long addr, char *symname)
@@ -305,17 +300,24 @@ int sprint_symbol(char *buffer, unsigned long address)
305 char *modname; 300 char *modname;
306 const char *name; 301 const char *name;
307 unsigned long offset, size; 302 unsigned long offset, size;
308 char namebuf[KSYM_NAME_LEN]; 303 int len;
309 304
310 name = kallsyms_lookup(address, &size, &offset, &modname, namebuf); 305 name = kallsyms_lookup(address, &size, &offset, &modname, buffer);
311 if (!name) 306 if (!name)
312 return sprintf(buffer, "0x%lx", address); 307 return sprintf(buffer, "0x%lx", address);
313 308
309 if (name != buffer)
310 strcpy(buffer, name);
311 len = strlen(buffer);
312 buffer += len;
313
314 if (modname) 314 if (modname)
315 return sprintf(buffer, "%s+%#lx/%#lx [%s]", name, offset, 315 len += sprintf(buffer, "+%#lx/%#lx [%s]",
316 size, modname); 316 offset, size, modname);
317 else 317 else
318 return sprintf(buffer, "%s+%#lx/%#lx", name, offset, size); 318 len += sprintf(buffer, "+%#lx/%#lx", offset, size);
319
320 return len;
319} 321}
320 322
321/* Look up a kernel symbol and print it to the kernel messages. */ 323/* Look up a kernel symbol and print it to the kernel messages. */