[PATCH 2/4] build system: section garbage collection for vmlinux

Denys Vlasenko
2007-09-11T20:18:13Z

[-- Attachment #1: Type: text/plain, Size: 264 bytes --]

This patch fixes x86_64 vdso image so that it builds with --gc-sections.

Then it fixes comment in arch/i386/kernel/vmlinux.lds.S
and adds comments to other linker scripts about .bss.

Please apply.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
--
vda

[-- Attachment #2: linux-2.6.23-rc4.2.lds.patch --]
[-- Type: text/x-diff, Size: 3738 bytes --]

--- linux-2.6.23-rc4.gc1/arch/x86_64/vdso/vdso.lds.S Sat Sep 8 22:06:52 2007
+++ linux-2.6.23-rc4.gc2/arch/x86_64/vdso/vdso.lds.S Sat Sep 8 22:07:05 2007
@@ -26,11 +26,11 @@
is insufficient, ld -shared will barf. Just increase it here. */
. = VDSO_PRELINK + VDSO_TEXT_OFFSET;

- .text : { *(.text) } :text
+ .text : { *(.text) *(.text.*) } :text
.ptr.text : { *(.ptr.text) } :text
. = VDSO_PRELINK + 0x900;
- .data : { *(.data) } :text
- .bss : { *(.bss) } :text
+ .data : { *(.data) *(.data.*) } :text
+ .bss : { *(.bss) *(.bss.*) } :text

.altinstructions : { *(.altinstructions) } :text
.altinstr_replacement : { *(.altinstr_replacement) } :text
diff -urpN linux-2.6.23-rc4.gc1/arch/i386/kernel/vmlinux.lds.S linux-2.6.23-rc4.gc2/arch/i386/kernel/vmlinux.lds.S
--- linux-2.6.23-rc4.gc1/arch/i386/kernel/vmlinux.lds.S 2007-09-10 18:54:38.000000000 +0100
+++ linux-2.6.23-rc4.gc2/arch/i386/kernel/vmlinux.lds.S 2007-09-10 19:09:24.000000000 +0100
@@ -2,17 +2,10 @@
* Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
*
* Don't define absolute symbols until and unless you know that symbol
- * value is should remain constant even if kernel image is relocated
+ * value should remain constant even if kernel image is relocated
* at run time. Absolute symbols are not relocated. If symbol value should
- * change if kernel is relocated, make the symbol section relative and
- * put it inside the section definition.
- */
-
-/* Don't define absolute symbols until and unless you know that symbol
- * value is should remain constant even if kernel image is relocated
- * at run time. Absolute symbols are not relocated. If symbol value should
- * change if kernel is relocated, make the symbol section relative and
- * put it inside the section definition.
+ * change if kernel is relocated, make the symbol section relative
+ * by putting it inside the section definition.
*/
#define LOAD_OFFSET __PAGE_OFFSET

@@ -192,6 +185,9 @@ SECTIONS
.bss : AT(ADDR(.bss) - LOAD_OFFSET) {
__init_end = .;
__bss_start = .; /* BSS */
+ /* We must use .bss.xxx section names for zero-initialized sections
+ * we want to combine into bss, otherwise gcc does not set
+ * 'nobits' flag for the section, and it cannot be merged into bss. */
*(.bss.k.page_aligned)
*(.bss)
. = ALIGN(4);
diff -urpN linux-2.6.23-rc4.gc1/arch/sh/kernel/vmlinux.lds.S linux-2.6.23-rc4.gc2/arch/sh/kernel/vmlinux.lds.S
--- linux-2.6.23-rc4.gc1/arch/sh/kernel/vmlinux.lds.S 2007-09-10 18:54:38.000000000 +0100
+++ linux-2.6.23-rc4.gc2/arch/sh/kernel/vmlinux.lds.S 2007-09-10 19:09:24.000000000 +0100
@@ -104,6 +104,9 @@ SECTIONS
.bss : {
__init_end = .;
__bss_start = .; /* BSS */
+ /* We must use .bss.xxx section names for zero-initialized sections
+ * we want to combine into bss, otherwise gcc does not set
+ * 'nobits' flag for the section, and it cannot be merged into bss. */
*(.bss.k.page_aligned)
*(.bss)
. = ALIGN(4);
diff -urpN linux-2.6.23-rc4.gc1/arch/xtensa/kernel/vmlinux.lds.S linux-2.6.23-rc4.gc2/arch/xtensa/kernel/vmlinux.lds.S
--- linux-2.6.23-rc4.gc1/arch/xtensa/kernel/vmlinux.lds.S 2007-09-10 18:54:38.000000000 +0100
+++ linux-2.6.23-rc4.gc2/arch/xtensa/kernel/vmlinux.lds.S 2007-09-10 19:09:24.000000000 +0100
@@ -255,6 +255,9 @@ SECTIONS

/* BSS section */
_bss_start = .;
+ /* We must use .bss.xxx section names for zero-initialized sections
+ * we want to combine into bss, otherwise gcc does not set
+ * 'nobits' flag for the section, and it cannot be merged into bss. */
.bss : { *(.bss.k.page_aligned) *(.bss) }
_bss_end = .;