[RFC PATCH 4/4] vmlinux.lds: define conditional sections with macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Rob Herring <robh@xxxxxxxxxx>

Various section definitions all use the same pattern. Create a common
macro to define these.

There are a few other instances with a different symbol naming convention
which could also be converted over to use this.

Signed-off-by: Rob Herring <robh@xxxxxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>
---
 include/asm-generic/vmlinux.lds.h | 82 +++++++++++++--------------------------
 1 file changed, 27 insertions(+), 55 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 000a0f30..9a08039 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -84,61 +84,33 @@
 #define MEM_DISCARD(sec) *(.mem##sec)
 #endif
 
-#ifdef CONFIG_FTRACE_MCOUNT_RECORD
-#define MCOUNT_REC()	. = ALIGN(8);				\
-			VMLINUX_SYMBOL(__start_mcount_loc) = .; \
-			*(__mcount_loc)				\
-			VMLINUX_SYMBOL(__stop_mcount_loc) = .;
-#else
-#define MCOUNT_REC()
-#endif
-
-#ifdef CONFIG_TRACE_BRANCH_PROFILING
-#define LIKELY_PROFILE()	VMLINUX_SYMBOL(__start_annotated_branch_profile) = .; \
-				*(_ftrace_annotated_branch)			      \
-				VMLINUX_SYMBOL(__stop_annotated_branch_profile) = .;
-#else
-#define LIKELY_PROFILE()
-#endif
-
-#ifdef CONFIG_PROFILE_ALL_BRANCHES
-#define BRANCH_PROFILE()	VMLINUX_SYMBOL(__start_branch_profile) = .;   \
-				*(_ftrace_branch)			      \
-				VMLINUX_SYMBOL(__stop_branch_profile) = .;
-#else
-#define BRANCH_PROFILE()
-#endif
-
-#ifdef CONFIG_EVENT_TRACING
-#define FTRACE_EVENTS()	. = ALIGN(8);					\
-			VMLINUX_SYMBOL(__start_ftrace_events) = .;	\
-			*(_ftrace_events)				\
-			VMLINUX_SYMBOL(__stop_ftrace_events) = .;
-#else
-#define FTRACE_EVENTS()
-#endif
-
-#ifdef CONFIG_TRACING
-#define TRACE_PRINTKS() VMLINUX_SYMBOL(__start___trace_bprintk_fmt) = .;      \
-			 *(__trace_printk_fmt) /* Trace_printk fmt' pointer */ \
-			 VMLINUX_SYMBOL(__stop___trace_bprintk_fmt) = .;
-#define TRACEPOINT_STR() VMLINUX_SYMBOL(__start___tracepoint_str) = .;	\
-			 *(__tracepoint_str) /* Trace_printk fmt' pointer */ \
-			 VMLINUX_SYMBOL(__stop___tracepoint_str) = .;
-#else
-#define TRACE_PRINTKS()
-#define TRACEPOINT_STR()
-#endif
-
-#ifdef CONFIG_FTRACE_SYSCALLS
-#define TRACE_SYSCALLS() . = ALIGN(8);					\
-			 VMLINUX_SYMBOL(__start_syscalls_metadata) = .;	\
-			 *(__syscalls_metadata)				\
-			 VMLINUX_SYMBOL(__stop_syscalls_metadata) = .;
-#else
-#define TRACE_SYSCALLS()
-#endif
-
+#define __DEF_SECT(cfg, align, sec, sym)	_DEF_SECT_##cfg(align, sec, sym)
+#define _DEF_SECT(cfg, align, sec, sym)		__DEF_SECT(cfg, align, sec, sym)
+#define DEF_SECTION_SYM(cfg, align, sec, sym)				\
+	_DEF_SECT(config_enabled(cfg), align, sec, sym)
+#define DEF_SECTION(cfg, align, sec)				\
+	_DEF_SECT(config_enabled(cfg), align, sec, sec)
+#define _DEF_SECT_0(align, sec, sym)
+#define _DEF_SECT_1(align, sec, sym)					\
+	. = ALIGN(align);						\
+	VMLINUX_SYMBOL(__start_##sym) = .;				\
+	*(##sec)							\
+	VMLINUX_SYMBOL(__stop_##sym) = .;
+
+#define MCOUNT_REC()		\
+	DEF_SECTION(CONFIG_FTRACE_MCOUNT_RECORD, 8, mcount_loc)
+#define LIKELY_PROFILE()	\
+	DEF_SECTION_SYM(CONFIG_TRACE_BRANCH_PROFILING, 1, _ftrace_annotated_branch, annotated_branch_profile)
+#define FTRACE_EVENTS()		\
+	DEF_SECTION(CONFIG_EVENT_TRACING, 8, ftrace_events)
+#define BRANCH_PROFILE()	\
+	DEF_SECTION_SYM(CONFIG_PROFILE_ALL_BRANCHES, 1, _ftrace_branch, branch_profile)
+#define TRACE_PRINTKS()		\
+	DEF_SECTION_SYM(CONFIG_TRACING, 1, __trace_printk_fmt, __trace_bprintk_fmt)
+#define TRACEPOINT_STR()	\
+	DEF_SECTION(CONFIG_TRACING, 1, __tracepoint_str)
+#define TRACE_SYSCALLS()	\
+	DEF_SECTION_SYM(CONFIG_FTRACE_SYSCALLS, 8, __syscalls_metadata, syscalls_metadata)
 
 #define ___OF_TABLE(cfg, name)	_OF_TABLE_##cfg(name)
 #define __OF_TABLE(cfg, name)	___OF_TABLE(cfg, name)
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux