Create kallsyms_lookup_size_offset()
PATCH 1/1 Create kallsyms_lookup_size_offset()
Some uses of kallsyms_lookup() do not need to find out the name of a symbol and its module's name it belongs. This is specially true in arch specific code, which needs to unwind the stack to show the back trace during oops (mips is an example). In this specific case, we just need to retreive the function's size and the offset of the active intruction inside it.
This simple patch adds a new entry "kallsyms_lookup_size_offset()" This new entry does exactly the same as kallsyms_lookup() but does not require any buffers to store any names.
It returns 0 if it fails otherwise 1.
Signed-off-by Franck Bui-Huu <[email protected]>
--- include/linux/kallsyms.h | 11 ++++ kernel/kallsyms.c | 125 ++++++++++++++++++++++++++++++---------------- kernel/module.c | 3 + 3 files changed, 94 insertions(+), 45 deletions(-)
include/linux/kallsyms.h +11 -0
@@ -12,6 +12,10 @@ #ifdef CONFIG_KALLSYMS/* Lookup the address for a symbol. Returns 0 if not found. */ unsigned long kallsyms_lookup_name (const char *name); +extern int kallsyms_lookup_size_offset (unsigned long addr, +unsigned long *symbolsize, +unsigned long *offset); +/* Lookup an address. modname is set to NULL if it's in the kernel. */ const char *kallsyms_lookup(unsigned long addr, unsigned long *symbolsize,
@@ -28,6 +32,13 @@ static inline unsigned long kallsyms_looreturn 0 ; } +static inline int kallsyms_lookup_size_offset (unsigned long addr, +unsigned long *symbolsize, +unsigned long *offset) +{ +return 0 ; +} + static inline const char *kallsyms_lookup(unsigned long addr, unsigned long *symbolsize, unsigned long *offset,
kernel/kallsyms.c +81 -44
150 lines not on this page · raw message
kernel/module.c +2 -1
@@ -2012,7 +2012,8 @@ const char *module_address_lookup(unsignlist_for_each_entry (mod, &modules, list) {if (within (addr, mod->module_init, mod->init_size) ||within (addr, mod->module_core, mod->core_size)) { - *modname = mod->name; +if (modname) + *modname = mod->name;return get_ksymbol (mod, addr, size, offset); } }
Signature · 1 line
1.4.2