[PATCH 1/2] kbuild: keep __mcount_loc table through dead code elimination

From: Marcin Nowakowski
Date: Thu Dec 22 2016 - 04:41:08 EST


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 <marcin.nowakowski@xxxxxxxxxx>
Acked-by: Nicholas Piggin <npiggin@xxxxxxxxx>
---
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