* Re: [PATCH v2 0/6] macros for section name cleanup [not found] <1241121253-32341-1-git-send-email-tabbott@mit.edu> @ 2009-05-01 21:31 ` Sam Ravnborg 2009-05-02 0:48 ` Tim Abbott 0 siblings, 1 reply; 8+ messages in thread From: Sam Ravnborg @ 2009-05-01 21:31 UTC (permalink / raw) To: Tim Abbott; +Cc: Linux kernel mailing list, linux arch Hi Tim. [cc trimmed so this hits lkml] I've tried to make the patch to vmlinux.lds.h more complete. With this patch I managed to achive the following diffstat: arch/mips/kernel/vmlinux.lds.S | 70 ++---------------- arch/mn10300/kernel/vmlinux.lds.S | 82 +++------------------- arch/sparc/kernel/vmlinux.lds.S | 82 +++------------------- include/asm-generic/vmlinux.lds.h | 139 ++++++++++++++++++++++++++++++++++++- 4 files changed, 165 insertions(+), 208 deletions(-) So with 3 architecture I have more lines deleted than added. None of these has been build tested but this shows the potential. Below you will find the *untested* patch for vmlinux.lds.h. This is the way I want to go where we have more complete definitions in the shared file and we try to keep the arch linker scripts to the arch specifc stuff. This is not a 1:1 replacement for your patches as they touches files outside vmlinux.lds.h but I concentrated on this single file for now. Comments welcome! Sam diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 89853bc..950d0d7 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -116,6 +116,43 @@ FTRACE_EVENTS() \ TRACE_SYSCALLS() +/* + * Data section helpers + */ +#define NOSAVE_DATA \ + . = ALIGN(PAGE_SIZE); \ + VMLINUX_SYMBOL(__nosave_begin) = .; \ + *(.data.nosave) \ + . = ALIGN(PAGE_SIZE); \ + VMLINUX_SYMBOL(__nosave_end) = .; + +#define PAGE_ALIGNED_DATA(page_align) \ + . = ALIGN((page_align)); \ + *(.data.page_aligned) + +#define READ_MOSTLY_DATA(align) \ + . = ALIGN((align)); \ + *(.data.read_mostly) + +#define CACHELINE_ALIGNED_DATA(align) \ + . = ALIGN((align)); \ + *(.data.cacheline_aligned) + +/* use 0 as page_align if page_aligned data is not used */ +#define RW_DATA(page_align, readmostly_align, cache_align) \ + . = ALIGN(PAGE_SIZE); \ + .data : AT(ADDR(.data) - LOAD_OFFSET) { \ + DATA_DATA \ + CONSTRUCTORS \ + NOSAVE_DATA \ + PAGE_ALIGNED_DATA(page_align) \ + READMOSTLY_DATA((readmostly_align)) \ + CACHELINE_ALIGNED_DATA((cache_align)) \ + } + +/* + * Read only Data + */ #define RO_DATA(align) \ . = ALIGN((align)); \ .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \ @@ -274,6 +311,18 @@ * All archs are supposed to use RO_DATA() */ #define RODATA RO_DATA(4096) +#ifdef CONFIG_BLK_DEV_INITRD +#define INITRAMFS \ + . = ALIGN(PAGE_SIZE); \ + .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { \ + VMLINUX_SYMBOL(__initramfs_start) = .; \ + *(.init.ramfs) \ + VMLINUX_SYMBOL(__initramfs_end) = .; \ + } +#else +#define INITRAMFS +#endif + #define SECURITY_INIT \ .security_initcall.init : AT(ADDR(.security_initcall.init) - LOAD_OFFSET) { \ VMLINUX_SYMBOL(__security_initcall_start) = .; \ @@ -281,6 +330,24 @@ VMLINUX_SYMBOL(__security_initcall_end) = .; \ } +#define INITDATA(initsetup_align) \ + .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \ + INIT_DATA \ + . = ALIGN(initsetup_align); \ + VMLINUX_SYMBOL(__setup_start) = .; \ + *(.init.setup) \ + VMLINUX_SYMBOL(__setup_end) = .; \ + VMLINUX_SYMBOL(__initcall_start) = .; \ + INITCALLS \ + VMLINUX_SYMBOL(__initcall_end) = .; \ + VMLINUX_SYMBOL(__con_initcall_start) = .; \ + *(.con_initcall.init) \ + VMLINUX_SYMBOL(__con_initcall_end) = .; + VMLINUX_SYMBOL(__security_initcall_start) = .; \ + *(.security_initcall.init) \ + VMLINUX_SYMBOL(__security_initcall_end) = .; \ + } + /* .text section. Map to function alignment to avoid address changes * during second ld run in second ld pass when generating System.map */ #define TEXT_TEXT \ @@ -332,6 +399,29 @@ /* Section used for early init (in .S files) */ #define HEAD_TEXT *(HEAD_TEXT_SECTION) +/* + * Exception table + */ +#define EXCEPTION_TABLE(align) \ + . = ALIGN((align)); \ + __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { \ + VMLINUX_SYMBOL(__start___ex_table) = .; \ + *(__ex_table) \ + VMLINUX_SYMBOL(__stop___ex_table) = .; \ + } + +/* + * Init task + */ +#define INIT_TASK \ + *(.data.init_task) + +#define INIT_TASK_DATA(align) \ + . = ALIGN((align)); \ + .data.init_task : { \ + INIT_TASK \ + } + /* init and exit section handling */ #define INIT_DATA \ *(.init.data) \ @@ -363,9 +453,52 @@ CPU_DISCARD(exit.text) \ MEM_DISCARD(exit.text) - /* DWARF debug sections. - Symbols in the DWARF debugging sections are relative to - the beginning of the section so we begin them at 0. */ +#define INITTEXT(inittext_align) \ + . = ALIGN((inittext_align)); \ + .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { \ + VMLINUX_SYMBOL(__init_begin) = .; \ + VMLINUX_SYMBOL(_sinittext) = .; \ + INIT_TEXT \ + VMLINUX_SYMBOL(_einittext) = .; \ + } + +#define INITDATA(initdata_align) \ + . = ALIGN((initdata_align)); \ + .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \ + INIT_DATA \ + } + +/* + * bss + */ +#define SBSS(sbss_align) \ + . = ALIGN((sbss_align)); \ + .sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \ + *(.sbss) \ + *(.scommon) \ + } + +#define BSS(bss_align) \ + . = ALIGN((bss_align)); \ + .bss : AT(ADDR(.bss) - LOAD_OFFSET) { \ + *(.bss.page_aligned) \ + *(.dynbss) \ + *(.bss) \ + *(COMMON) \ + } + +#define SBSS_BSS(sbss_align, bss_align) \ + VMLINUX_SYMBOL(__bss_start) = .; \ + SBSS(sbss_align) \ + BSS(bss_align) \ + ALIGN_FUNCTION(); \ + VMLINUX_SYMBOL(__bss_stop) = .; + +/* + * DWARF debug sections. + * Symbols in the DWARF debugging sections are relative to + * the beginning of the section so we begin them at 0. + */ #define DWARF_DEBUG \ /* DWARF 1 */ \ .debug 0 : { *(.debug) } \ ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/6] macros for section name cleanup 2009-05-01 21:31 ` [PATCH v2 0/6] macros for section name cleanup Sam Ravnborg @ 2009-05-02 0:48 ` Tim Abbott 2009-05-02 22:01 ` Sam Ravnborg 0 siblings, 1 reply; 8+ messages in thread From: Tim Abbott @ 2009-05-02 0:48 UTC (permalink / raw) To: Sam Ravnborg; +Cc: Linux kernel mailing list, linux arch, Anders Kaseorg On Fri, 1 May 2009, Sam Ravnborg wrote: > This is the way I want to go where we have more complete > definitions in the shared file and we try to keep the arch > linker scripts to the arch specifc stuff. I like the general look of this. Indeed, I was planning to work on something like this as a follow-on to the linker script cleanup work I've done so far. Some comments on the details are below. > +#define PAGE_ALIGNED_DATA(page_align) \ > + . = ALIGN((page_align)); \ > + *(.data.page_aligned) Why does this need an argument? You should be able to just align to PAGE_SIZE. Also, I'm not sure what you're trying to do with the double parentheses here (it also appears inconsistently in several other places in this patch). > +/* use 0 as page_align if page_aligned data is not used */ > +#define RW_DATA(page_align, readmostly_align, cache_align) \ > + . = ALIGN(PAGE_SIZE); \ > + .data : AT(ADDR(.data) - LOAD_OFFSET) { \ > + DATA_DATA \ > + CONSTRUCTORS \ > + NOSAVE_DATA \ > + PAGE_ALIGNED_DATA(page_align) \ > + READMOSTLY_DATA((readmostly_align)) \ > + CACHELINE_ALIGNED_DATA((cache_align)) \ > + } I think there are several architectures that have some other stuff in their .data output section (e.g. powerpc, frv, ia64), so we won't be able to use this on all architectures. Perhaps we want an intermediate macro between DATA_DATA and RW_DATA that is just the contents of .data here that those architectuere can use? > +#define INITDATA(initsetup_align) \ > + .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \ > + INIT_DATA \ > + . = ALIGN(initsetup_align); \ > + VMLINUX_SYMBOL(__setup_start) = .; \ > + *(.init.setup) \ [...] > +#define INITDATA(initdata_align) \ > + . = ALIGN((initdata_align)); \ > + .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \ > + INIT_DATA \ > + } You define two different macros called INITDATA; I'm not sure what the intention is here. > +#define INIT_TASK \ > + *(.data.init_task) > + > +#define INIT_TASK_DATA(align) > + . = ALIGN((align)); \ > + .data.init_task : { \ > + INIT_TASK \ > + } > + You mentioned elsewhere you thought .data.init_task needs to be its own output section rather than part of the .data output section; why is that? There are several architectures on which it is part of the .data output section (e.g. sh, um, avr32). Also, I think it is possible that INIT_TASK_DATA could just align to THREAD_SIZE rather than taking an argument. While working on my patches for this I noticed there were only a couple of architectures where the alignment wasn't THREAD_SIZE (or a value equal to THREAD_SIZE was used). One exception was parisc, where the aligment is 16384 and THREAD_SIZE is always at least that but could be bigger in some configs where PAGE_SIZE is bigger. I'm not sure whether this one exception is a bug. -Tim Abbott ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/6] macros for section name cleanup 2009-05-02 0:48 ` Tim Abbott @ 2009-05-02 22:01 ` Sam Ravnborg 2009-05-04 14:27 ` Sam Ravnborg 0 siblings, 1 reply; 8+ messages in thread From: Sam Ravnborg @ 2009-05-02 22:01 UTC (permalink / raw) To: Tim Abbott; +Cc: Linux kernel mailing list, linux arch, Anders Kaseorg On Fri, May 01, 2009 at 08:48:53PM -0400, Tim Abbott wrote: > On Fri, 1 May 2009, Sam Ravnborg wrote: > > > This is the way I want to go where we have more complete > > definitions in the shared file and we try to keep the arch > > linker scripts to the arch specifc stuff. > > I like the general look of this. Indeed, I was planning to work on > something like this as a follow-on to the linker script cleanup work I've > done so far. Keep in mind that my primary goal here is to clean up the linker scripts. Support for -ffunction-sections is only a spin-off of that. This is why I try to take a broader look at it. > > Some comments on the details are below. > > > +#define PAGE_ALIGNED_DATA(page_align) \ > > + . = ALIGN((page_align)); \ > > + *(.data.page_aligned) > > Why does this need an argument? You should be able to just align to > PAGE_SIZE. Only a few archs supports .data.page_aligned so those that does not pass a 0 as alignmnet thus they do not waste any memory. > > Also, I'm not sure what you're trying to do with the double parentheses > here (it also appears inconsistently in several other places in this > patch). Old habbit - dropped now. > > > +/* use 0 as page_align if page_aligned data is not used */ > > +#define RW_DATA(page_align, readmostly_align, cache_align) \ > > + . = ALIGN(PAGE_SIZE); \ > > + .data : AT(ADDR(.data) - LOAD_OFFSET) { \ > > + DATA_DATA \ > > + CONSTRUCTORS \ > > + NOSAVE_DATA \ > > + PAGE_ALIGNED_DATA(page_align) \ > > + READMOSTLY_DATA((readmostly_align)) \ > > + CACHELINE_ALIGNED_DATA((cache_align)) \ > > + } > > I think there are several architectures that have some other stuff in > their .data output section (e.g. powerpc, frv, ia64), so we won't be able > to use this on all architectures. We have at least two situations to deal with: 1) archs that define more in .data They can either define another output section named '.data' or they can name it differently. frv should be able to do: RW_DATA(...) .data : { *(.data.*) EXIT_DATA } ld allow us to define identical named output sections and it will append to the first when it encounter the name for the second time. 2) archs that do something special. x86 is an example with has: .data : AT(ADDR(.data) - LOAD_OFFSET) { DATA_DATA } :data .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { *(.data.nosave) } :data.init2 See that it add the data section to two different PHDRS. In this case they cannot use RW_DATA and need to fall back to the individual defines. > > Perhaps we want an intermediate macro between DATA_DATA and RW_DATA that > is just the contents of .data here that those architectuere can use? > > > +#define INITDATA(initsetup_align) \ > > + .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \ > > + INIT_DATA \ > > + . = ALIGN(initsetup_align); \ > > + VMLINUX_SYMBOL(__setup_start) = .; \ > > + *(.init.setup) \ > [...] > > +#define INITDATA(initdata_align) \ > > + . = ALIGN((initdata_align)); \ > > + .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \ > > + INIT_DATA \ > > + } > > You define two different macros called INITDATA; I'm not sure what the > intention is here. Bug - fixed. > > > +#define INIT_TASK \ > > + *(.data.init_task) > > + > > +#define INIT_TASK_DATA(align) > > + . = ALIGN((align)); \ > > + .data.init_task : { \ > > + INIT_TASK \ > > + } > > + > > You mentioned elsewhere you thought .data.init_task needs to be its own > output section rather than part of the .data output section; why is that? > There are several architectures on which it is part of the .data output > section (e.g. sh, um, avr32). I had noticed it was not part of the .data output section in some cases. But it occur to me not to make any big difference now I have loked closer so I have moved it inside RW_DATA() for now. > > Also, I think it is possible that INIT_TASK_DATA could just align to > THREAD_SIZE rather than taking an argument. While working on my patches > for this I noticed there were only a couple of architectures where the > alignment wasn't THREAD_SIZE (or a value equal to THREAD_SIZE was used). > One exception was parisc, where the aligment is 16384 and THREAD_SIZE is > always at least that but could be bigger in some configs where PAGE_SIZE > is bigger. I'm not sure whether this one exception is a bug. That triggered some discussions - I will read and see the conclusions. Sam ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/6] macros for section name cleanup 2009-05-02 22:01 ` Sam Ravnborg @ 2009-05-04 14:27 ` Sam Ravnborg 2009-05-04 14:30 ` [PATCH/RFC] Sample conversion of powerpc Sam Ravnborg 2009-05-04 16:32 ` [PATCH v2 0/6] macros for section name cleanup Tim Abbott 0 siblings, 2 replies; 8+ messages in thread From: Sam Ravnborg @ 2009-05-04 14:27 UTC (permalink / raw) To: Tim Abbott; +Cc: Linux kernel mailing list, linux arch, Anders Kaseorg On Sun, May 03, 2009 at 12:01:32AM +0200, Sam Ravnborg wrote: > On Fri, May 01, 2009 at 08:48:53PM -0400, Tim Abbott wrote: > > On Fri, 1 May 2009, Sam Ravnborg wrote: > > > > > This is the way I want to go where we have more complete > > > definitions in the shared file and we try to keep the arch > > > linker scripts to the arch specifc stuff. > > > > I like the general look of this. Indeed, I was planning to work on > > something like this as a follow-on to the linker script cleanup work I've > > done so far. > > Keep in mind that my primary goal here is to clean up the linker scripts. > Support for -ffunction-sections is only a spin-off of that. > This is why I try to take a broader look at it. Here comes the reworked version. I have addressed your comments (thanks!), and also added a lot more stuff. I'm especially found of the "minimal" linker script contained in the beginning of the file. This helped me to gain better understanding of the general sturcture - And I then also quickly spotted when an architecture does not follow the normal flow. I have converted powerpc to the new scheme - which I have done a test build of. If/when we get this in I will help all architectures to convert to use these new defines killing a lot of duplication in the process. But we need to get this stuff agreed on first. Comments appreciated! Sam diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 89853bc..91fe5d4 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -1,4 +1,60 @@ -#include <linux/section-names.h> +/* + * Helper macros to support writing architecture specific + * linker scripts. + * + * A minimal linker scripts has following content: + * + * OUTPUT_FORMAT(...) + * OUTPUT_ARCH(...) + * ENTRY(...) + * SECTIONS + * { + * . = START; + * _stext = .; + * .text : { + * HEAD_TEXT + * TEXT_TEXT + * SCHED_TEXT + * LOCK_TEXT + * KPROBES_TEXT + * IRQENTRY_TEXT + * } = 0 + * _etext = .; + * + * RO_DATA_SECTION(PAGE_SIZE) + * RW_DATA_SECTION(...) + * _edata = .; + * + * EXCEPTION_TABLE(...) + * NOTES + * + * __init_begin = .; + * INIT_TEXT_SECTION(PAGE_SIZE) + * INIT_DATA_SECTION(...) + * PERCPU(PAGE_SIZE) + * __init_end = .; + * + * BSS_SECTION(0, 0) + * _end = .; + * + * /DISCARD/ : { + * EXIT_TEXT + * EXIT_DATA + * *(.exitcall.exit) + * } + * STABS_DEBUG + * DWARF_DEBUG + * } + * + * [_stext, _etext] is the text section + * [_etext, _edata] is the data section + * [__init_begin, __init_end] is the init section that may be freed after init + * + * Some of the included output section include their own set of constants. + * Examples are: [__initramfs_start, __initramfs_end] for initramfs and + * [__nosave_begin, __nosave_end] for the nosave data + */ + #include <linux/section-names.h> #ifndef LOAD_OFFSET #define LOAD_OFFSET 0 @@ -116,6 +172,35 @@ FTRACE_EVENTS() \ TRACE_SYSCALLS() +/* + * Data section helpers + */ +#define NOSAVE_DATA \ + . = ALIGN(PAGE_SIZE); \ + VMLINUX_SYMBOL(__nosave_begin) = .; \ + *(.data.nosave) \ + . = ALIGN(PAGE_SIZE); \ + VMLINUX_SYMBOL(__nosave_end) = .; + +#define PAGE_ALIGNED_DATA(page_align) \ + . = ALIGN(page_align); \ + *(.data.page_aligned) + +#define READ_MOSTLY_DATA(align) \ + . = ALIGN(align); \ + *(.data.read_mostly) + +#define CACHELINE_ALIGNED_DATA(align) \ + . = ALIGN(align); \ + *(.data.cacheline_aligned) + +#define INIT_TASK(align) \ + . = ALIGN(align); \ + *(.data.init_task) + +/* + * Read only Data + */ #define RO_DATA(align) \ . = ALIGN((align)); \ .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \ @@ -332,6 +417,26 @@ /* Section used for early init (in .S files) */ #define HEAD_TEXT *(HEAD_TEXT_SECTION) +/* + * Exception table + */ +#define EXCEPTION_TABLE(align) \ + . = ALIGN(align); \ + __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { \ + VMLINUX_SYMBOL(__start___ex_table) = .; \ + *(__ex_table) \ + VMLINUX_SYMBOL(__stop___ex_table) = .; \ + } + +/* + * Init task + */ +#define INIT_TASK_DATA(align) \ + . = ALIGN(align); \ + .data.init_task : { \ + INIT_TASK \ + } + /* init and exit section handling */ #define INIT_DATA \ *(.init.data) \ @@ -363,9 +468,32 @@ CPU_DISCARD(exit.text) \ MEM_DISCARD(exit.text) - /* DWARF debug sections. - Symbols in the DWARF debugging sections are relative to - the beginning of the section so we begin them at 0. */ +/* + * bss (Block started by Symbol) - uninitialized data + * zeroed during startup + */ +#define SBSS \ + .sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \ + *(.sbss) \ + *(.scommon) \ + } + +#define BSS(bss_align) \ + . = ALIGN(bss_align); \ + .bss : AT(ADDR(.bss) - LOAD_OFFSET) { \ + VMLINUX_SYMBOL(__bss_start) = .; \ + *(.bss.page_aligned) \ + *(.dynbss) \ + *(.bss) \ + *(COMMON) \ + VMLINUX_SYMBOL(__bss_stop) = .; \ + } + +/* + * DWARF debug sections. + * Symbols in the DWARF debugging sections are relative to + * the beginning of the section so we begin them at 0. + */ #define DWARF_DEBUG \ /* DWARF 1 */ \ .debug 0 : { *(.debug) } \ @@ -432,6 +560,12 @@ VMLINUX_SYMBOL(__stop_notes) = .; \ } +#define INIT_SETUP(initsetup_align) \ + . = ALIGN(initsetup_align); \ + VMLINUX_SYMBOL(__setup_start) = .; \ + *(.init.setup) \ + VMLINUX_SYMBOL(__setup_end) = .; + #define INITCALLS \ *(.initcallearly.init) \ VMLINUX_SYMBOL(__early_initcall_end) = .; \ @@ -453,6 +587,31 @@ *(.initcall7.init) \ *(.initcall7s.init) +#define INIT_CALLS \ + VMLINUX_SYMBOL(__initcall_start) = .; \ + INITCALLS \ + VMLINUX_SYMBOL(__initcall_end) = .; + +#define CON_INITCALL \ + VMLINUX_SYMBOL(__con_initcall_start) = .; \ + *(.con_initcall.init) \ + VMLINUX_SYMBOL(__con_initcall_end) = .; + +#define SECURITY_INITCALL \ + VMLINUX_SYMBOL(__security_initcall_start) = .; \ + *(.security_initcall.init) \ + VMLINUX_SYMBOL(__security_initcall_end) = .; + +#ifdef CONFIG_BLK_DEV_INITRD +#define INIT_RAM_FS \ + . = ALIGN(PAGE_SIZE); \ + VMLINUX_SYMBOL(__initramfs_start) = .; \ + *(.init.ramfs) \ + VMLINUX_SYMBOL(__initramfs_end) = .; +#else +#define INITRAMFS +#endif + /** * PERCPU_VADDR - define output section for percpu area * @vaddr: explicit base address (optional) @@ -509,3 +668,49 @@ *(.data.percpu.shared_aligned) \ VMLINUX_SYMBOL(__per_cpu_end) = .; \ } + + +/* + * Definition of the high level *_SECTION macros + * They will fit only a subset of the architectures + */ + +#define RO_DATA_SECTION(align) RO_DATA(align) + +/* use 0 as page_align if page_aligned data is not used */ +#define RW_DATA_SECTION(page_align, readmostly_align, cache_align, inittask_align) \ + . = ALIGN(PAGE_SIZE); \ + .data : AT(ADDR(.data) - LOAD_OFFSET) { \ + DATA_DATA \ + CONSTRUCTORS \ + NOSAVE_DATA \ + PAGE_ALIGNED_DATA(page_align) \ + READMOSTLY_DATA(readmostly_align) \ + CACHELINE_ALIGNED_DATA(cache_align) \ + INIT_TASK(inittask_align) \ + } + +#define INIT_TEXT_SECTION(inittext_align) \ + . = ALIGN(inittext_align); \ + .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { \ + VMLINUX_SYMBOL(_sinittext) = .; \ + INIT_TEXT \ + VMLINUX_SYMBOL(_einittext) = .; \ + } + +#define INIT_DATA_SECTION(initsetup_align) \ + .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { \ + INIT_DATA \ + INIT_SETUP(initsetup_align) \ + INIT_CALLS \ + CON_INITCALL \ + SECURITY_INITCALL \ + INIT_RAM_FS \ + } + +#define BSS_SECTION(sbss_align, bss_align) \ + SBSS \ + VMLINUX_SYMBOL(__bss_start) = .; \ + BSS(bss_align) \ + . = ALIGN(4); \ + VMLINUX_SYMBOL(__bss_stop) = .; ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH/RFC] Sample conversion of powerpc 2009-05-04 14:27 ` Sam Ravnborg @ 2009-05-04 14:30 ` Sam Ravnborg 2009-05-04 16:32 ` [PATCH v2 0/6] macros for section name cleanup Tim Abbott 1 sibling, 0 replies; 8+ messages in thread From: Sam Ravnborg @ 2009-05-04 14:30 UTC (permalink / raw) To: Tim Abbott; +Cc: Linux kernel mailing list, linux arch, Anders Kaseorg This is the patch to convert powerpc to the new linker script setup. Note that powerpc does not take benefit of all the consolidations. Sam arch/powerpc/kernel/vmlinux.lds.S | 53 +++++-------------------------------- 1 files changed, 7 insertions(+), 46 deletions(-) diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S index a047a6c..e0fef43 100644 --- a/arch/powerpc/kernel/vmlinux.lds.S +++ b/arch/powerpc/kernel/vmlinux.lds.S @@ -75,14 +75,8 @@ SECTIONS PROVIDE32 (etext = .); /* Read-only data */ - RODATA - - /* Exception & bug tables */ - __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { - __start___ex_table = .; - *(__ex_table) - __stop___ex_table = .; - } + RO_DATA_SECTION(PAGE_SIZE) + EXCEPTION_TABLE(1) NOTES :kernel :notes @@ -100,11 +94,7 @@ SECTIONS . = ALIGN(PAGE_SIZE); __init_begin = .; - .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { - _sinittext = .; - INIT_TEXT - _einittext = .; - } :kernel + INIT_TEXT_SECTION(PAGE_SIZE) :kernel /* .exit.text is discarded at runtime, not link time, * to deal with references from __bug_table @@ -113,8 +103,10 @@ SECTIONS EXIT_TEXT } - .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { - INIT_DATA + INIT_DATA_SECTION(16) + PERCPU(PAGE_SIZE) + + .init.data : { __vtop_table_begin = .; *(.vtop_fixup); __vtop_table_end = .; @@ -128,27 +120,6 @@ SECTIONS #endif } - . = ALIGN(16); - .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { - __setup_start = .; - *(.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 = .; - *(.con_initcall.init) - __con_initcall_end = .; - } - - SECURITY_INIT - . = ALIGN(8); __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) { __start___ftr_fixup = .; @@ -175,15 +146,6 @@ SECTIONS __stop___fw_ftr_fixup = .; } #endif -#ifdef CONFIG_BLK_DEV_INITRD - . = ALIGN(PAGE_SIZE); - .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { - __initramfs_start = .; - *(.init.ramfs) - __initramfs_end = .; - } -#endif - PERCPU(PAGE_SIZE) . = ALIGN(8); .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) { @@ -247,7 +209,6 @@ SECTIONS . = ALIGN(PAGE_SIZE); _edata = .; - PROVIDE32 (edata = .); /* The initial task and kernel stack */ #ifdef CONFIG_PPC32 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/6] macros for section name cleanup 2009-05-04 14:27 ` Sam Ravnborg 2009-05-04 14:30 ` [PATCH/RFC] Sample conversion of powerpc Sam Ravnborg @ 2009-05-04 16:32 ` Tim Abbott 2009-05-04 17:42 ` Mike Frysinger 1 sibling, 1 reply; 8+ messages in thread From: Tim Abbott @ 2009-05-04 16:32 UTC (permalink / raw) To: Sam Ravnborg; +Cc: Linux kernel mailing list, linux arch, Anders Kaseorg On Mon, 4 May 2009, Sam Ravnborg wrote: > I'm especially fond of the "minimal" linker script > contained in the beginning of the file. I like this a lot too. > + * /DISCARD/ : { > + * EXIT_TEXT > + * EXIT_DATA > + * *(.exitcall.exit) > + * } You may want to create an EXIT_CALL macro, to remove the explicit mention of .exitcall.exit, which is the only input section referenced directly in the example script. > +#define READ_MOSTLY_DATA(align) \ > + . = ALIGN(align); \ > + *(.data.read_mostly) Should READ_MOSTLY_DATA have an ALIGN(align) at the end as well? If the goal is to isolate READ_MOSTLY_DATA from other data at the given alignment level, this would seem appropriate. Something similar may apply to CACHELINE_ALIGNED_DATA as well. > +/* > + * bss (Block started by Symbol) - uninitialized data > + * zeroed during startup > + */ > +#define SBSS \ > + .sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \ > + *(.sbss) \ > + *(.scommon) \ > + } I notice that s390 and powerpc reference a ".dynsbss"; does that belong here? > +#ifdef CONFIG_BLK_DEV_INITRD > +#define INIT_RAM_FS \ > + . = ALIGN(PAGE_SIZE); \ > + VMLINUX_SYMBOL(__initramfs_start) = .; \ > + *(.init.ramfs) \ > + VMLINUX_SYMBOL(__initramfs_end) = .; > +#else > +#define INITRAMFS > +#endif I think you want the #else clause to be INIT_RAM_FS here. > +/* > + * Definition of the high level *_SECTION macros > + * They will fit only a subset of the architectures > + */ Do we want a TEXT_SECTION macro here as well that looks like what appears above in the example script? > +#define RW_DATA_SECTION(page_align, readmostly_align, cache_align, inittask_align) \ > + . = ALIGN(PAGE_SIZE); \ > + .data : AT(ADDR(.data) - LOAD_OFFSET) { \ > + DATA_DATA \ > + CONSTRUCTORS \ > + NOSAVE_DATA \ > + PAGE_ALIGNED_DATA(page_align) \ > + READMOSTLY_DATA(readmostly_align) \ > + CACHELINE_ALIGNED_DATA(cache_align) \ > + INIT_TASK(inittask_align) \ > + } How did you pick the order of the sections here? I would think that to pack the .data section efficiently, you'd want to sort by alignment requirements so that e.g. all the at-least-page aligned sections are adjacent (INIT_TASK and the page-aligned sections are separated by some much smaller aligments here). So it would like either the following or the following reversed: . = ALIGN(PAGE_SIZE); \ .data : AT(ADDR(.data) - LOAD_OFFSET) { \ INIT_TASK(inittask_align) \ NOSAVE_DATA \ PAGE_ALIGNED_DATA(page_align) \ READMOSTLY_DATA(readmostly_align) \ CACHELINE_ALIGNED_DATA(cache_align) \ DATA_DATA \ CONSTRUCTORS \ } -Tim Abbott ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/6] macros for section name cleanup 2009-05-04 16:32 ` [PATCH v2 0/6] macros for section name cleanup Tim Abbott @ 2009-05-04 17:42 ` Mike Frysinger 2009-05-04 17:54 ` Sam Ravnborg 0 siblings, 1 reply; 8+ messages in thread From: Mike Frysinger @ 2009-05-04 17:42 UTC (permalink / raw) To: Tim Abbott Cc: Sam Ravnborg, Linux kernel mailing list, linux arch, Anders Kaseorg On Mon, May 4, 2009 at 12:32, Tim Abbott wrote: > On Mon, 4 May 2009, Sam Ravnborg wrote: >> +#define RW_DATA_SECTION(page_align, readmostly_align, cache_align, >> inittask_align) \ >> + . = ALIGN(PAGE_SIZE); \ >> + .data : AT(ADDR(.data) - LOAD_OFFSET) { \ >> + DATA_DATA \ >> + CONSTRUCTORS \ >> + NOSAVE_DATA \ >> + PAGE_ALIGNED_DATA(page_align) \ >> + READMOSTLY_DATA(readmostly_align) \ >> + CACHELINE_ALIGNED_DATA(cache_align) \ >> + INIT_TASK(inittask_align) \ >> + } > > How did you pick the order of the sections here? I would think that to > pack the .data section efficiently, you'd want to sort by alignment > requirements so that e.g. all the at-least-page aligned sections are > adjacent (INIT_TASK and the page-aligned sections are separated by some > much smaller aligments here). if this were actually the case, there should of course be some /* comments */ above the define explaining that the order wasnt arbitrarily pulled like a rabbit from an orifice. if you're scratching your head, then there's going to be plenty more people who never ask but treat it like untouchable voodoo. -mike ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/6] macros for section name cleanup 2009-05-04 17:42 ` Mike Frysinger @ 2009-05-04 17:54 ` Sam Ravnborg 0 siblings, 0 replies; 8+ messages in thread From: Sam Ravnborg @ 2009-05-04 17:54 UTC (permalink / raw) To: Mike Frysinger Cc: Tim Abbott, Linux kernel mailing list, linux arch, Anders Kaseorg On Mon, May 04, 2009 at 01:42:08PM -0400, Mike Frysinger wrote: > On Mon, May 4, 2009 at 12:32, Tim Abbott wrote: > > On Mon, 4 May 2009, Sam Ravnborg wrote: > >> +#define RW_DATA_SECTION(page_align, readmostly_align, cache_align, > >> inittask_align) \ > >> + . = ALIGN(PAGE_SIZE); \ > >> + .data : AT(ADDR(.data) - LOAD_OFFSET) { \ > >> + DATA_DATA \ > >> + CONSTRUCTORS \ > >> + NOSAVE_DATA \ > >> + PAGE_ALIGNED_DATA(page_align) \ > >> + READMOSTLY_DATA(readmostly_align) \ > >> + CACHELINE_ALIGNED_DATA(cache_align) \ > >> + INIT_TASK(inittask_align) \ > >> + } > > > > How did you pick the order of the sections here? I would think that to > > pack the .data section efficiently, you'd want to sort by alignment > > requirements so that e.g. all the at-least-page aligned sections are > > adjacent (INIT_TASK and the page-aligned sections are separated by some > > much smaller aligments here). > > if this were actually the case, there should of course be some /* > comments */ above the define explaining that the order wasnt > arbitrarily pulled like a rabbit from an orifice. if you're > scratching your head, then there's going to be plenty more people who > never ask but treat it like untouchable voodoo. Point taken (from both of you). I will try to document the order in next version. In reality I just picked the order used for 32 bit x86 IIRC. Sam ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-05-04 17:52 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1241121253-32341-1-git-send-email-tabbott@mit.edu>
2009-05-01 21:31 ` [PATCH v2 0/6] macros for section name cleanup Sam Ravnborg
2009-05-02 0:48 ` Tim Abbott
2009-05-02 22:01 ` Sam Ravnborg
2009-05-04 14:27 ` Sam Ravnborg
2009-05-04 14:30 ` [PATCH/RFC] Sample conversion of powerpc Sam Ravnborg
2009-05-04 16:32 ` [PATCH v2 0/6] macros for section name cleanup Tim Abbott
2009-05-04 17:42 ` Mike Frysinger
2009-05-04 17:54 ` Sam Ravnborg
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox