Skip to contentSkip to conversation

m68knommu: Clean up linker script using new linker script macros.

PATCH Superseded Tim Abbott 2 participants 7 messages Sep 7, 2009 – Sep 8, 2009

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Tim Abbott

author
#0 lore raw

PATCH 1/1 m68knommu: Clean up linker script using new linker script macros.

---
 arch/m68knommu/kernel/vmlinux.lds.S |   37 +++++++---------------------------
 1 files changed, 8 insertions(+), 29 deletions(-)
arch/m68knommu/kernel/vmlinux.lds.S +8 -29
index b7fe505..979acb5 100644
@@ -8,6 +8,8 @@
  */
 
 #include <asm-generic/vmlinux.lds.h>
+#include <asm/page.h>
+#include <asm/thread_info.h>
 
 #if defined(CONFIG_RAMKERNEL)
 #define	RAM_START	CONFIG_KERNELBASE
@@ -147,40 +149,17 @@ SECTIONS {
 		. = ALIGN(4);
 		_sdata = . ;
 		DATA_DATA
-		. = ALIGN(32);
-		*(.data.cacheline_aligned)
-		. = ALIGN(8192) ;
-		*(.data.init_task)
+		CACHELINE_ALIGNED_DATA(32)
+		INIT_TASK_DATA(THREAD_SIZE)
 		_edata = . ;
 	} > DATA
 
 	.init : {
-		. = ALIGN(4096);
+		. = ALIGN(PAGE_SIZE);
 		__init_begin = .;
-		_sinittext = .;
-		INIT_TEXT
-		_einittext = .;
-		INIT_DATA
-		. = ALIGN(16);
-		__setup_start = .;
-		*(.init.setup)
-		__setup_end = .;
-		__initcall_start = .;
-		INITCALLS
-		__initcall_end = .;
-		__con_initcall_start = .;
-		*(.con_initcall.init)
-		__con_initcall_end = .;
-		__security_initcall_start = .;
-		*(.security_initcall.init)
-		__security_initcall_end = .;
-#ifdef CONFIG_BLK_DEV_INITRD
-		. = ALIGN(4);
-		__initramfs_start = .;
-		*(.init.ramfs)
-		__initramfs_end = .;
-#endif
-		. = ALIGN(4096);
+		INIT_TEXT_SECTION(PAGE_SIZE)
+		INIT_DATA_SECTION(16)
+		. = ALIGN(PAGE_SIZE);
 		__init_end = .;
 	} > INIT
 
Signature · 1 line
1.6.3.3
#1 lore raw

Hi Tim,

Quoted 25 lines · Tim Abbott
---
 arch/m68knommu/kernel/vmlinux.lds.S |   37 +++++++---------------------------
 1 files changed, 8 insertions(+), 29 deletions(-)
arch/m68knommu/kernel/vmlinux.lds.S +2 -2
index b7fe505..979acb5 100644
@@ -8,6 +8,8 @@
  */
 
 #include <asm-generic/vmlinux.lds.h>
+#include <asm/page.h>
+#include <asm/thread_info.h>
 
 #if defined(CONFIG_RAMKERNEL)
 #define	RAM_START	CONFIG_KERNELBASE
