tracing/probes: Fix build break on !CONFIG_KPROBE_EVENT
authorNamhyung Kim <namhyung.kim@lge.com>
Fri, 3 Jan 2014 05:12:46 +0000 (14:12 +0900)
committerSteven Rostedt <rostedt@goodmis.org>
Fri, 3 Jan 2014 20:27:18 +0000 (15:27 -0500)
When kprobe-based dynamic event tracer is not enabled, it caused
following build error:

   kernel/built-in.o: In function `traceprobe_update_arg':
   (.text+0x10c8dd): undefined reference to `fetch_symbol_u8'
   kernel/built-in.o: In function `traceprobe_update_arg':
   (.text+0x10c8e9): undefined reference to `fetch_symbol_u16'
   kernel/built-in.o: In function `traceprobe_update_arg':
   (.text+0x10c8f5): undefined reference to `fetch_symbol_u32'
   kernel/built-in.o: In function `traceprobe_update_arg':
   (.text+0x10c901): undefined reference to `fetch_symbol_u64'
   kernel/built-in.o: In function `traceprobe_update_arg':
   (.text+0x10c909): undefined reference to `fetch_symbol_string'
   kernel/built-in.o: In function `traceprobe_update_arg':
   (.text+0x10c913): undefined reference to `fetch_symbol_string_size'
   ...

It was due to the fetch methods are referred from CHECK_FETCH_FUNCS
macro and since it was only defined in trace_kprobe.c.  Move NULL
definition of such fetch functions to the header file.

Note, it also requires CONFIG_BRANCH_PROFILING enabled to trigger
this failure as well. This is because the "fetch_symbol_*" variables
are referenced in a "else if" statement that will only call
update_symbol_cache(), which is a static inline stub function
when CONFIG_KPROBE_EVENT is not enabled. gcc is smart enough
to optimize this "else if" out and that also removes the code that
references the undefined variables.

But when BRANCH_PROFILING is enabled, it fools gcc into keeping
the if statement around and thus references the undefined symbols
and fails to build.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/trace_probe.h
kernel/trace/trace_uprobe.c

index e29d743..b73574a 100644 (file)
@@ -243,6 +243,14 @@ unsigned long update_symbol_cache(struct symbol_cache *sc);
 void free_symbol_cache(struct symbol_cache *sc);
 struct symbol_cache *alloc_symbol_cache(const char *sym, long offset);
 #else
+/* uprobes do not support symbol fetch methods */
+#define fetch_symbol_u8                        NULL
+#define fetch_symbol_u16               NULL
+#define fetch_symbol_u32               NULL
+#define fetch_symbol_u64               NULL
+#define fetch_symbol_string            NULL
+#define fetch_symbol_string_size       NULL
+
 struct symbol_cache {
 };
 static inline unsigned long __used update_symbol_cache(struct symbol_cache *sc)
index 1fdea6d..79e52d9 100644 (file)
@@ -172,14 +172,6 @@ static __kprobes void FETCH_FUNC_NAME(memory, string_size)(struct pt_regs *regs,
                *(u32 *)dest = len;
 }
 
-/* uprobes do not support symbol fetch methods */
-#define fetch_symbol_u8                        NULL
-#define fetch_symbol_u16               NULL
-#define fetch_symbol_u32               NULL
-#define fetch_symbol_u64               NULL
-#define fetch_symbol_string            NULL
-#define fetch_symbol_string_size       NULL
-
 static unsigned long translate_user_vaddr(void *file_offset)
 {
        unsigned long base_addr;