Linker script cleanup patches for parisc
v2 cover Linker script cleanup patches for parisc
This is an updated version of the patch series I sent on September 6 cleaning up the parisc architecture's linker scripts. It differs from the previous version only in having been rebased on top of Linus' current master (and is a complete rewrite of the version that got some review back in May:
<http://linux.derkeiler.com/Mailing-Lists/Kernel/2009-05/msg00095.html>).
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
Tim Abbott (2):
parisc: Clean up linker script using new linker script macros.
parisc: Remove useless altinstructions code copied from x86.
arch/parisc/kernel/vmlinux.lds.S | 104 ++------------------------------------ 1 files changed, 4 insertions(+), 100 deletions(-)
PATCH v2 1/2 parisc: Clean up linker script using new linker script macros.
This patch has the (likely harmless) side effect of moving .data.init_task inside the _edata.
It also changes the alignment of .data.init_task from 16384 to THREAD_SIZE, which can in some configurations be larger than 16384. I believe that this change fixes a potential bug on those configurations.
--- arch/parisc/kernel/vmlinux.lds.S | 79 ++------------------------------------ 1 files changed, 4 insertions(+), 75 deletions(-)
arch/parisc/kernel/vmlinux.lds.S +4 -75
@@ -77,13 +77,7 @@ SECTIONS */ . = ALIGN(PAGE_SIZE); data_start = .; - . = ALIGN(16); - /* Exception table */ - __ex_table : { - __start___ex_table = .; - *(__ex_table) - __stop___ex_table = .; - } + EXCEPTION_TABLE(16) NOTES
@@ -94,23 +88,8 @@ SECTIONS __stop___unwind = .; } - /* rarely changed data like cpu maps */ - . = ALIGN(16); - .data.read_mostly : { - *(.data.read_mostly) - } - - . = ALIGN(L1_CACHE_BYTES); /* Data */ - .data : { - DATA_DATA - CONSTRUCTORS - } - - . = ALIGN(L1_CACHE_BYTES); - .data.cacheline_aligned : { - *(.data.cacheline_aligned) - } + RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) /* PA-RISC locks requires 16-byte alignment */ . = ALIGN(16);
@@ -118,17 +97,6 @@ SECTIONS *(.data.lock_aligned) } - /* nosave data is really only used for software suspend...it's here - * just in case we ever implement it - */ - . = ALIGN(PAGE_SIZE); - __nosave_begin = .; - .data_nosave : { - *(.data.nosave) - } - . = ALIGN(PAGE_SIZE); - __nosave_end = .; - /* End of data section */ _edata = .;
@@ -147,14 +115,6 @@ SECTIONS } __bss_stop = .; - - /* assembler code expects init_task to be 16k aligned */ - . = ALIGN(16384); - /* init_task */ - .data.init_task : { - *(.data.init_task) - } - #ifdef CONFIG_64BIT . = ALIGN(16); /* Linkage tables */
@@ -172,31 +132,8 @@ SECTIONS /* reserve space for interrupt stack by aligning __init* to 16k */ . = ALIGN(16384); __init_begin = .; - .init.text : { - _sinittext = .; - INIT_TEXT - _einittext = .; - } - .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_TEXT_SECTION(16384) + INIT_DATA_SECTION(16) /* alternate instruction replacement. This is a mechanism x86 uses * to detect the CPU type and replace generic instruction sequences
@@ -222,14 +159,6 @@ SECTIONS .exit.data : { EXIT_DATA } -#ifdef CONFIG_BLK_DEV_INITRD - . = ALIGN(PAGE_SIZE); - .init.ramfs : { - __initramfs_start = .; - *(.init.ramfs) - __initramfs_end = .; - } -#endif PERCPU(PAGE_SIZE) . = ALIGN(PAGE_SIZE);
Signature · 1 line
1.6.3.3
PATCH v2 2/2 parisc: Remove useless altinstructions code copied from x86.
In reply to Tim Abbott--- arch/parisc/kernel/vmlinux.lds.S | 25 ------------------------- 1 files changed, 0 insertions(+), 25 deletions(-)
arch/parisc/kernel/vmlinux.lds.S +0 -24
@@ -135,31 +135,6 @@ SECTIONS INIT_TEXT_SECTION(16384) INIT_DATA_SECTION(16) - /* alternate instruction replacement. This is a mechanism x86 uses - * to detect the CPU type and replace generic instruction sequences - * with CPU specific ones. We don't currently do this in PA, but - * it seems like a good idea... - */ - . = ALIGN(4); - .altinstructions : { - __alt_instructions = .; - *(.altinstructions) - __alt_instructions_end = .; - } - .altinstr_replacement : { - *(.altinstr_replacement) - } - - /* .exit.text is discard at runtime, not link time, to deal with references - * from .altinstructions and .eh_frame - */ - .exit.text : { - EXIT_TEXT - } - .exit.data : { - EXIT_DATA - }
Quoted 12 lines · Tim Abbott
This is an updated version of the patch series I sent on September 6 cleaning up the parisc architecture's linker scripts. It differs from the previous version only in having been rebased on top of Linus' current master (and is a complete rewrite of the version that got some review back in May:
<http://linux.derkeiler.com/Mailing-Lists/Kernel/2009-05/msg00095.html>).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.
Quoted 5 lines
-Tim Abbott
Tim Abbott (2):
parisc: Clean up linker script using new linker script macros.
parisc: Remove useless altinstructions code copied from x86.
Looks good.
Both have my:
Sam
Helge Deller
maintainerQuoted 10 lines · Tim Abbott
This is an updated version of the patch series I sent on September 6 cleaning up the parisc architecture's linker scripts. [....]
-Tim AbbottTim Abbott (2):
parisc: Clean up linker script using new linker script macros.
parisc: Remove useless altinstructions code copied from x86.arch/parisc/kernel/vmlinux.lds.S | 104 ++------------------------------------ 1 files changed, 4 insertions(+), 100 deletions(-)
Tim, thanks for your work!
Sadly it broke the parisc build in two places:
a) THREAD_SIZE can't be used in the vmlinux.lds.S file
b) It generates linker errors like "local symbol 0: discarded in section `.exit.text' from kernel/built-in.o".
Attached patch below fixes both issues. Tested with 32- and 64-bit parisc kernel.
Helge
--------
parisc: Fix linker script breakage.
arch/parisc/kernel/asm-offsets.c +2 -0
@@ -287,6 +287,8 @@ int main(void)DEFINE (ASM_PFN_PTE_SHIFT ,PFN_PTE_SHIFT );DEFINE (ASM_PT_INITIAL ,PT_INITIAL );BLANK (); +DEFINE (ASM_THREAD_SIZE ,THREAD_SIZE ); +BLANK ();DEFINE (EXCDATA_IP , offsetof(struct exception_data , fault_ip));DEFINE (EXCDATA_SPACE , offsetof(struct exception_data , fault_space));DEFINE (EXCDATA_ADDR , offsetof(struct exception_data , fault_addr));
arch/parisc/kernel/vmlinux.lds.S +11 -1
@@ -89,7 +89,7 @@ SECTIONS } /* Data */ - RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) + RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, ASM_THREAD_SIZE) /* PA-RISC locks requires 16-byte alignment */ . = ALIGN(16);
@@ -135,6 +135,16 @@ SECTIONS INIT_TEXT_SECTION(16384) INIT_DATA_SECTION(16) + /* we have to discard exit text and such at runtime, not link time */ + .exit.text : + { + EXIT_TEXT + } + .exit.data : + { + EXIT_DATA + } + PERCPU(PAGE_SIZE) . = ALIGN(PAGE_SIZE); __init_end = .;
Quoted 6 lines · Helge Deller
Tim, thanks for your work!
Sadly it broke the parisc build in two places:
a)THREAD_SIZEcan't be used in thevmlinux.lds.Sfile
b) It generates linker errors like "local symbol 0: discarded in section `.exit.text' fromkernel/built-in.o".
Sorry about that -- I should have tried harder to get someone to test this one, since parisc is one of the architectures for which I don't have a cross-compiler.
Quoted 2 lines
Attached patch below fixes both issues. Tested with 32- and 64-bit parisc kernel.
The .exit.text change looks fine.
[...]
arch/parisc/kernel/asm-offsets.c int main(void) · line 294
Quoted 13 lines
b/arch/parisc/kernel/asm-offsets.c
index 699cf8e..7e76f03 100644arch/parisc/kernel/asm-offsets.c +2
-0@@ -287,6 +287,8 @@ int main(void)DEFINE (ASM_PFN_PTE_SHIFT ,PFN_PTE_SHIFT );DEFINE (ASM_PT_INITIAL ,PT_INITIAL );BLANK (); +DEFINE (ASM_THREAD_SIZE ,THREAD_SIZE ); +BLANK ();DEFINE (EXCDATA_IP , offsetof(struct exception_data , fault_ip));DEFINE (EXCDATA_SPACE , offsetof(struct exception_data , fault_space));DEFINE (EXCDATA_ADDR , offsetof(struct exception_data , fault_addr));
Rather than adding a new definition in asm-offsets.c, I think it'll be better to do something like the following to make the normal THREAD_SIZE definition available in the linker script and other assembly files:
-Tim Abbott
parisc: Make THREAD_SIZE available to assembly files and linker scripts.
--- arch/parisc/include/asm/thread_info.h | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
arch/parisc/include/asm/thread_info.h +5 -4
@@ -32,6 +32,11 @@ struct thread_info {#define init_thread_info (init_thread_union.thread_info)#define init_stack (init_thread_union.stack) +/* how to get the thread information struct from C */ +#define current_thread_info () ((struct thread_info *)mfctl(30)) + +#endif /* !__ASSEMBLY */ +/* thread information allocation */ #define THREAD_SIZE_ORDER 2
@@ -40,11 +45,6 @@ struct thread_info {#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)#define THREAD_SHIFT (PAGE_SHIFT + THREAD_SIZE_ORDER) -/* how to get the thread information struct from C */ -#define current_thread_info () ((struct thread_info *)mfctl(30)) - -#endif /* !__ASSEMBLY */
Quoted 4 lines · Tim Abbott
Quoted 2 lines · Helge Deller
Tim, thanks for your work!
Quoted 8 lines
Quoted 4 lines
Sadly it broke the parisc build in two places:
a)THREAD_SIZEcan't be used in thevmlinux.lds.Sfile
b) It generates linker errors like "local symbol 0: discarded in section `.exit.text' fromkernel/built-in.o".Sorry about that -- I should have tried harder to get someone to test this one, since parisc is one of the architectures for which I don't have a cross-compiler.
No problem. It was on my todo-list to test your patch, but then it already got merged :-)
Quoted 4 lines
Quoted 2 lines
Attached patch below fixes both issues. Tested with 32- and 64-bit parisc kernel.
The .exit.text change looks fine.
Good.
Quoted 10 lines
[...]
Rather than adding a new definition inasm-offsets.c, I think it'll be better to do something like the following to make the normalTHREAD_SIZEdefinition available in the linker script and other assembly files:-Tim Abbott
parisc: Make
THREAD_SIZEavailable to assembly files and linker scripts.Signed-off-by Tim Abbott<[email protected]>
Yes, much better.
But with this change, the vmlinux.lds.S file needs to include the <asm/thread_info.h> file as well. I've added the adjusted patch to vmlinux.lds.S below.
Quoted 22 lines
--- arch/parisc/include/asm/thread_info.h | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)arch/parisc/include/asm/thread_info.h +5
-0@@ -32,6 +32,11 @@ struct thread_info {#define init_thread_info (init_thread_union.thread_info)#define init_stack (init_thread_union.stack) +/* how to get the thread information struct from C */ +#define current_thread_info () ((struct thread_info *)mfctl(30)) + +#endif /* !__ASSEMBLY */ +/* thread information allocation */ #define THREAD_SIZE_ORDER 2@@ -40,11 +45,6 @@ struct thread_info {#define THREAD_SIZE (PAGE_SIZE<< THREAD_SIZE_ORDER)
arch/parisc/include/asm/thread_info.h struct thread_info { · line 50
Quoted 10 lines
arch/parisc/include/asm/thread_info.h +0
-5#define THREAD_SHIFT (PAGE_SHIFT + THREAD_SIZE_ORDER) -/* how to get the thread information struct from C */ -#define current_thread_info () ((struct thread_info *)mfctl(30)) - -#endif /* !__ASSEMBLY */ -#define PREEMPT_ACTIVE_BIT 28#define PREEMPT_ACTIVE (1<< PREEMPT_ACTIVE_BIT)
Adjusted patch to vmlinux.lds.S:
parisc: Fix linker script breakage.
arch/parisc/kernel/vmlinux.lds.S +11 -0
@@ -28,6 +28,7 @@ #include <asm/cache.h> #include <asm/page.h> #include <asm/asm-offsets.h> +#include <asm/thread_info.h> /* ld script to make hppa Linux kernel */ #ifndef CONFIG_64BIT
@@ -135,6 +136,16 @@ SECTIONS INIT_TEXT_SECTION(16384) INIT_DATA_SECTION(16) + /* we have to discard exit text and such at runtime, not link time */ + .exit.text : + { + EXIT_TEXT + } + .exit.data : + { + EXIT_DATA + } + PERCPU(PAGE_SIZE) . = ALIGN(PAGE_SIZE); __init_end = .;