diff -urpN linux-2.6.23-rc4.gc6/arch/i386/kernel/vmlinux.lds.S linux-2.6.23-rc4.gc7/arch/i386/kernel/vmlinux.lds.S --- linux-2.6.23-rc4.gc6/arch/i386/kernel/vmlinux.lds.S 2007-09-12 19:51:42.000000000 +0100 +++ linux-2.6.23-rc4.gc7/arch/i386/kernel/vmlinux.lds.S 2007-09-12 21:10:38.000000000 +0100 @@ -6,7 +6,19 @@ * at run time. Absolute symbols are not relocated. If symbol value should * change if kernel is relocated, make the symbol section relative * by putting it inside the section definition. + * + * Try to avoid creating output sections needlessly. + * Group pieces with same attributes (ro/rw, code/data, + * persistent/discarded-after-init) together in one section. + * + * Statistically, padding is smaller if input sections + * within output section are sorted by alignment in descending order. + * + * If you need to ALIGN a section, putting ALIGN immediately before section + * can result in smaller on-disk image than when you put it immeadiately + * after section's opening '{'. */ + #define LOAD_OFFSET __PAGE_OFFSET #include @@ -18,6 +30,7 @@ OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") OUTPUT_ARCH(i386) ENTRY(phys_startup_32) + jiffies = jiffies_64; PHDRS { @@ -30,13 +43,11 @@ SECTIONS . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR; phys_startup_32 = startup_32 - LOAD_OFFSET; - .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) { - _text = .; /* Text and read-only data */ - KEEP(*(.head.text)) - } :text = 0x9090 - /* read-only */ .text : AT(ADDR(.text) - LOAD_OFFSET) { + _text = .; /* Text and read-only data */ + KEEP(*(.head.text)) + TEXT_TEXT SCHED_TEXT LOCK_TEXT @@ -54,6 +65,7 @@ SECTIONS __stop___ex_table = .; } + /* Hm? NOTES end up marked as CODE in vmlinux, but they are not. FIXME */ NOTES :text :note BUG_TABLE :text @@ -69,45 +81,39 @@ SECTIONS RODATA /* writeable */ - . = ALIGN(4096); + . = ALIGN(THREAD_SIZE); /* at least 4k */ .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */ - DATA_DATA - CONSTRUCTORS - } :data + /* init_task */ + *(.init_task.data) - . = ALIGN(4096); - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { + . = ALIGN(4096); + *(.page_aligned.data) + + . = ALIGN(4096); __nosave_begin = .; /* No need to KEEP */ *(.nosave.data) . = ALIGN(4096); __nosave_end = .; - } - . = ALIGN(4096); - .page_aligned.data : AT(ADDR(.page_aligned.data) - LOAD_OFFSET) { - *(.page_aligned.data) + /* The IDT has to be page-aligned because of F0 0F bug */ *(.idt.data) - } - . = ALIGN(32); - .cacheline_aligned.data : AT(ADDR(.cacheline_aligned.data) - LOAD_OFFSET) { + DATA_DATA + CONSTRUCTORS + + . = ALIGN(32); *(.cacheline_aligned.data) - } - /* rarely changed data like cpu maps */ - . = ALIGN(32); - .read_mostly.data : AT(ADDR(.read_mostly.data) - LOAD_OFFSET) { + /* rarely changed data like cpu maps */ + . = ALIGN(32); *(.read_mostly.data) - _edata = .; /* End of data section */ - } - . = ALIGN(THREAD_SIZE); /* init_task */ - .init_task.data : AT(ADDR(.init_task.data) - LOAD_OFFSET) { - *(.init_task.data) - } + _edata = .; + } :data + + /* Might get freed after init */ - /* might get freed after init */ . = ALIGN(4096); .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) { __smp_locks = .; @@ -116,75 +122,80 @@ SECTIONS } /* Will be freed after init */ - /* Init code and data */ + . = ALIGN(4096); .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { __init_begin = .; _sinittext = .; *(.init.text) _einittext = .; + + /* No need to KEEP - referenced by .altinstructions */ + *(.altinstr_replacement) + + /* .exit.text is discarded at runtime, not link time, to deal with references + from .altinstructions and .eh_frame */ + *(.exit.text) + } + + /* ro, code */ + SECURITY_INIT + +#if defined(CONFIG_BLK_DEV_INITRD) + /* ALIGN outside section may make on-disk image smaller */ + . = ALIGN(4096); +#endif + .init.rodata : AT(ADDR(.init.rodata) - LOAD_OFFSET) { +#if defined(CONFIG_BLK_DEV_INITRD) + __initramfs_start = .; + KEEP(*(.init.ramfs)) + __initramfs_end = .; +#endif + . = ALIGN(4); + __alt_instructions = .; + KEEP(*(.altinstructions)) + __alt_instructions_end = .; + + . = ALIGN(4); + __parainstructions = .; + KEEP(*(.parainstructions)) + __parainstructions_end = .; } - .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) } - . = ALIGN(16); - .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { + + .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { + *(.init.data) + + . = ALIGN(16); __setup_start = .; /* __setup_param() macro produces these, * obsolete_checksetup() processes them */ KEEP(*(.init.setup)) __setup_end = .; - } - .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) { + __initcall_start = .; INITCALLS __initcall_end = .; - } - .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) { + __con_initcall_start = .; KEEP(*(.con_initcall.init)) __con_initcall_end = .; - } - SECURITY_INIT - . = ALIGN(4); - .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) { - __alt_instructions = .; - KEEP(*(.altinstructions)) - __alt_instructions_end = .; - } - .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) { - /* No need to KEEP - referenced by .altinstructions */ - *(.altinstr_replacement) - } - . = ALIGN(4); - .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) { - __parainstructions = .; - KEEP(*(.parainstructions)) - __parainstructions_end = .; - } - /* .exit.text is discarded at runtime, not link time, to deal with references - from .altinstructions and .eh_frame */ - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) } - .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) } -#if defined(CONFIG_BLK_DEV_INITRD) - . = ALIGN(4096); - .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { - __initramfs_start = .; - KEEP(*(.init.ramfs)) - __initramfs_end = .; + /* TODO: can .exit.data be discarded at link time? */ + *(.exit.data) } -#endif . = ALIGN(4096); .percpu.data : AT(ADDR(.percpu.data) - LOAD_OFFSET) { __per_cpu_start = .; - *(.percpu.data) + *(SORT_BY_ALIGNMENT(.percpu.data)) + /* Dont move in front of .percpu.data, .percpu.data contains page-aligned stuff */ *(.percpu.shared_aligned.data) __per_cpu_end = .; } - . = ALIGN(4096); /* End of "freed after init" portion */ + . = ALIGN(4096); .bss : AT(ADDR(.bss) - LOAD_OFFSET) { __init_end = .; __bss_start = .; /* BSS */