[PATCH 2/2] livepatch: Make sure the TOC is handled when detecting ftrace location

From: root
Date: Tue Feb 02 2016 - 09:35:06 EST


There seems to be a bug in gcc on PPC. It does not handle TOC
if the function does not access global variables or functions
by default. But it should when profiling is enabled.

This patch works around this problem by adding a call
to a global function.

This patch is for testing only!
---
kernel/livepatch/ftrace-test.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/kernel/livepatch/ftrace-test.c b/kernel/livepatch/ftrace-test.c
index 22f0c54bf7b3..a3b7aabb67e5 100644
--- a/kernel/livepatch/ftrace-test.c
+++ b/kernel/livepatch/ftrace-test.c
@@ -1,6 +1,9 @@
/* Sample code to figure out mcount location offset */
+#include <linux/printk.h>
+

int test(int a)
{
+ printk("%d\n", a);
return ++a;
}
--
1.8.5.6