Rework the link script, based on the Blackfin's, to resolve section
overlap error.

The PAGE_SIZE and THREAD_SIZE defs in page.h are used instead of
numeric constant.

The code moving loop in head.S is removed, because a boot loader is
always used.

Note that the bss section is now before the data section. We want the
init sections to be freed without fragmentation.

Signed-off-by: Thomas Chou <[EMAIL PROTECTED]>
---
 linux-2.6.x/arch/nios2nommu/kernel/head.S        |   25 +--
 linux-2.6.x/arch/nios2nommu/kernel/vmlinux.lds.S |  251 +++++++++++-----------
 linux-2.6.x/include/asm-nios2nommu/page.h        |    2 +-
 3 files changed, 126 insertions(+), 152 deletions(-)

diff --git a/linux-2.6.x/arch/nios2nommu/kernel/head.S 
b/linux-2.6.x/arch/nios2nommu/kernel/head.S
index 2d63d28..b1ca973 100644
--- a/linux-2.6.x/arch/nios2nommu/kernel/head.S
+++ b/linux-2.6.x/arch/nios2nommu/kernel/head.S
@@ -107,30 +107,9 @@ data_flush:
        sub     r1,r1,r2
        bgt     r1,r0,data_flush
 
-NR_MoveStart:
 #ifdef CONFIG_BREAK_ON_START
        break
 #endif //CONFIG_BREAK_ON_START
-       nextpc  r1                      /* Find out where we are */
-chkadr:        
-       movia   r2,chkadr
-       beq     r1,r2,finish_move       /* We are running in RAM done */
-       addi    r1,r1,(_start - chkadr) /* Source */
-       movia   r2,_start               /* Destination */
-       movia   r3,__bss_start          /* End of copy */
-       
-loop_move:                             // r1: src, r2: dest, r3: last dest
-       ldw     r8,0(r1)                // load a word from [r1]
-       stw     r8,0(r2)                // stort a word to dest [r2]
-       flushd  0(r2)                   // Flush cache for safty
-       addi    r1,r1,4                 // inc the src addr
-       addi    r2,r2,4                 // inc the dest addr
-       blt     r2,r3,loop_move
-               
-       movia   r1,finish_move          // VMA(_start)->l1
-       jmp     r1                      // jmp to _start        
-
-finish_move:
 
 #if defined(CPU_EXCEPT_ADDRESS_ASM) && (CPU_EXCEPT_ADDRESS_ASM != 
(LINUX_SDRAM_START + 0x20))
 /*     Copy an instruction sequence to put at the exception address */ 
@@ -215,8 +194,8 @@ finish_move:
        //------------------------------------------------------
        // Zero out the .bss segment (uninitialized common data)
        //
-       movia   r2,__bss_start          // presume nothing is between
-       movia   r1,_end                 // the .bss and _end.
+       movia   r2,__bss_start          // zero out bss
+       movia   r1,__bss_stop
 1:
        stb     r0,0(r2)
        addi    r2,r2,1
diff --git a/linux-2.6.x/arch/nios2nommu/kernel/vmlinux.lds.S 
b/linux-2.6.x/arch/nios2nommu/kernel/vmlinux.lds.S
index 05b6b2b..8031978 100644
--- a/linux-2.6.x/arch/nios2nommu/kernel/vmlinux.lds.S
+++ b/linux-2.6.x/arch/nios2nommu/kernel/vmlinux.lds.S
@@ -1,5 +1,11 @@
+/*
+ * File:         arch/nios2nommu/kernel/vmlinux.lds.S
+ * Based on:     arch/blackfin/kernel/vmlinux.lds.S
+ */
+
 #include <asm-generic/vmlinux.lds.h>
 #include <asm/nios.h>
+#include <asm/page.h>
                
 OUTPUT_FORMAT("elf32-littlenios2", "elf32-littlenios2", "elf32-littlenios2")
 
