Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kallsyms: only build {,module_}kallsyms_on_each_symbol when required

kallsyms_on_each_symbol and module_kallsyms_on_each_symbol are only used
by the livepatching code, so don't build them if livepatching is not
enabled.

Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>

authored by

Christoph Hellwig and committed by
Jessica Yu
3e355205 013c1667

+12 -25
+4 -13
include/linux/kallsyms.h
··· 71 71 return ptr; 72 72 } 73 73 74 - #ifdef CONFIG_KALLSYMS 75 - /* Lookup the address for a symbol. Returns 0 if not found. */ 76 - unsigned long kallsyms_lookup_name(const char *name); 77 - 78 - /* Call a function on each kallsyms symbol in the core kernel */ 79 74 int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, 80 75 unsigned long), 81 76 void *data); 77 + 78 + #ifdef CONFIG_KALLSYMS 79 + /* Lookup the address for a symbol. Returns 0 if not found. */ 80 + unsigned long kallsyms_lookup_name(const char *name); 82 81 83 82 extern int kallsyms_lookup_size_offset(unsigned long addr, 84 83 unsigned long *symbolsize, ··· 103 104 #else /* !CONFIG_KALLSYMS */ 104 105 105 106 static inline unsigned long kallsyms_lookup_name(const char *name) 106 - { 107 - return 0; 108 - } 109 - 110 - static inline int kallsyms_on_each_symbol(int (*fn)(void *, const char *, 111 - struct module *, 112 - unsigned long), 113 - void *data) 114 107 { 115 108 return 0; 116 109 }
+4 -12
include/linux/module.h
··· 608 608 /* Look for this name: can be of form module:name. */ 609 609 unsigned long module_kallsyms_lookup_name(const char *name); 610 610 611 - int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, 612 - struct module *, unsigned long), 613 - void *data); 614 - 615 611 extern void __noreturn __module_put_and_exit(struct module *mod, 616 612 long code); 617 613 #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code) ··· 791 795 return 0; 792 796 } 793 797 794 - static inline int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, 795 - struct module *, 796 - unsigned long), 797 - void *data) 798 - { 799 - return 0; 800 - } 801 - 802 798 static inline int register_module_notifier(struct notifier_block *nb) 803 799 { 804 800 /* no events will happen anyway, so this can always succeed */ ··· 878 890 return true; 879 891 } 880 892 #endif /* CONFIG_MODULE_SIG */ 893 + 894 + int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, 895 + struct module *, unsigned long), 896 + void *data); 881 897 882 898 #endif /* _LINUX_MODULE_H */
+2
kernel/kallsyms.c
··· 177 177 return module_kallsyms_lookup_name(name); 178 178 } 179 179 180 + #ifdef CONFIG_LIVEPATCH 180 181 /* 181 182 * Iterate over all symbols in vmlinux. For symbols from modules use 182 183 * module_kallsyms_on_each_symbol instead. ··· 199 198 } 200 199 return 0; 201 200 } 201 + #endif /* CONFIG_LIVEPATCH */ 202 202 203 203 static unsigned long get_symbol_pos(unsigned long addr, 204 204 unsigned long *symbolsize,
+2
kernel/module.c
··· 4488 4488 return ret; 4489 4489 } 4490 4490 4491 + #ifdef CONFIG_LIVEPATCH 4491 4492 int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, 4492 4493 struct module *, unsigned long), 4493 4494 void *data) ··· 4519 4518 mutex_unlock(&module_mutex); 4520 4519 return ret; 4521 4520 } 4521 + #endif /* CONFIG_LIVEPATCH */ 4522 4522 #endif /* CONFIG_KALLSYMS */ 4523 4523 4524 4524 /* Maximum number of characters written by module_flags() */