@@ -147,40 +149,17 @@ SECTIONS {
 		. = ALIGN(4);
 		_sdata = . ;
 		DATA_DATA
-		. = ALIGN(32);
-		*(.data.cacheline_aligned)

arch/m68knommu/kernel/vmlinux.lds.S SECTIONS { · line 158

Quoted 10 lines
arch/m68knommu/kernel/vmlinux.lds.S +3 -3
-		. = ALIGN(8192) ;
-		*(.data.init_task)
+		CACHELINE_ALIGNED_DATA(32)
+		INIT_TASK_DATA(THREAD_SIZE)
 		_edata = . ;
 	} > DATA
 
 	.init : {
-		. = ALIGN(4096);
+		. = ALIGN(PAGE_SIZE);

This fails for me with:

LD vmlinux
/usr/local/bin/m68k-uclinux-ld:arch/m68knommu/kernel/vmlinux.lds:287: syntax error

due to PAGE_SIZE evaluating to:

  . = ALIGN((1UL << (12)));

The linker doesn't like the 'UL' suffix.

Regards
Greg

Quoted 31 lines
arch/m68knommu/kernel/vmlinux.lds.S +3 -24
 		__init_begin = .;
-		_sinittext = .;
-		INIT_TEXT
-		_einittext = .;
-		INIT_DATA
-		. = ALIGN(16);
-		__setup_start = .;
-		*(.init.setup)
-		__setup_end = .;
-		__initcall_start = .;
-		INITCALLS
-		__initcall_end = .;
-		__con_initcall_start = .;
-		*(.con_initcall.init)
-		__con_initcall_end = .;
-		__security_initcall_start = .;
-		*(.security_initcall.init)
-		__security_initcall_end = .;
-#ifdef CONFIG_BLK_DEV_INITRD
-		. = ALIGN(4);
-		__initramfs_start = .;
-		*(.init.ramfs)
-		__initramfs_end = .;
-#endif
-		. = ALIGN(4096);
+		INIT_TEXT_SECTION(PAGE_SIZE)
+		INIT_DATA_SECTION(16)
+		. = ALIGN(PAGE_SIZE);
 		__init_end = .;
 	} > INIT
 
Signature · 5 lines
------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     [email protected]
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com
author
#2 lore raw
Quoted 11 lines · Greg Ungerer

This fails for me with:

LD vmlinux
/usr/local/bin/m68k-uclinux-ld:arch/m68knommu/kernel/vmlinux.lds:287: syntax error

due to PAGE_SIZE evaluating to:

  . = ALIGN((1UL << (12)));

The linker doesn't like the 'UL' suffix.

Yeah, sorry, I didn't have a cross-compiler for this one to test. The fix is to use _AC(1,UL), like most of the other architectures (including m68k with an mmu) do.

-Tim Abbott

m68knommu: Make PAGE_SIZE available to assembly files.

---
 arch/m68k/include/asm/page_no.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
arch/m68k/include/asm/page_no.h +3 -1
index 9aa3f90..1f31b06 100644
@@ -1,10 +1,12 @@
 #ifndef _M68KNOMMU_PAGE_H
 #define _M68KNOMMU_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))
 
 #include <asm/setup.h>
Signature · 1 line
1.6.3.3
#3 lore raw

Hi Tim,

Quoted 8 lines · Tim Abbott
Quoted 6 lines · Greg Ungerer

This fails for me with:

LD vmlinux
/usr/local/bin/m68k-uclinux-ld:arch/m68knommu/kernel/vmlinux.lds:287: syntax error

Quoted 7 lines
Quoted 5 lines

due to PAGE_SIZE evaluating to:

  . = ALIGN((1UL << (12)));

The linker doesn't like the 'UL' suffix.

Yeah, sorry, I didn't have a cross-compiler for this one to test. The fix is to use _AC(1,UL), like most of the other architectures (including m68k with an mmu) do.

Yep, that fixes that. I'll push this patch into the for-linus branch of the m68knommu git tree.

Now, back to the original patch. Now fails with another syntax error at the last line in this:

.init : {
. = ALIGN((1 << (12)));
__init_begin = .;
. = ALIGN((1 << (12))); .init.text : AT(ADDR(.init.text) - 0) {
_sinittext = .; *(.init.text) *(.devinit.text) *(.cpuinit.text) *(.meminit.text) _einittext = .; }

Regards
Greg

Quoted 27 lines

-Tim Abbott

m68knommu: Make PAGE_SIZE available to assembly files.

---
 arch/m68k/include/asm/page_no.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
arch/m68k/include/asm/page_no.h +3 -1
index 9aa3f90..1f31b06 100644
@@ -1,10 +1,12 @@
 #ifndef _M68KNOMMU_PAGE_H
 #define _M68KNOMMU_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))
 
 #include <asm/setup.h>
Signature · 5 lines
------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     [email protected]
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com
author
#4 lore raw
Quoted 9 lines · Greg Ungerer

Now, back to the original patch. Now fails with another syntax error at the last line in this:

.init : {
. = ALIGN((1 << (12)));
__init_begin = .;
. = ALIGN((1 << (12))); .init.text : AT(ADDR(.init.text) - 0) { _sinittext =
.; *(.init.text) *(.devinit.text) *(.cpuinit.text) *(.meminit.text) _einittext = .; }

Oops. The ".init : { }" wrapping the new macros there should have been removed.

The following patch should fix this issue (obviously, you'll want to squash it with the original patch, but I figure sending the diff will be easier to review).

-Tim Abbott

---
 arch/m68knommu/kernel/vmlinux.lds.S |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)
arch/m68knommu/kernel/vmlinux.lds.S +6 -8
index 979acb5..c380040 100644
@@ -154,14 +154,12 @@ SECTIONS {
 		_edata = . ;
 	} > DATA
 
-	.init : {
-		. = ALIGN(PAGE_SIZE);
-		__init_begin = .;
-		INIT_TEXT_SECTION(PAGE_SIZE)
-		INIT_DATA_SECTION(16)
-		. = ALIGN(PAGE_SIZE);
-		__init_end = .;
-	} > INIT
+	. = ALIGN(PAGE_SIZE);
+	__init_begin = .;
+	INIT_TEXT_SECTION(PAGE_SIZE) > INIT
+	INIT_DATA_SECTION(16) > INIT
+	. = ALIGN(PAGE_SIZE);
+	__init_end = .;
 
 	/DISCARD/ : {
 		EXIT_TEXT
Signature · 1 line
1.6.3.3
#5 lore raw

Hi Tim,

Quoted 12 lines · Tim Abbott
Quoted 9 lines · Greg Ungerer

Now, back to the original patch. Now fails with another syntax error at the last line in this:

.init : {
. = ALIGN((1 << (12)));
__init_begin = .;
. = ALIGN((1 << (12))); .init.text : AT(ADDR(.init.text) - 0) { _sinittext =
.; *(.init.text) *(.devinit.text) *(.cpuinit.text) *(.meminit.text) _einittext = .; }

Quoted 3 lines

Oops. The ".init : { }" wrapping the new macros there should have been removed.

The following patch should fix this issue (obviously, you'll want to squash it with the original patch, but I figure sending the diff will be easier to review).

Ok, yes, that fixes that problem. I had to also make THREAD_SIZE available to the linker with:

arch/m68k/include/asm/thread_info_no.h +2 -2
index c2bde5e..a6512bf 100644
@@ -12,8 +12,6 @@
 
 #ifdef __KERNEL__
 
-#ifndef __ASSEMBLY__
-
 /*
  * Size of kernel stack for each process. This must be a power of 2...
  */
@@ -28,6 +26,8 @@
  */
 #define THREAD_SIZE (PAGE_SIZE<<THREAD_SIZE_ORDER)
 
+#ifndef __ASSEMBLY__
+
 /*
  * low level task data.
  */

But now the bss section doesn't looked properly aligned (at least it is not on a page boundary any longer after the init.data):

Sections:

Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00124ab8  40020000  40020000  00002000  2**4

CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00011540 40144ac0 40144ac0 00126ac0 2**4
CONTENTS, ALLOC, LOAD, DATA
2 .init.text 0000a96c 40156000 40156000 00138000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
3 .init.data 00000b7c 4016096c 4016096c 0014296c 2**2
CONTENTS, ALLOC, LOAD, DATA
4 .bss 0000a9e8 401614f0 401614f0 001434e8 2**4
ALLOC
5 .comment 00001c8c 00000000 00000000 001434e8 2**0
CONTENTS, READONLY

Seems kind of odd because:

40156000 A __init_begin
40162000 A __init_end
401614f0 B _sbss

The resulting kernels don't boot.

Regards
Greg

Quoted 30 lines
---
 arch/m68knommu/kernel/vmlinux.lds.S |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)
arch/m68knommu/kernel/vmlinux.lds.S +6 -8
index 979acb5..c380040 100644
@@ -154,14 +154,12 @@ SECTIONS {
 		_edata = . ;
 	} > DATA
 
-	.init : {
-		. = ALIGN(PAGE_SIZE);
-		__init_begin = .;
-		INIT_TEXT_SECTION(PAGE_SIZE)
-		INIT_DATA_SECTION(16)
-		. = ALIGN(PAGE_SIZE);
-		__init_end = .;
-	} > INIT
+	. = ALIGN(PAGE_SIZE);
+	__init_begin = .;
+	INIT_TEXT_SECTION(PAGE_SIZE) > INIT
+	INIT_DATA_SECTION(16) > INIT
+	. = ALIGN(PAGE_SIZE);
+	__init_end = .;
 
 	/DISCARD/ : {
 		EXIT_TEXT
Signature · 5 lines
------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     [email protected]
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com
author
#6 lore raw
Quoted 18 lines · Greg Ungerer

But now the bss section doesn't looked properly aligned (at least it is not on a page boundary any longer after the init.data):

Sections:

Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00124ab8  40020000  40020000  00002000  2**4

CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00011540 40144ac0 40144ac0 00126ac0 2**4
CONTENTS, ALLOC, LOAD, DATA
2 .init.text 0000a96c 40156000 40156000 00138000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
3 .init.data 00000b7c 4016096c 4016096c 0014296c 2**2
CONTENTS, ALLOC, LOAD, DATA
4 .bss 0000a9e8 401614f0 401614f0 001434e8 2**4
ALLOC
5 .comment 00001c8c 00000000 00000000 001434e8 2**0
CONTENTS, READONLY

Quoted 5 lines

Seems kind of odd because:

40156000 A __init_begin
40162000 A __init_end
401614f0 B _sbss

Yes, that is quite odd.

Quoted 1 line

The resulting kernels don't boot.

Right, presumably a big chunk of the .sbss code is being freed since _sbss is before __init_end.

I'm guessing the issue here is that the __init_begin and __init_end markers are now not actually in a section (and thus don't have a memory region marker attached). Does the following patch cause _sbss to not overlap the init region?

-Tim Abbott

arch/m68knommu/kernel/vmlinux.lds.S +8 -4
index c380040..81b54cb 100644
@@ -154,12 +154,16 @@ SECTIONS {
 		_edata = . ;
 	} > DATA
 
-	. = ALIGN(PAGE_SIZE);
-	__init_begin = .;
+	.init_begin : {
+		. = ALIGN(PAGE_SIZE);
+		__init_begin = .;
+	} > INIT
 	INIT_TEXT_SECTION(PAGE_SIZE) > INIT
 	INIT_DATA_SECTION(16) > INIT
-	. = ALIGN(PAGE_SIZE);
-	__init_end = .;
+	.init_end : {
+		. = ALIGN(PAGE_SIZE);
+		__init_end = .;
+	} > INIT
 
 	/DISCARD/ : {
 		EXIT_TEXT