Lines Matching +full:look +full:- +full:up

1 // SPDX-License-Identifier: GPL-2.0-only
3 * kallsyms.c: in-kernel printing of symbolic oopses and stack traces.
5 * Rewritten and vastly simplified by Rusty Russell for in-kernel
75 len--; in kallsyms_expand_symbol()
83 maxlen--; in kallsyms_expand_symbol()
105 * Get just the first code, look it up in the token table, in kallsyms_get_symbol_type()
128 * Sequentially scan all the symbols up to the point we're searching in get_symbol_offset()
137 * If MSB is 1, it is a "big" symbol, so we need to look into in get_symbol_offset()
146 return name - kallsyms_names; in get_symbol_offset()
151 /* values are unsigned offsets if --absolute-percpu is not in effect */ in kallsyms_sym_address()
159 /* ...and negative offsets are relative to kallsyms_relative_base - 1 */ in kallsyms_sym_address()
160 return kallsyms_relative_base - 1 - kallsyms_offsets[idx]; in kallsyms_sym_address()
183 high = kallsyms_num_syms - 1; in kallsyms_lookup_names()
186 mid = low + (high - low) / 2; in kallsyms_lookup_names()
194 high = mid - 1; in kallsyms_lookup_names()
200 return -ESRCH; in kallsyms_lookup_names()
204 seq = get_symbol_seq(low - 1); in kallsyms_lookup_names()
209 low--; in kallsyms_lookup_names()
215 while (high < kallsyms_num_syms - 1) { in kallsyms_lookup_names()
297 while (high - low > 1) { in get_symbol_pos()
298 mid = low + (high - low) / 2; in get_symbol_pos()
309 while (low && kallsyms_sym_address(low-1) == kallsyms_sym_address(low)) in get_symbol_pos()
310 --low; in get_symbol_pos()
314 /* Search for next non-aliased symbol. */ in get_symbol_pos()
333 *symbolsize = symbol_end - symbol_start; in get_symbol_pos()
335 *offset = addr - symbol_start; in get_symbol_pos()
363 namebuf[KSYM_NAME_LEN - 1] = 0; in kallsyms_lookup_buildid()
397 * - modname is set to NULL if it's in the kernel.
398 * - We guarantee that the returned name is valid until we reschedule even if.
400 * - We also guarantee that modname will be valid until rescheduled.
419 symname[KSYM_NAME_LEN - 1] = '\0'; in lookup_symbol_name()
434 /* Look up a kernel symbol and return it in a text buffer. */
447 return sprintf(buffer, "0x%lx", address - symbol_offset); in __sprint_symbol()
449 offset -= symbol_offset; in __sprint_symbol()
472 * sprint_symbol - Look up a kernel symbol and return it in a text buffer
476 * This function looks up a kernel symbol with @address and stores its name,
489 * sprint_symbol_build_id - Look up a kernel symbol and return it in a text buffer
493 * This function looks up a kernel symbol with @address and stores its name,
506 * sprint_symbol_no_offset - Look up a kernel symbol and return it in a text buffer
510 * This function looks up a kernel symbol with @address and stores its name
523 * sprint_backtrace - Look up a backtrace symbol and return it in a text buffer
529 * tail-call to the function marked "noreturn", gcc optimized out code after
530 * the call so that the stack-saved return address could point outside of the
538 return __sprint_symbol(buffer, address, -1, 1, 0); in sprint_backtrace()
542 * sprint_backtrace_build_id - Look up a backtrace symbol and return it in a text buffer
548 * tail-call to the function marked "noreturn", gcc optimized out code after
549 * the call so that the stack-saved return address could point outside of the
558 return __sprint_symbol(buffer, address, -1, 1, 1); in sprint_backtrace_build_id()
578 int ret = module_get_kallsym(iter->pos - kallsyms_num_syms, in get_ksymbol_mod()
579 &iter->value, &iter->type, in get_ksymbol_mod()
580 iter->name, iter->module_name, in get_ksymbol_mod()
581 &iter->exported); in get_ksymbol_mod()
583 iter->pos_mod_end = iter->pos; in get_ksymbol_mod()
597 int ret = ftrace_mod_get_kallsym(iter->pos - iter->pos_mod_end, in get_ksymbol_ftrace_mod()
598 &iter->value, &iter->type, in get_ksymbol_ftrace_mod()
599 iter->name, iter->module_name, in get_ksymbol_ftrace_mod()
600 &iter->exported); in get_ksymbol_ftrace_mod()
602 iter->pos_ftrace_mod_end = iter->pos; in get_ksymbol_ftrace_mod()
613 strscpy(iter->module_name, "bpf", MODULE_NAME_LEN); in get_ksymbol_bpf()
614 iter->exported = 0; in get_ksymbol_bpf()
615 ret = bpf_get_kallsym(iter->pos - iter->pos_ftrace_mod_end, in get_ksymbol_bpf()
616 &iter->value, &iter->type, in get_ksymbol_bpf()
617 iter->name); in get_ksymbol_bpf()
619 iter->pos_bpf_end = iter->pos; in get_ksymbol_bpf()
633 strscpy(iter->module_name, "__builtin__kprobes", MODULE_NAME_LEN); in get_ksymbol_kprobe()
634 iter->exported = 0; in get_ksymbol_kprobe()
635 return kprobe_get_kallsym(iter->pos - iter->pos_bpf_end, in get_ksymbol_kprobe()
636 &iter->value, &iter->type, in get_ksymbol_kprobe()
637 iter->name) < 0 ? 0 : 1; in get_ksymbol_kprobe()
643 unsigned off = iter->nameoff; in get_ksymbol_core()
645 iter->module_name[0] = '\0'; in get_ksymbol_core()
646 iter->value = kallsyms_sym_address(iter->pos); in get_ksymbol_core()
648 iter->type = kallsyms_get_symbol_type(off); in get_ksymbol_core()
650 off = kallsyms_expand_symbol(off, iter->name, ARRAY_SIZE(iter->name)); in get_ksymbol_core()
652 return off - iter->nameoff; in get_ksymbol_core()
657 iter->name[0] = '\0'; in reset_iter()
658 iter->nameoff = get_symbol_offset(new_pos); in reset_iter()
659 iter->pos = new_pos; in reset_iter()
661 iter->pos_mod_end = 0; in reset_iter()
662 iter->pos_ftrace_mod_end = 0; in reset_iter()
663 iter->pos_bpf_end = 0; in reset_iter()
669 * in iter->pos_..._end as each section is added, and so can be used to
674 iter->pos = pos; in update_iter_mod()
676 if ((!iter->pos_mod_end || iter->pos_mod_end > pos) && in update_iter_mod()
680 if ((!iter->pos_ftrace_mod_end || iter->pos_ftrace_mod_end > pos) && in update_iter_mod()
684 if ((!iter->pos_bpf_end || iter->pos_bpf_end > pos) && in update_iter_mod()
699 if (pos != iter->pos) in update_iter()
702 iter->nameoff += get_ksymbol_core(iter); in update_iter()
703 iter->pos++; in update_iter()
712 if (!update_iter(m->private, *pos)) in s_next()
719 if (!update_iter(m->private, *pos)) in s_start()
721 return m->private; in s_start()
731 struct kallsym_iter *iter = m->private; in s_show()
734 if (!iter->name[0]) in s_show()
737 value = iter->show_value ? (void *)iter->value : NULL; in s_show()
739 if (iter->module_name[0]) { in s_show()
746 type = iter->exported ? toupper(iter->type) : in s_show()
747 tolower(iter->type); in s_show()
749 type, iter->name, iter->module_name); in s_show()
752 iter->type, iter->name); in s_show()
782 ctx.ksym = m ? m->private : NULL; in ksym_prog_seq_show()
815 iter->show_value = kallsyms_show_value(current_cred()); in bpf_iter_ksym_init()
856 * We keep iterator in m->private, since normal case is to in kallsyms_open()
863 return -ENOMEM; in kallsyms_open()
870 iter->show_value = kallsyms_show_value(file->f_cred); in kallsyms_open()