diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index dd38c97933f134ba5ade7503edba0baa3dff419f..da40461793f940887d25a4cc8e4e857aa2bf503d 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -110,9 +110,16 @@ #endif #ifdef CONFIG_FTRACE_MCOUNT_RECORD +/* + * The ftrace call sites are logged to a section whose name depends on the + * compiler option used. A given kernel image will only use one, AKA + * FTRACE_CALLSITE_SECTION. We capture all of them here to avoid header + * dependencies for FTRACE_CALLSITE_SECTION's definition. + */ #define MCOUNT_REC() . = ALIGN(8); \ __start_mcount_loc = .; \ KEEP(*(__mcount_loc)) \ + KEEP(*(__patchable_function_entries)) \ __stop_mcount_loc = .; #else #define MCOUNT_REC() diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index e15ef271d6e4d02a782347b1101811197345cb02..cb4d958a77ffeeb2454aebe3ea0b8b87b2d4fd78 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -744,6 +744,11 @@ static inline unsigned long get_lock_parent_ip(void) #ifdef CONFIG_FTRACE_MCOUNT_RECORD extern void ftrace_init(void); +#ifdef CC_USING_PATCHABLE_FUNCTION_ENTRY +#define FTRACE_CALLSITE_SECTION "__patchable_function_entries" +#else +#define FTRACE_CALLSITE_SECTION "__mcount_loc" +#endif #else static inline void ftrace_init(void) { } #endif diff --git a/kernel/module.c b/kernel/module.c index d3aaec62c1423ae08e89f38d779d6a4454220ad4..67bafd0eea7ba7f8b267a2e0f463f48cbbc827ff 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -3138,7 +3138,7 @@ static int find_module_sections(struct module *mod, struct load_info *info) #endif #ifdef CONFIG_FTRACE_MCOUNT_RECORD /* sechdrs[0].sh_size is always zero */ - mod->ftrace_callsites = section_objs(info, "__mcount_loc", + mod->ftrace_callsites = section_objs(info, FTRACE_CALLSITE_SECTION, sizeof(*mod->ftrace_callsites), &mod->num_ftrace_callsites); #endif