commit 44a374322bf4d1279ceac7ed35508ff6759af659
Author: Waseem Daher <wdaher@mit.edu>
Date:   Wed Sep 10 01:17:36 2008 -0400

    Ksplice: Add an option to compile with -ffunction-sections -fdata-sections
    
    This patch relies upon Denys Vlasenko's patch for compiling with
    -ffunction-sections and -fdata-sections: <http://lkml.org/lkml/2008/8/24/159>.
    
    This patch is a temporary placeholder to make it possible to link and boot an
    x86 or ARM kernel with -ffunction-sections and -fdata-sections enabled.  It
    causes modpost to warn about section names that it does not expect.
    
    Signed-off-by: Waseem Daher <wdaher@mit.edu>

diff --git a/Makefile b/Makefile
index 4ff83ea..6e02bd7 100644
--- a/Makefile
+++ b/Makefile
@@ -540,6 +540,10 @@ ifdef CONFIG_FTRACE
 KBUILD_CFLAGS	+= -pg
 endif
 
+ifdef CONFIG_FUNCTION_DATA_SECTIONS
+KBUILD_CFLAGS	+= -ffunction-sections -fdata-sections
+endif
+
 # We trigger additional mismatches with less inlining
 ifdef CONFIG_DEBUG_SECTION_MISMATCH
 KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index 7ec0ff5..63078dc 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -170,6 +170,7 @@ SECTIONS
 	.bss : {
 		__bss_start = .;	/* BSS				*/
 		*(.bss)
+		*(.bss.*)
 		*(COMMON)
 		_end = .;
 	}
diff --git a/arch/x86/boot/compressed/vmlinux_32.lds b/arch/x86/boot/compressed/vmlinux_32.lds
index f4358fb..f868fe0 100644
--- a/arch/x86/boot/compressed/vmlinux_32.lds
+++ b/arch/x86/boot/compressed/vmlinux_32.lds
@@ -21,6 +21,12 @@ SECTIONS
 		*(.text.*)
 		_etext = . ;
 	}
+	.got : {
+		_got = . ;	/* GOT */
+		*(.got)
+		*(.got.*)
+		_egot = . ;
+	}
 	.rodata : {
 		_rodata = . ;
 		*(.rodata)	 /* read-only data */
diff --git a/arch/x86/kernel/vmlinux_32.lds.S b/arch/x86/kernel/vmlinux_32.lds.S
index 4901fbe..fde82bd 100644
--- a/arch/x86/kernel/vmlinux_32.lds.S
+++ b/arch/x86/kernel/vmlinux_32.lds.S
@@ -192,6 +192,7 @@ SECTIONS
 	__bss_start = .;		/* BSS */
 	*(.bss.kernel.page_aligned)
 	*(.bss)
+	*(.bss.*)
 	. = ALIGN(4);
 	__bss_stop = .;
   	_end = . ;
diff --git a/arch/x86/kernel/vmlinux_64.lds.S b/arch/x86/kernel/vmlinux_64.lds.S
index fd43e58..0957fb0 100644
--- a/arch/x86/kernel/vmlinux_64.lds.S
+++ b/arch/x86/kernel/vmlinux_64.lds.S
@@ -223,6 +223,7 @@ SECTIONS
   .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
 	*(.bss.kernel.page_aligned)
 	*(.bss)
+	*(.bss.*)
 	}
   __bss_stop = .;
 
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 4a47ebd..f21a7e0 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -41,6 +41,7 @@
 /* .data section */
 #define DATA_DATA							\
 	*(.data)							\
+	*(.data.*)							\
 	*(.kernel.data.init.refok)					\
 	*(.ref.data)							\
 	DEV_KEEP(init.data)						\
@@ -223,6 +224,7 @@
 		ALIGN_FUNCTION();					\
 		*(.text.hot)						\
 		*(.text)						\
+		*(.text.*)						\
 		*(.ref.text)						\
 		*(.kernel.text.init.refok)				\
 		*(.kernel.exit.text.refok)				\
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 0b50481..1c9775b 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -548,6 +548,15 @@ config FRAME_POINTER
 	  some architectures or if you use external debuggers.
 	  If you don't debug the kernel, you can say N.
 
+config FUNCTION_DATA_SECTIONS
+	bool "Compile with -ffunction-sections -fdata-sections"
+	depends on !FTRACE
+	help
+	  If you say Y here the compiler will give each function
+	  and data structure its own ELF section.
+
+	  If unsure, say N.
+
 config BOOT_PRINTK_DELAY
 	bool "Delay each boot printk message by N milliseconds"
 	depends on DEBUG_KERNEL && PRINTK && GENERIC_CALIBRATE_DELAY
