Linker script cleanup for sparc
PATCH v2 1/1 Linker script cleanup for sparc
This is an updated version of the patch series I sent in late July cleaning up the sparc architecture's linker scripts. The only change is that it is rebased on top of Linus's current master.
This cross-architecture linker script cleanup project is in preparation for adding support for building the kernel with -ffunction-sections -fdata-sections, which is a prerequisite for Ksplice.
-Tim Abbott
Geoffrey Thomas (1):
sparc: Clean up linker script using new linker script macros.
arch/sparc/kernel/vmlinux.lds.S | 75 ++++----------------------------------- 1 files changed, 7 insertions(+), 68 deletions(-)
PATCH v2 1/1 sparc: Clean up linker script using new linker script macros.
From: Geoffrey Thomas <[email protected]>
--- arch/sparc/kernel/vmlinux.lds.S | 75 ++++----------------------------------- 1 files changed, 7 insertions(+), 68 deletions(-)
arch/sparc/kernel/vmlinux.lds.S +7 -68
@@ -51,70 +51,27 @@ SECTIONS _etext = .; RO_DATA(PAGE_SIZE) - .data : { - DATA_DATA - CONSTRUCTORS - } .data1 : { *(.data1) } - . = ALIGN(SMP_CACHE_BYTES); - .data.cacheline_aligned : { - *(.data.cacheline_aligned) - } - . = ALIGN(SMP_CACHE_BYTES); - .data.read_mostly : { - *(.data.read_mostly) - } + RW_DATA_SECTION(SMP_CACHE_BYTES, 0, THREAD_SIZE) + /* End of data section */ _edata = .; - /* init_task */ - . = ALIGN(THREAD_SIZE); - .data.init_task : { - *(.data.init_task) - } .fixup : { __start___fixup = .; *(.fixup) __stop___fixup = .; } - . = ALIGN(16); - __ex_table : { - __start___ex_table = .; - *(__ex_table) - __stop___ex_table = .; - } + EXCEPTION_TABLE(16) NOTES . = ALIGN(PAGE_SIZE); - .init.text : { - __init_begin = .; - _sinittext = .; - INIT_TEXT - _einittext = .; - } + __init_begin = ALIGN(PAGE_SIZE); + INIT_TEXT_SECTION(PAGE_SIZE) __init_text_end = .; - .init.data : { - INIT_DATA - } - . = ALIGN(16); - .init.setup : { - __setup_start = .; - *(.init.setup) - __setup_end = .; - } - .initcall.init : { - __initcall_start = .; - INITCALLS - __initcall_end = .; - } - .con_initcall.init : { - __con_initcall_start = .; - *(.con_initcall.init) - __con_initcall_end = .; - } - SECURITY_INIT + INIT_DATA_SECTION(16) . = ALIGN(4); .tsb_ldquad_phys_patch : {
@@ -146,29 +103,11 @@ SECTIONS __sun4v_2insn_patch_end = .; } -#ifdef CONFIG_BLK_DEV_INITRD - . = ALIGN(PAGE_SIZE); - .init.ramfs : { - __initramfs_start = .; - *(.init.ramfs) - __initramfs_end = .; - } -#endif - PERCPU(PAGE_SIZE) . = ALIGN(PAGE_SIZE); __init_end = .; - __bss_start = .; - .sbss : { - *(.sbss) - *(.scommon) - } - .bss : { - *(.dynbss) - *(.bss) - *(COMMON) - } + BSS_SECTION(0, 0, 0) _end = . ; STABS_DEBUG
Signature · 1 line
1.6.3.3
David Miller
maintainerRe: [PATCH v2] sparc: Clean up linker script using new linker script macros.
From: Tim Abbott <[email protected]>
Date: Wed, 16 Sep 2009 12:46:32 -0400
Quoted 11 lines
arch/sparc/kernel/vmlinux.lds.S +0
-4@@ -51,70 +51,27 @@ SECTIONS _etext = .; RO_DATA(PAGE_SIZE) - .data : { - DATA_DATA - CONSTRUCTORS - } .data1 : { *(.data1) }
arch/sparc/kernel/vmlinux.lds.S SECTIONS · line 58
Quoted 10 lines
arch/sparc/kernel/vmlinux.lds.S +2
-8- . = ALIGN(SMP_CACHE_BYTES); - .data.cacheline_aligned : { - *(.data.cacheline_aligned) - } - . = ALIGN(SMP_CACHE_BYTES); - .data.read_mostly : { - *(.data.read_mostly) - } + RW_DATA_SECTION(SMP_CACHE_BYTES, 0, THREAD_SIZE) +
Can you do this cleanup without moving the relative locations of .data and .data1 sections?
Re: [PATCH v2] sparc: Clean up linker script using new linker script macros.
Quoted 2 lines · David Miller
Can you do this cleanup without moving the relative locations of .data and .data1 sections?
Yes, if you just swap RW_DATA_SECTION and .data1 so it looks like
RW_DATA_SECTION(SMP_CACHE_BYTES, 0, THREAD_SIZE)
.data1 : {
*(.data1)
}instead, that would preserve their relative locations.
Currently, switching to RW_DATA_SECTION would still result in a change in their relative position that .data.page_aligned and .data.nosave would be between .data and .data1 (not sure if that is relevant on sparc). (this will change when <http://lkml.org/lkml/2009/9/16/396> is merged).
-Tim Abbott
David Miller
maintainerRe: [PATCH v2] sparc: Clean up linker script using new linker script macros.
From: Tim Abbott <[email protected]>
Date: Wed, 16 Sep 2009 13:27:43 -0400 (EDT)
Quoted 12 lines · David Miller
Quoted 3 lines
Can you do this cleanup without moving the relative locations of .data and .data1 sections?
Yes, if you just swap
RW_DATA_SECTIONand .data1 so it looks like
RW_DATA_SECTION(SMP_CACHE_BYTES, 0, THREAD_SIZE).data1 : { *(.data1) }
Quoted 6 lines
instead, that would preserve their relative locations.
Currently, switching to
RW_DATA_SECTIONwould still result in a change in their relative position that .data.page_aligned and .data.nosave would be between .data and .data1 (not sure if that is relevant on sparc). (this will change when <http://lkml.org/lkml/2009/9/16/396> is merged).
I don't know which, if any, are relevant or could cause problems.
It's hard for me to ACK this because it's not a straight nop transformation, which we could at least presume would function properly if the macros were implemented correctly.
Re: [PATCH v2] sparc: Clean up linker script using new linker script macros.
Quoted 15 lines · David Miller
From: Tim Abbott <[email protected]>
Date: Wed, 16 Sep 2009 13:27:43 -0400 (EDT)Quoted 12 lines · David Miller
Quoted 3 lines
Can you do this cleanup without moving the relative locations of .data and .data1 sections?
Yes, if you just swap
RW_DATA_SECTIONand .data1 so it looks like
RW_DATA_SECTION(SMP_CACHE_BYTES, 0, THREAD_SIZE).data1 : { *(.data1) }
Quoted 8 lines
Quoted 6 lines
instead, that would preserve their relative locations.
Currently, switching to
RW_DATA_SECTIONwould still result in a change in their relative position that .data.page_aligned and .data.nosave would be between .data and .data1 (not sure if that is relevant on sparc). (this will change when <http://lkml.org/lkml/2009/9/16/396> is merged).I don't know which, if any, are relevant or could cause problems.
The kind of problem I've seen on other architectures is if there are short-range (e.g. 2-byte) relative relocations between two sections, and you insert a new section between them, they end up too far apart and the kernel fails to link. I don't know whether the sparc architecture has that kind of short relocation issue, but that's what I'd be worried about with section order changes.
The other potential issue is sections moving past linker script defined symbols such as __init_end, so that the section might be allocated differently. The only change of that form in this patch is that it moves .data.init_task before _edata, which on sparc is only used to print how memory is used by different data types.
The other thing I should mention is that I've not boot-tested this; I've only build-tested it with a sparc64 cross-compiler. So that should be done before merging this.
Quoted 3 lines
It's hard for me to ACK this because it's not a straight nop transformation, which we could at least presume would function properly if the macros were implemented correctly.
Would it help if I were to split the patch into first rearranging the code to look like the macros and then applying the macros, so that you can see more easily exactly what is changing?
-Tim Abbott
Re: [PATCH v2] sparc: Clean up linker script using new linker script macros.
From: Tim Abbott <[email protected]>
Date: Wed, 16 Sep 2009 14:03:48 -0400 (EDT)
Quoted 9 lines · David Miller
Quoted 4 lines
It's hard for me to ACK this because it's not a straight nop transformation, which we could at least presume would function properly if the macros were implemented correctly.
Would it help if I were to split the patch into first rearranging the code to look like the macros and then applying the macros, so that you can see more easily exactly what is changing?
No, it wouldn't :-) The issue is that I can't just say from reading the patch that it will absolutely work.
But I'm willing to take the risk and we can revert if testing shows it breaks things, so:
Re: [PATCH v2] sparc: Clean up linker script using new linker script macros.
In reply to David MillerQuoted 22 lines · David Miller
From: Tim Abbott <[email protected]>
Date: Wed, 16 Sep 2009 13:27:43 -0400 (EDT)Quoted 12 lines · David Miller
Quoted 3 lines
Can you do this cleanup without moving the relative locations of .data and .data1 sections?
Yes, if you just swap
RW_DATA_SECTIONand .data1 so it looks like
RW_DATA_SECTION(SMP_CACHE_BYTES, 0, THREAD_SIZE).data1 : { *(.data1) }Quoted 6 lines
instead, that would preserve their relative locations.
Currently, switching to
RW_DATA_SECTIONwould still result in a change in their relative position that .data.page_aligned and .data.nosave would be between .data and .data1 (not sure if that is relevant on sparc). (this will change when <http://lkml.org/lkml/2009/9/16/396> is merged).
Quoted 5 lines
I don't know which, if any, are relevant or could cause problems.
It's hard for me to ACK this because it's not a straight nop transformation, which we could at least presume would function properly if the macros were implemented correctly.
As you most likely are aware the linker scripts has diverged a lot over time between different architectures.
So whatever fits the ordering of one architecture fails on another architecture.
Tim is doing a huge effort to bring some sanity into this area which I appreciate a lot!
Sam