@@ -10,132 +16,121 @@ jiffies = jiffies_64;
 
 SECTIONS
 {
-  . = nasys_program_mem;
-  /* read-only */
-  _stext = . ;
-  _text = .;                   /* Text and read-only data */
-  .text : {
-    TEXT_TEXT
-    SCHED_TEXT
-    LOCK_TEXT
-    *(.fixup)
-    *(.gnu.warning)
-  } =0
-
-  . = ALIGN(4) ;
-  _etext = .;                  /* End of text section */
-
-  . = ALIGN(32);               /* Exception table */
-  __start___ex_table = .;
-  __ex_table : { *(__ex_table) }
-  __stop___ex_table = .;
-
-  RODATA
-
-  /* writeable */
-  .data : {                    /* Data */
-    /*
-     * This ALIGN is needed as a workaround for a bug a gcc bug upto 4.1 which
-     * limits the maximum alignment to at most 32kB and results in the 
following
-     * warning:
-     *
-     *  CC      arch/mips/kernel/init_task.o
-     * arch/mips/kernel/init_task.c:30: warning: alignment of 
‘init_thread_union’
-     * is greater than maximum object file alignment.  Using 32768
-     */
-    . = ALIGN(8192);   /* MUST be 8192, the THREAD_SIZE */
-    *(.data.init_task)
-
-    *(.data)
-
-    CONSTRUCTORS
-  }
-
-  .lit8 : { *(.lit8) }
-  .lit4 : { *(.lit4) }
-  /* We want the small data sections together, so single-instruction offsets
-     can access them all, and initialized data all before uninitialized, so
-     we can shorten the on-disk segment size.  */
-  .sdata     : { *(.sdata) }
-
-  . = ALIGN(4096);
-  __nosave_begin = .;
-  .data_nosave : { *(.data.nosave) }
-  . = ALIGN(4096);
-  __nosave_end = .;
-
-  . = ALIGN(32);
-  .data.cacheline_aligned : { *(.data.cacheline_aligned) }
-
-  _edata =  .;                 /* End of data section */
-
-  /* will be freed after init */
-  . = ALIGN(4096);             /* 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
-    /* .exit.text is discarded at runtime, not link time, to deal with
-     references from .rodata */
-  .exit.text : { *(.exit.text) }
-  .exit.data : { *(.exit.data) }
-  . = ALIGN(4096);
-  __initramfs_start = .;
-  .init.ramfs : { *(.init.ramfs) }
-  __initramfs_end = .;
-  . = ALIGN(32);
-  __per_cpu_start = .;
-  .data.percpu  : { *(.data.percpu) }
-  __per_cpu_end = .;
-  . = ALIGN(4096);
-  __init_end = .;
-  /* freed after init ends here */
-
-  __bss_start = .;             /* BSS */
-  .sbss      : {
-    *(.sbss)
-    *(.scommon)
-  }
-  .bss : {
-    *(.bss)
-    *(COMMON)
-  }
-  __bss_stop = .;
-
-  _end = . ;
-
-  /* Sections to be discarded */
-  /DISCARD/ : {
-       *(.exit.text)
-       *(.exit.data)
-        *(.exitcall.exit)
-  }
-
-
-  STABS_DEBUG
-
-  DWARF_DEBUG
-
-  /* These must appear regardless of  .  */
-  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
-  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
-  .note : { *(.note) }
+       . = nasys_program_mem;
+       .text : 
+       {
+               _stext = . ;
+               _text = .;
+               TEXT_TEXT
+               SCHED_TEXT
+               LOCK_TEXT
+               KPROBES_TEXT
+               *(.fixup)
+
+               . = ALIGN(32);          /* Exception table */
+               __start___ex_table = .;
+               *(__ex_table)
+               __stop___ex_table = .;
+
+               _etext = .;
+       } =0
+
+       /* Just in case the first read only is a 32-bit access */
+       RO_DATA(4)
+
+       .bss :
+       {
+               . = ALIGN(4);
+               __bss_start = .;
+               *(.bss .bss.*)
+               *(COMMON)
+               *(.sbss)
+               *(.scommon)      
+               __bss_stop = .;
+       }
+
+       .data :
+       {
+               _sdata = .;
+               /* This gets done first, so the glob doesn't suck it in */
+               . = ALIGN(32);
+               *(.data.cacheline_aligned)
+
+               DATA_DATA
+               *(.data.*)
+               *(.sdata)
+               CONSTRUCTORS
+
+               /* make sure the init_task is aligned to the
+                * kernel thread size so we can locate the kernel
+                * stack properly and quickly.
+                */
+               . = ALIGN(THREAD_SIZE);
+               *(.init_task.data)
+
+               _edata = .;
+       }
+
+       /* The init section should be last, so when we free it, it goes into
+        * the general memory pool, and (hopefully) will decrease fragmentation
+        * a tiny bit. The init section has a _requirement_ that it be
+        * PAGE_SIZE aligned
+        */
+       . = ALIGN(PAGE_SIZE);
+       __init_begin = .;
+
+       .init.text :
+       {
+               . = ALIGN(PAGE_SIZE);
+               _sinittext = .;
+               INIT_TEXT
+               _einittext = .;
+       }
+       .init.data :
+       {
+               . = ALIGN(16);
+               INIT_DATA
+       }
+       .init.setup :
+       {
+               . = ALIGN(16);
+               __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.ramfs :
+       {
+               . = ALIGN(4);
+               __initramfs_start = .;
+               *(.init.ramfs)
+               __initramfs_end = .;
+       }
+       __init_end = .;
+       _end = . ;
+
+       STABS_DEBUG
+
+       DWARF_DEBUG
+
+       NOTES
+
+       /DISCARD/ :
+       {
+               EXIT_TEXT
+               EXIT_DATA
+               *(.exitcall.exit)
+       }
 }
diff --git a/linux-2.6.x/include/asm-nios2nommu/page.h 
b/linux-2.6.x/include/asm-nios2nommu/page.h
index d4ba728..b623bb9 100644
--- a/linux-2.6.x/include/asm-nios2nommu/page.h
+++ b/linux-2.6.x/include/asm-nios2nommu/page.h
@@ -28,7 +28,7 @@
 /* PAGE_SHIFT determines the page size */
 
 #define PAGE_SHIFT     (12)
-#define PAGE_SIZE      (1UL << PAGE_SHIFT)
+#define PAGE_SIZE      (4096)
 #define PAGE_MASK      (~(PAGE_SIZE-1))
 
 #ifdef __KERNEL__
-- 
1.5.3.3

_______________________________________________
uClinux-dev mailing list
[email protected]
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by [email protected]
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to