Hi Linus,
This patch series contains patches cleaning up the linker scripts on
several architectures architectures (as well as one improvement to the
architecture-independent macros). Everything here has been acked or
reviewed by Sam Ravnborg. Please merge.
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 (13):
Optimize the ordering of sections in RW_DATA_SECTION.
m32r: make PAGE_SIZE available to assembly.
m32r: Define THREAD_SIZE only once.
m32r: Move GET_THREAD_INFO definition out of asm/thread_info.h.
m32r: Remove unused .altinstructions and .exit.* code from linker
script.
m32r: Move the spi_stack_top and spu_stack_top into .init.data
section.
m32r: Cleanup linker script using new linker script macros.
parisc: Clean up linker script using new linker script macros.
parisc: Remove useless altinstructions code copied from x86.
xtensa: Cleanup linker script using new linker script macros.
um: Clean up linker script using standard macros.
h8300: Cleanup linker script using new linker script macros.
mn10300: Clean up linker script using higher-level macros.
arch/h8300/kernel/vmlinux.lds.S | 25 ++------
arch/m32r/include/asm/page.h | 4 +-
arch/m32r/include/asm/processor.h | 2 -
arch/m32r/include/asm/thread_info.h | 15 +----
arch/m32r/kernel/entry.S | 7 ++
arch/m32r/kernel/head.S | 4 +-
arch/m32r/kernel/vmlinux.lds.S | 78 +++-----------------------
arch/mn10300/kernel/vmlinux.lds.S | 40 +------------
arch/parisc/kernel/vmlinux.lds.S | 104 +---------------------------------
arch/um/include/asm/common.lds.S | 29 ++--------
arch/um/kernel/dyn.lds.S | 9 +--
arch/um/kernel/uml.lds.S | 26 ++-------
arch/xtensa/kernel/vmlinux.lds.S | 75 +++++--------------------
include/asm-generic/vmlinux.lds.h | 4 +-
14 files changed, 68 insertions(+), 354 deletions(-)
Signed-off-by: Tim Abbott <[email protected]>
Reviewed-by: Sam Ravnborg <[email protected]>
---
include/asm-generic/vmlinux.lds.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 29ca8f5..b6e818f 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -721,12 +721,12 @@
. = ALIGN(PAGE_SIZE); \
.data : AT(ADDR(.data) - LOAD_OFFSET) { \
INIT_TASK_DATA(inittask) \
+ NOSAVE_DATA \
+ PAGE_ALIGNED_DATA(pagealigned) \
CACHELINE_ALIGNED_DATA(cacheline) \
READ_MOSTLY_DATA(cacheline) \
DATA_DATA \
CONSTRUCTORS \
- NOSAVE_DATA \
- PAGE_ALIGNED_DATA(pagealigned) \
}
#define INIT_TEXT_SECTION(inittext_align) \
--
1.6.3.3
page.h includes ifndef __ASSEMBLY__ guards, but PAGE_SIZE is defined
using "1UL", which the assembler does not support. Use the _AC macro
from const.h to make it available to assembly (and linker scripts).
Signed-off-by: Tim Abbott <[email protected]>
Cc: Hirokazu Takata <[email protected]>
Acked-by: Sam Ravnborg <[email protected]>
---
arch/m32r/include/asm/page.h | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/arch/m32r/include/asm/page.h b/arch/m32r/include/asm/page.h
index 11777f7..725ede8 100644
--- a/arch/m32r/include/asm/page.h
+++ b/arch/m32r/include/asm/page.h
@@ -1,9 +1,11 @@
#ifndef _ASM_M32R_PAGE_H
#define _ASM_M32R_PAGE_H
+#include <linux/const.h>
+
/* PAGE_SHIFT determines the page size */
#define PAGE_SHIFT 12
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
+#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
#ifndef __ASSEMBLY__
--
1.6.3.3
Previously, m32r's asm/thread_info.h defined THREAD_SIZE differently
for assembly and C code; now that PAGE_SIZE is usable from assembly,
these can be combined. Also, m32r's asm/processor.h redefines
THREAD_SIZE to the same value; remove this redundant definition.
Signed-off-by: Tim Abbott <[email protected]>
Cc: Hirokazu Takata <[email protected]>
Acked-by: Sam Ravnborg <[email protected]>
---
arch/m32r/include/asm/processor.h | 2 --
arch/m32r/include/asm/thread_info.h | 6 ++----
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/arch/m32r/include/asm/processor.h b/arch/m32r/include/asm/processor.h
index 1a997fc..8397c24 100644
--- a/arch/m32r/include/asm/processor.h
+++ b/arch/m32r/include/asm/processor.h
@@ -140,8 +140,6 @@ unsigned long get_wchan(struct task_struct *p);
#define KSTK_EIP(tsk) ((tsk)->thread.lr)
#define KSTK_ESP(tsk) ((tsk)->thread.sp)
-#define THREAD_SIZE (2*PAGE_SIZE)
-
#define cpu_relax() barrier()
#endif /* _ASM_M32R_PROCESSOR_H */
diff --git a/arch/m32r/include/asm/thread_info.h b/arch/m32r/include/asm/thread_info.h
index 7157815..4d66169 100644
--- a/arch/m32r/include/asm/thread_info.h
+++ b/arch/m32r/include/asm/thread_info.h
@@ -55,6 +55,8 @@ struct thread_info {
#define PREEMPT_ACTIVE 0x10000000
+#define THREAD_SIZE (PAGE_SIZE << 1)
+
/*
* macros/functions for gaining access to the thread information structure
*/
@@ -76,8 +78,6 @@ struct thread_info {
#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)
-#define THREAD_SIZE (2*PAGE_SIZE)
-
/* how to get the thread information struct from C */
static inline struct thread_info *current_thread_info(void)
{
@@ -127,8 +127,6 @@ static inline unsigned int get_thread_fault_code(void)
#else /* !__ASSEMBLY__ */
-#define THREAD_SIZE 8192
-
/* how to get the thread information struct from ASM */
#define GET_THREAD_INFO(reg) GET_THREAD_INFO reg
.macro GET_THREAD_INFO reg
--
1.6.3.3
Previously, asm/thread_info.h was not usable from linker scripts
because it contains a piece of .macro code. Since that code was only
used in the m32r entry.S, the right fix is probably to move the macro
there.
Signed-off-by: Tim Abbott <[email protected]>
Cc: Hirokazu Takata <[email protected]>
Acked-by: Sam Ravnborg <[email protected]>
---
arch/m32r/include/asm/thread_info.h | 9 ---------
arch/m32r/kernel/entry.S | 7 +++++++
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/arch/m32r/include/asm/thread_info.h b/arch/m32r/include/asm/thread_info.h
index 4d66169..ed240b6 100644
--- a/arch/m32r/include/asm/thread_info.h
+++ b/arch/m32r/include/asm/thread_info.h
@@ -125,15 +125,6 @@ static inline unsigned int get_thread_fault_code(void)
return ti->flags >> TI_FLAG_FAULT_CODE_SHIFT;
}
-#else /* !__ASSEMBLY__ */
-
-/* how to get the thread information struct from ASM */
-#define GET_THREAD_INFO(reg) GET_THREAD_INFO reg
- .macro GET_THREAD_INFO reg
- ldi \reg, #-THREAD_SIZE
- and \reg, sp
- .endm
-
#endif
/*
diff --git a/arch/m32r/kernel/entry.S b/arch/m32r/kernel/entry.S
index 612d35b..4038698 100644
--- a/arch/m32r/kernel/entry.S
+++ b/arch/m32r/kernel/entry.S
@@ -118,6 +118,13 @@
#define resume_kernel restore_all
#endif
+/* how to get the thread information struct from ASM */
+#define GET_THREAD_INFO(reg) GET_THREAD_INFO reg
+ .macro GET_THREAD_INFO reg
+ ldi \reg, #-THREAD_SIZE
+ and \reg, sp
+ .endm
+
ENTRY(ret_from_fork)
pop r0
bl schedule_tail
--
1.6.3.3
It appears that m32r copied the .altinstructions definition from x86
when the architecture was first merged into Linux. m32r doesn't put
anything in .altinstructions, so this is just dead code.
The following block affecting .exit.text/.exit.data, which has a
comment also copied from x86, should also be deleted; the linker
script later discards the .exit.text and .exit.data sections.
Signed-off-by: Tim Abbott <[email protected]>
Cc: Hirokazu Takata <[email protected]>
Acked-by: Sam Ravnborg <[email protected]>
---
arch/m32r/kernel/vmlinux.lds.S | 9 ---------
1 files changed, 0 insertions(+), 9 deletions(-)
diff --git a/arch/m32r/kernel/vmlinux.lds.S b/arch/m32r/kernel/vmlinux.lds.S
index de5e21c..a8aa4a8 100644
--- a/arch/m32r/kernel/vmlinux.lds.S
+++ b/arch/m32r/kernel/vmlinux.lds.S
@@ -91,15 +91,6 @@ SECTIONS
.con_initcall.init : { *(.con_initcall.init) }
__con_initcall_end = .;
SECURITY_INIT
- . = ALIGN(4);
- __alt_instructions = .;
- .altinstructions : { *(.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 }
#ifdef CONFIG_BLK_DEV_INITRD
. = ALIGN(4096);
--
1.6.3.3
Since these get squashed into the .data output section by the m32r
linker script, it seems likely that they don't need their own input
sections.
At Hirokazu Takata's suggestion, we place these structures in
.init.data rather than just placing them in .data (since they are only
used at init time).
This patch is preparation for cleaning up the m32r architecture to use
the new macros in vmlinux.lds.h; if these sections are indeed not
needed, then we can use the RW_DATA_SECTION macro for m32r and save a
bunch of redundant code.
Signed-off-by: Tim Abbott <[email protected]>
Cc: Hirokazu Takata <[email protected]>
Acked-by: Sam Ravnborg <[email protected]>
---
arch/m32r/kernel/head.S | 4 ++--
arch/m32r/kernel/vmlinux.lds.S | 2 --
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/m32r/kernel/head.S b/arch/m32r/kernel/head.S
index 0a71944..a46652d 100644
--- a/arch/m32r/kernel/head.S
+++ b/arch/m32r/kernel/head.S
@@ -268,13 +268,13 @@ ENTRY(empty_zero_page)
/*------------------------------------------------------------------------
* Stack area
*/
- .section .spi
+ .section .init.data, "aw"
ALIGN
.global spi_stack_top
.zero 1024
spi_stack_top:
- .section .spu
+ .section .init.data, "aw"
ALIGN
.global spu_stack_top
.zero 1024
diff --git a/arch/m32r/kernel/vmlinux.lds.S b/arch/m32r/kernel/vmlinux.lds.S
index a8aa4a8..aadb24e 100644
--- a/arch/m32r/kernel/vmlinux.lds.S
+++ b/arch/m32r/kernel/vmlinux.lds.S
@@ -49,8 +49,6 @@ SECTIONS
/* writeable */
.data : { /* Data */
- *(.spu)
- *(.spi)
DATA_DATA
CONSTRUCTORS
}
--
1.6.3.3
This patch is largely a straightforward conversion. One thing to note
is that the new macros use fewer separate output sections than the old
code; this should have no functional impact but is relevant for people
objdumping vmlinux files.
Also note that it moves the .data.init_task output sections inside
_edata.
Signed-off-by: Tim Abbott <[email protected]>
Cc: Hirokazu Takata <[email protected]>
Acked-by: Sam Ravnborg <[email protected]>
---
arch/m32r/kernel/vmlinux.lds.S | 67 +++++----------------------------------
1 files changed, 9 insertions(+), 58 deletions(-)
diff --git a/arch/m32r/kernel/vmlinux.lds.S b/arch/m32r/kernel/vmlinux.lds.S
index aadb24e..8ceb618 100644
--- a/arch/m32r/kernel/vmlinux.lds.S
+++ b/arch/m32r/kernel/vmlinux.lds.S
@@ -4,6 +4,7 @@
#include <asm-generic/vmlinux.lds.h>
#include <asm/addrspace.h>
#include <asm/page.h>
+#include <asm/thread_info.h>
OUTPUT_ARCH(m32r)
#if defined(__LITTLE_ENDIAN__)
@@ -40,72 +41,22 @@ SECTIONS
#endif
_etext = .; /* End of text section */
- . = ALIGN(16); /* Exception table */
- __start___ex_table = .;
- __ex_table : { *(__ex_table) }
- __stop___ex_table = .;
-
+ EXCEPTION_TABLE(16)
RODATA
-
- /* writeable */
- .data : { /* Data */
- DATA_DATA
- CONSTRUCTORS
- }
-
- . = ALIGN(4096);
- __nosave_begin = .;
- .data_nosave : { *(.data.nosave) }
- . = ALIGN(4096);
- __nosave_end = .;
-
- . = ALIGN(32);
- .data.cacheline_aligned : { *(.data.cacheline_aligned) }
-
+ RW_DATA_SECTION(32, PAGE_SIZE, THREAD_SIZE)
_edata = .; /* End of data section */
- . = ALIGN(8192); /* init_task */
- .data.init_task : { *(.data.init_task) }
-
/* will be freed after init */
- . = ALIGN(4096); /* Init code and data */
+ . = ALIGN(PAGE_SIZE); /* Init code and data */
__init_begin = .;
- .init.text : {
- _sinittext = .;
- INIT_TEXT
- _einittext = .;
- }
- .init.data : { INIT_DATA }
- . = ALIGN(16);
- __setup_start = .;
- .init.setup : { *(.init.setup) }
- __setup_end = .;
- __initcall_start = .;
- .initcall.init : {
- INITCALLS
- }
- __initcall_end = .;
- __con_initcall_start = .;
- .con_initcall.init : { *(.con_initcall.init) }
- __con_initcall_end = .;
- SECURITY_INIT
-
-#ifdef CONFIG_BLK_DEV_INITRD
- . = ALIGN(4096);
- __initramfs_start = .;
- .init.ramfs : { *(.init.ramfs) }
- __initramfs_end = .;
-#endif
-
- PERCPU(4096)
- . = ALIGN(4096);
+ INIT_TEXT_SECTION(PAGE_SIZE)
+ INIT_DATA_SECTION(16)
+ PERCPU(PAGE_SIZE)
+ . = ALIGN(PAGE_SIZE);
__init_end = .;
/* freed after init ends here */
- __bss_start = .; /* BSS */
- .bss : { *(.bss) }
- . = ALIGN(4);
- __bss_stop = .;
+ BSS_SECTION(0, 0, 4)
_end = . ;
--
1.6.3.3
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.
Signed-off-by: Tim Abbott <[email protected]>
Cc: Kyle McMartin <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: [email protected]
Acked-by: Sam Ravnborg <[email protected]>
---
arch/parisc/kernel/vmlinux.lds.S | 79 ++------------------------------------
1 files changed, 4 insertions(+), 75 deletions(-)
diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S
index aea1784..3fd66d9 100644
--- a/arch/parisc/kernel/vmlinux.lds.S
+++ b/arch/parisc/kernel/vmlinux.lds.S
@@ -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);
--
1.6.3.3
Signed-off-by: Tim Abbott <[email protected]>
Cc: Kyle McMartin <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: [email protected]
Acked-by: Sam Ravnborg <[email protected]>
---
arch/parisc/kernel/vmlinux.lds.S | 25 -------------------------
1 files changed, 0 insertions(+), 25 deletions(-)
diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S
index 3fd66d9..775be27 100644
--- a/arch/parisc/kernel/vmlinux.lds.S
+++ b/arch/parisc/kernel/vmlinux.lds.S
@@ -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
- }
-
PERCPU(PAGE_SIZE)
. = ALIGN(PAGE_SIZE);
__init_end = .;
--
1.6.3.3
Signed-off-by: Tim Abbott <[email protected]>
Cc: Chris Zankel <[email protected]>
Acked-by: Sam Ravnborg <[email protected]>
---
arch/xtensa/kernel/vmlinux.lds.S | 75 +++++++-------------------------------
1 files changed, 14 insertions(+), 61 deletions(-)
diff --git a/arch/xtensa/kernel/vmlinux.lds.S b/arch/xtensa/kernel/vmlinux.lds.S
index 921b6ff..9b52615 100644
--- a/arch/xtensa/kernel/vmlinux.lds.S
+++ b/arch/xtensa/kernel/vmlinux.lds.S
@@ -15,6 +15,8 @@
*/
#include <asm-generic/vmlinux.lds.h>
+#include <asm/page.h>
+#include <asm/thread_info.h>
#include <variant/core.h>
#include <platform/hardware.h>
@@ -107,41 +109,18 @@ SECTIONS
.fixup : { *(.fixup) }
- . = ALIGN(16);
-
- __ex_table : {
- __start___ex_table = .;
- *(__ex_table)
- __stop___ex_table = .;
- }
-
+ EXCEPTION_TABLE(16)
/* Data section */
- . = ALIGN(XCHAL_ICACHE_LINESIZE);
_fdata = .;
- .data :
- {
- DATA_DATA
- CONSTRUCTORS
- . = ALIGN(XCHAL_ICACHE_LINESIZE);
- *(.data.cacheline_aligned)
- }
-
+ RW_DATA_SECTION(XCHAL_ICACHE_LINESIZE, PAGE_SIZE, THREAD_SIZE)
_edata = .;
- /* The initial task */
- . = ALIGN(8192);
- .data.init_task : { *(.data.init_task) }
-
/* Initialization code and data: */
- . = ALIGN(1 << 12);
+ . = ALIGN(PAGE_SIZE);
__init_begin = .;
- .init.text : {
- _sinittext = .;
- INIT_TEXT
- _einittext = .;
- }
+ INIT_TEXT_SECTION(PAGE_SIZE)
.init.data :
{
@@ -168,36 +147,15 @@ SECTIONS
.DebugInterruptVector.text);
__boot_reloc_table_end = ABSOLUTE(.) ;
- }
- . = ALIGN(XCHAL_ICACHE_LINESIZE);
-
- __setup_start = .;
- .init.setup : { *(.init.setup) }
- __setup_end = .;
-
- __initcall_start = .;
- .initcall.init : {
- INITCALLS
+ INIT_SETUP(XCHAL_ICACHE_LINESIZE)
+ INIT_CALLS
+ CON_INITCALL
+ SECURITY_INITCALL
+ INIT_RAM_FS
}
- __initcall_end = .;
-
- __con_initcall_start = .;
- .con_initcall.init : { *(.con_initcall.init) }
- __con_initcall_end = .;
-
- SECURITY_INIT
-
-
-#ifdef CONFIG_BLK_DEV_INITRD
- . = ALIGN(4096);
- __initramfs_start =.;
- .init.ramfs : { *(.init.ramfs) }
- __initramfs_end = .;
-#endif
-
- PERCPU(4096)
+ PERCPU(PAGE_SIZE)
/* We need this dummy segment here */
@@ -252,16 +210,11 @@ SECTIONS
.DoubleExceptionVector.literal)
. = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
- . = ALIGN(1 << 12);
+ . = ALIGN(PAGE_SIZE);
__init_end = .;
- . = ALIGN(8192);
-
- /* BSS section */
- _bss_start = .;
- .bss : { *(.bss.page_aligned) *(.bss) }
- _bss_end = .;
+ BSS_SECTION(0, 8192, 0)
_end = .;
--
1.6.3.3
Signed-off-by: Tim Abbott <[email protected]>
Cc: Jeff Dike <[email protected]>
Cc: [email protected]
Acked-by: Sam Ravnborg <[email protected]>
---
arch/um/include/asm/common.lds.S | 29 ++++++-----------------------
arch/um/kernel/dyn.lds.S | 9 ++-------
arch/um/kernel/uml.lds.S | 26 ++++++--------------------
3 files changed, 14 insertions(+), 50 deletions(-)
diff --git a/arch/um/include/asm/common.lds.S b/arch/um/include/asm/common.lds.S
index 37ecc55..ac55b9e 100644
--- a/arch/um/include/asm/common.lds.S
+++ b/arch/um/include/asm/common.lds.S
@@ -16,11 +16,7 @@
. = ALIGN(4096);
.note : { *(.note.*) }
- __ex_table : {
- __start___ex_table = .;
- *(__ex_table)
- __stop___ex_table = .;
- }
+ EXCEPTION_TABLE(0)
BUG_TABLE
@@ -43,28 +39,17 @@
}
.init.setup : {
- __setup_start = .;
- *(.init.setup)
- __setup_end = .;
+ INIT_SETUP(0)
}
- . = ALIGN(32);
- .data.percpu : {
- __per_cpu_start = . ;
- *(.data.percpu)
- __per_cpu_end = . ;
- }
+ PERCPU(32)
.initcall.init : {
- __initcall_start = .;
- INITCALLS
- __initcall_end = .;
+ INIT_CALLS
}
.con_initcall.init : {
- __con_initcall_start = .;
- *(.con_initcall.init)
- __con_initcall_end = .;
+ CON_INITCALL
}
.uml.initcall.init : {
@@ -118,8 +103,6 @@
. = ALIGN(4096);
.init.ramfs : {
- __initramfs_start = .;
- *(.init.ramfs)
- __initramfs_end = .;
+ INIT_RAM_FS
}
diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S
index 715a188..7fcad58 100644
--- a/arch/um/kernel/dyn.lds.S
+++ b/arch/um/kernel/dyn.lds.S
@@ -16,11 +16,7 @@ SECTIONS
_text = .;
_stext = .;
__init_begin = .;
- .init.text : {
- _sinittext = .;
- INIT_TEXT
- _einittext = .;
- }
+ INIT_TEXT_SECTION(PAGE_SIZE)
. = ALIGN(PAGE_SIZE);
@@ -96,8 +92,7 @@ SECTIONS
.init_array : { *(.init_array) }
.fini_array : { *(.fini_array) }
.data : {
- . = ALIGN(KERNEL_STACK_SIZE); /* init_task */
- *(.data.init_task)
+ INIT_TASK_DATA(KERNEL_STACK_SIZE)
. = ALIGN(KERNEL_STACK_SIZE);
*(.data.init_irqstack)
DATA_DATA
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
index 2ebd397..e7a6cca 100644
--- a/arch/um/kernel/uml.lds.S
+++ b/arch/um/kernel/uml.lds.S
@@ -22,11 +22,7 @@ SECTIONS
_text = .;
_stext = .;
__init_begin = .;
- .init.text : {
- _sinittext = .;
- INIT_TEXT
- _einittext = .;
- }
+ INIT_TEXT_SECTION(PAGE_SIZE)
. = ALIGN(PAGE_SIZE);
.text :
@@ -52,8 +48,7 @@ SECTIONS
init.data : { INIT_DATA }
.data :
{
- . = ALIGN(KERNEL_STACK_SIZE); /* init_task */
- *(.data.init_task)
+ INIT_TASK_DATA(KERNEL_STACK_SIZE)
. = ALIGN(KERNEL_STACK_SIZE);
*(.data.init_irqstack)
DATA_DATA
@@ -81,19 +76,10 @@ SECTIONS
_edata = .;
PROVIDE (edata = .);
. = ALIGN(PAGE_SIZE);
- .sbss :
- {
- __bss_start = .;
- PROVIDE(_bss_start = .);
- *(.sbss)
- *(.scommon)
- }
- .bss :
- {
- *(.dynbss)
- *(.bss)
- *(COMMON)
- }
+ __bss_start = .;
+ PROVIDE(_bss_start = .);
+ SBSS(0)
+ BSS(0)
_end = .;
PROVIDE (end = .);
--
1.6.3.3
Signed-off-by: Tim Abbott <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Acked-by: Sam Ravnborg <[email protected]>
---
arch/h8300/kernel/vmlinux.lds.S | 25 +++++++------------------
1 files changed, 7 insertions(+), 18 deletions(-)
diff --git a/arch/h8300/kernel/vmlinux.lds.S b/arch/h8300/kernel/vmlinux.lds.S
index 662b02e..b9e2490 100644
--- a/arch/h8300/kernel/vmlinux.lds.S
+++ b/arch/h8300/kernel/vmlinux.lds.S
@@ -1,5 +1,6 @@
#define VMLINUX_SYMBOL(_sym_) _##_sym_
#include <asm-generic/vmlinux.lds.h>
+#include <asm/page.h>
/* target memory map */
#ifdef CONFIG_H8300H_GENERIC
@@ -79,11 +80,8 @@ SECTIONS
SCHED_TEXT
LOCK_TEXT
__etext = . ;
- . = ALIGN(16); /* Exception table */
- ___start___ex_table = .;
- *(__ex_table)
- ___stop___ex_table = .;
}
+ EXCEPTION_TABLE(16)
RODATA
#if defined(CONFIG_ROMKERNEL)
@@ -100,8 +98,7 @@ SECTIONS
__sdata = . ;
___data_start = . ;
- . = ALIGN(0x2000) ;
- *(.data.init_task)
+ INIT_TASK_DATA(0x2000)
. = ALIGN(0x4) ;
DATA_DATA
. = ALIGN(0x4) ;
@@ -114,24 +111,16 @@ SECTIONS
__einittext = .;
INIT_DATA
. = ALIGN(0x4) ;
+ INIT_SETUP(0x4)
___setup_start = .;
*(.init.setup)
. = ALIGN(0x4) ;
___setup_end = .;
- ___initcall_start = .;
- INITCALLS
- ___initcall_end = .;
- ___con_initcall_start = .;
- *(.con_initcall.init)
- ___con_initcall_end = .;
+ INIT_CALLS
+ CON_INITCALL
EXIT_TEXT
EXIT_DATA
-#if defined(CONFIG_BLK_DEV_INITRD)
- . = ALIGN(4);
- ___initramfs_start = .;
- *(.init.ramfs)
- ___initramfs_end = .;
-#endif
+ INIT_RAM_FS
. = ALIGN(0x4) ;
___init_end = .;
__edata = . ;
--
1.6.3.3
Signed-off-by: Tim Abbott <[email protected]>
Cc: David Howells <[email protected]>
Cc: Koichi Yasutake <[email protected]>
Acked-by: Sam Ravnborg <[email protected]>
---
arch/mn10300/kernel/vmlinux.lds.S | 40 +++---------------------------------
1 files changed, 4 insertions(+), 36 deletions(-)
diff --git a/arch/mn10300/kernel/vmlinux.lds.S b/arch/mn10300/kernel/vmlinux.lds.S
index 76f41bd..10549dc 100644
--- a/arch/mn10300/kernel/vmlinux.lds.S
+++ b/arch/mn10300/kernel/vmlinux.lds.S
@@ -44,24 +44,8 @@ SECTIONS
RO_DATA(PAGE_SIZE)
/* writeable */
- .data : { /* Data */
- DATA_DATA
- CONSTRUCTORS
- }
-
- .data_nosave : { NOSAVE_DATA; }
-
- .data.page_aligned : { PAGE_ALIGNED_DATA(PAGE_SIZE); }
- .data.cacheline_aligned : { CACHELINE_ALIGNED_DATA(32); }
-
- /* rarely changed data like cpu maps */
- . = ALIGN(32);
- .data.read_mostly : AT(ADDR(.data.read_mostly)) {
- READ_MOSTLY_DATA(32);
- _edata = .; /* End of data section */
- }
-
- .data.init_task : { INIT_TASK_DATA(THREAD_SIZE); }
+ RW_DATA_SECTION(32, PAGE_SIZE, THREAD_SIZE)
+ _edata = .;
/* might get freed after init */
. = ALIGN(PAGE_SIZE);
@@ -74,22 +58,8 @@ SECTIONS
/* will be freed after init */
. = ALIGN(PAGE_SIZE); /* Init code and data */
__init_begin = .;
- .init.text : {
- _sinittext = .;
- INIT_TEXT;
- _einittext = .;
- }
- .init.data : { INIT_DATA; }
- .setup.init : { INIT_SETUP(16); }
-
- __initcall_start = .;
- .initcall.init : {
- INITCALLS
- }
- __initcall_end = .;
- .con_initcall.init : { CON_INITCALL; }
-
- SECURITY_INIT
+ INIT_TEXT_SECTION(PAGE_SIZE)
+ INIT_DATA_SECTION(16)
. = ALIGN(4);
__alt_instructions = .;
.altinstructions : { *(.altinstructions) }
@@ -100,8 +70,6 @@ SECTIONS
.exit.text : { EXIT_TEXT; }
.exit.data : { EXIT_DATA; }
- .init.ramfs : { INIT_RAM_FS; }
-
PERCPU(32)
. = ALIGN(PAGE_SIZE);
__init_end = .;
--
1.6.3.3
Umm. As a commit message this sucks. What's so optimized about this?
Linus
On Tue, 22 Sep 2009, Tim Abbott wrote:
>
> Signed-off-by: Tim Abbott <[email protected]>
> Reviewed-by: Sam Ravnborg <[email protected]>
> ---
> include/asm-generic/vmlinux.lds.h | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> index 29ca8f5..b6e818f 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -721,12 +721,12 @@
> . = ALIGN(PAGE_SIZE); \
> .data : AT(ADDR(.data) - LOAD_OFFSET) { \
> INIT_TASK_DATA(inittask) \
> + NOSAVE_DATA \
> + PAGE_ALIGNED_DATA(pagealigned) \
> CACHELINE_ALIGNED_DATA(cacheline) \
> READ_MOSTLY_DATA(cacheline) \
> DATA_DATA \
> CONSTRUCTORS \
> - NOSAVE_DATA \
> - PAGE_ALIGNED_DATA(pagealigned) \
> }
>
> #define INIT_TEXT_SECTION(inittext_align) \
> --
> 1.6.3.3
>
On Wed, 23 Sep 2009, Linus Torvalds wrote:
>
> Umm. As a commit message this sucks. What's so optimized about this?
Yeah, it does. Sorry about that.
This patch sorts the sections by alignment requirements, which should pack
them essentially optimally. The old RW_DATA_SECTION had INIT_TASK_DATA
(which was more-than-PAGE_SIZE-aligned), followed by a bunch of small
alignment stuff, followed by more PAGE_SIZE-aligned stuff, so you wasted
memory in the middle of .data re-aligning back up to PAGE_SIZE.
-Tim Abbott
> On Tue, 22 Sep 2009, Tim Abbott wrote:
> >
> > Signed-off-by: Tim Abbott <[email protected]>
> > Reviewed-by: Sam Ravnborg <[email protected]>
> > ---
> > include/asm-generic/vmlinux.lds.h | 4 ++--
> > 1 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> > index 29ca8f5..b6e818f 100644
> > --- a/include/asm-generic/vmlinux.lds.h
> > +++ b/include/asm-generic/vmlinux.lds.h
> > @@ -721,12 +721,12 @@
> > . = ALIGN(PAGE_SIZE); \
> > .data : AT(ADDR(.data) - LOAD_OFFSET) { \
> > INIT_TASK_DATA(inittask) \
> > + NOSAVE_DATA \
> > + PAGE_ALIGNED_DATA(pagealigned) \
> > CACHELINE_ALIGNED_DATA(cacheline) \
> > READ_MOSTLY_DATA(cacheline) \
> > DATA_DATA \
> > CONSTRUCTORS \
> > - NOSAVE_DATA \
> > - PAGE_ALIGNED_DATA(pagealigned) \
> > }
> >
> > #define INIT_TEXT_SECTION(inittext_align) \
> > --
> > 1.6.3.3
> >
>
On Tue, Sep 22, 2009 at 10:22:23AM -0400, Tim Abbott wrote:
> Signed-off-by: Tim Abbott <[email protected]>
> Cc: Kyle McMartin <[email protected]>
> Cc: Helge Deller <[email protected]>
> Cc: [email protected]
> Acked-by: Sam Ravnborg <[email protected]>
Heh, I had a patch to use this, but I guess I never finished it, (to nop
out some cache flushes and syncs on coherent architectures in the iommu
code.) I'll add a hunk to bring it back if/when I ever submit that
change.
cheers, Kyle