When CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is enabled we must ensure
__mcount_loc is preserved, as otherwise there are no valid entries for
ftrace to work with.

Fixes: 4b89b7f7aad5 ('kbuild: keep data tables through dead code elimination')

Signed-off-by: Marcin Nowakowski <[email protected]>
Acked-by: Nicholas Piggin <[email protected]>
---
 include/asm-generic/vmlinux.lds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/asm-generic/vmlinux.lds.h 
b/include/asm-generic/vmlinux.lds.h
index 0968d13..f492aa4 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -89,7 +89,7 @@
 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
 #define MCOUNT_REC()   . = ALIGN(8);                           \
                        VMLINUX_SYMBOL(__start_mcount_loc) = .; \
-                       *(__mcount_loc)                         \
+                       KEEP(*(__mcount_loc))                   \
                        VMLINUX_SYMBOL(__stop_mcount_loc) = .;
 #else
 #define MCOUNT_REC()
-- 
2.7.4

Reply via email to