[PATCH 1/2] section garbage collection for i386

From: Denys Vlasenko
Date: Wed Sep 12 2007 - 16:24:39 EST


Hi Sam,

This patch is preparatory: it adds a few KEEP() directives where
I forgot them in previous patch set, adds comments which explains
places where KEEP() is definitely not needed, and fixes i386 vdso generation
in an "obviously safe" way.

Please apply.

Signed-off-by: Denys Vlasenko <vda.linux@xxxxxxxxxxxxxx>
--
vda
diff -urpN linux-2.6.23-rc4.gc4/arch/i386/kernel/vsyscall.lds.S linux-2.6.23-rc4.gc5/arch/i386/kernel/vsyscall.lds.S
--- linux-2.6.23-rc4.gc4/arch/i386/kernel/vsyscall.lds.S 2007-07-09 00:32:17.000000000 +0100
+++ linux-2.6.23-rc4.gc5/arch/i386/kernel/vsyscall.lds.S 2007-09-12 19:47:17.000000000 +0100
@@ -23,10 +23,10 @@ SECTIONS
is insufficient, ld -shared will barf. Just increase it here. */
. = VDSO_PRELINK_asm + 0x400;

- .text : { *(.text) } :text =0x90909090
+ .text : { *(.text) *(.text.*) } :text =0x90909090
.note : { *(.note.*) } :text :note
.eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
- .eh_frame : { KEEP (*(.eh_frame)) } :text
+ .eh_frame : { KEEP(*(.eh_frame)) } :text
.dynamic : { *(.dynamic) } :text :dynamic
.useless : {
*(.got.plt) *(.got)
diff -urpN linux-2.6.23-rc4.gc4/include/asm-generic/vmlinux.lds.h linux-2.6.23-rc4.gc5/include/asm-generic/vmlinux.lds.h
--- linux-2.6.23-rc4.gc4/include/asm-generic/vmlinux.lds.h 2007-09-12 19:46:32.000000000 +0100
+++ linux-2.6.23-rc4.gc5/include/asm-generic/vmlinux.lds.h 2007-09-12 19:47:17.000000000 +0100
@@ -169,6 +169,7 @@
#define SCHED_TEXT \
ALIGN_FUNCTION(); \
VMLINUX_SYMBOL(__sched_text_start) = .; \
+ /* No need to KEEP */ \
*(.sched.text) \
VMLINUX_SYMBOL(__sched_text_end) = .;

@@ -177,12 +178,14 @@
#define LOCK_TEXT \
ALIGN_FUNCTION(); \
VMLINUX_SYMBOL(__lock_text_start) = .; \
+ /* No need to KEEP */ \
*(.spinlock.text) \
VMLINUX_SYMBOL(__lock_text_end) = .;

#define KPROBES_TEXT \
ALIGN_FUNCTION(); \
VMLINUX_SYMBOL(__kprobes_text_start) = .; \
+ /* No need to KEEP */ \
*(.kprobes.text) \
VMLINUX_SYMBOL(__kprobes_text_end) = .;

@@ -228,14 +231,16 @@
. = ALIGN(8); \
__bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) { \
__start___bug_table = .; \
- *(__bug_table) \
+ /* Support for BUG() */ \
+ KEEP(*(__bug_table)) \
__stop___bug_table = .; \
}

#define NOTES \
.notes : AT(ADDR(.notes) - LOAD_OFFSET) { \
VMLINUX_SYMBOL(__start_notes) = .; \
- *(.note.*) \
+ /* For /sys/kernel/notes */ \
+ KEEP(*(.note.*)) \
VMLINUX_SYMBOL(__stop_notes) = .; \
}