Move .stack before debug sections
authorAlan Modra <amodra@gmail.com>
Mon, 20 Feb 2017 02:55:13 +0000 (13:25 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 20 Feb 2017 09:03:28 +0000 (19:33 +1030)
PR 20199
* emulparams/elf32m32c.sh: Define STACK_ADDR and STACK_SENTINEL
rather than using OTHER_SECTIONS.
* emulparams/elf32mt.sh: Likewise.
* emulparams/elf32rx.sh: Likewise.
* emulparams/elf32rl78.sh: Likewise.  Use OTHER_SYMBOLS to
define __rl78_abs__.
* emulparams/shelf.sh: Define STACK_ADDR and STACK_SENTINEL
rather than using OTHER_SECTIONS.
* emulparams/shelf32.sh: Likewise.  Use OTHER_SECTIONS for .cranges.
* emulparams/shelf64.sh: Unset OTHER_SECTIONS.
* emulparams/shelf_nbsd.sh: Unset STACK_ADDR not OTHER_SECTIONS.
* emulparams/shelf_uclinux.sh: Likewise.
* emulparams/shlsymbian.sh: Unset STACK_ADDR.  Use OTHER_SYMBOLS
to define _stack, not OTHER_SECTIONS.
* scripttempl/elf.sc: Move STACK, TINY_DATA_SECTION, and
TINY_BSS_SECTION before debug sections.  Add STACK_SENTINEL.
* scripttempl/arclinux.sc: Likewise.
* scripttempl/elf64hppa.sc: Likewise.
* scripttempl/elfxtensa.sc: Likewise.
* scripttempl/nds32elf.sc: Likewise.
* scripttempl/armbpabi.sc: Move STACK before debug sections.
* scripttempl/elf_chaos.sc: Likewise.
* scripttempl/elfarc.sc: Delete STACK.
* scripttempl/epiphany_4x4.sc: Delete STACK.  Move TINY_DATA_SECTION,
TINY_BSS_SECTION, and .stack before debug sections.

20 files changed:
ld/ChangeLog
ld/emulparams/elf32m32c.sh
ld/emulparams/elf32mt.sh
ld/emulparams/elf32rl78.sh
ld/emulparams/elf32rx.sh
ld/emulparams/shelf.sh
ld/emulparams/shelf32.sh
ld/emulparams/shelf64.sh
ld/emulparams/shelf_nbsd.sh
ld/emulparams/shelf_uclinux.sh
ld/emulparams/shlsymbian.sh
ld/scripttempl/arclinux.sc
ld/scripttempl/armbpabi.sc
ld/scripttempl/elf.sc
ld/scripttempl/elf64hppa.sc
ld/scripttempl/elf_chaos.sc
ld/scripttempl/elfarc.sc
ld/scripttempl/elfxtensa.sc
ld/scripttempl/epiphany_4x4.sc
ld/scripttempl/nds32elf.sc

index ce8cdb3..d02d009 100644 (file)
@@ -1,3 +1,32 @@
+2017-02-17  Alan Modra  <amodra@gmail.com>
+
+       PR 20199
+       * emulparams/elf32m32c.sh: Define STACK_ADDR and STACK_SENTINEL
+       rather than using OTHER_SECTIONS.
+       * emulparams/elf32mt.sh: Likewise.
+       * emulparams/elf32rx.sh: Likewise.
+       * emulparams/elf32rl78.sh: Likewise.  Use OTHER_SYMBOLS to
+       define __rl78_abs__.
+       * emulparams/shelf.sh: Define STACK_ADDR and STACK_SENTINEL
+       rather than using OTHER_SECTIONS.
+       * emulparams/shelf32.sh: Likewise.  Use OTHER_SECTIONS for .cranges.
+       * emulparams/shelf64.sh: Unset OTHER_SECTIONS.
+       * emulparams/shelf_nbsd.sh: Unset STACK_ADDR not OTHER_SECTIONS.
+       * emulparams/shelf_uclinux.sh: Likewise.
+       * emulparams/shlsymbian.sh: Unset STACK_ADDR.  Use OTHER_SYMBOLS
+       to define _stack, not OTHER_SECTIONS.
+       * scripttempl/elf.sc: Move STACK, TINY_DATA_SECTION, and
+       TINY_BSS_SECTION before debug sections.  Add STACK_SENTINEL.
+       * scripttempl/arclinux.sc: Likewise.
+       * scripttempl/elf64hppa.sc: Likewise.
+       * scripttempl/elfxtensa.sc: Likewise.
+       * scripttempl/nds32elf.sc: Likewise.
+       * scripttempl/armbpabi.sc: Move STACK before debug sections.
+       * scripttempl/elf_chaos.sc: Likewise.
+       * scripttempl/elfarc.sc: Delete STACK.
+       * scripttempl/epiphany_4x4.sc: Delete STACK.  Move TINY_DATA_SECTION,
+       TINY_BSS_SECTION, and .stack before debug sections.
+
 2017-02-17  Nick Clifton  <nickc@redhat.com>
 
        PR ld/20825
index eaf2c4e..cd2b700 100644 (file)
@@ -10,17 +10,8 @@ TEMPLATE_NAME=elf32
 EXTRA_EM_FILE=needrelax
 ELFSIZE=32
 MAXPAGESIZE=256
-# This is like setting STACK_ADDR to 0x0073FFFF0, except that the setting can
-# be overridden, e.g. --defsym _stack=0x0f00, and that we put an extra
-# sentinal value at the bottom.
-# N.B. We can't use PROVIDE to set the default value in a symbol because
-# the address is needed to place the .stack section, which in turn is needed
-# to hold the sentinel value(s).
-test -z "$CREATE_SHLIB" && OTHER_SECTIONS="  .stack        ${RELOCATING-0}${RELOCATING+(DEFINED(__stack) ? __stack : 0x7fc)} :
-  {
-    ${RELOCATING+__stack = .;}
-    *(.stack)
-    LONG(0xdeaddead)
-  }"
+
+STACK_ADDR="(DEFINED(__stack) ? __stack : 0x7fc)"
+STACK_SENTINEL="LONG(0xdeaddead)"
 # We do not need .stack for shared library.
-test -n "$CREATE_SHLIB" && OTHER_SECTIONS=""
+test -n "$CREATE_SHLIB" && unset STACK_ADDR
index 04fc1ed..6880db8 100644 (file)
@@ -10,17 +10,8 @@ ENTRY=_start
 EMBEDDED=yes
 ELFSIZE=32
 MAXPAGESIZE=256
-# This is like setting STACK_ADDR to 0x0073FFFF0, except that the setting can
-# be overridden, e.g. --defsym _stack=0x0f00, and that we put an extra
-# sentinal value at the bottom.
-# N.B. We can't use PROVIDE to set the default value in a symbol because
-# the address is needed to place the .stack section, which in turn is needed
-# to hold the sentinel value(s).
-test -z "$CREATE_SHLIB" && OTHER_SECTIONS="  .stack        ${RELOCATING-0}${RELOCATING+(DEFINED(__stack) ? __stack : 0x007FFFF0)} :
-  {
-    ${RELOCATING+__stack = .;}
-    *(.stack)
-    LONG(0xdeaddead)
-  }"
+
+STACK_ADDR="(DEFINED(__stack) ? __stack : 0x007FFFF0)"
+STACK_SENTINEL="LONG(0xdeaddead)"
 # We do not need .stack for shared library.
-test -n "$CREATE_SHLIB" && OTHER_SECTIONS=""
+test -n "$CREATE_SHLIB" && unset STACK_ADDR
index 7073efb..b782d03 100644 (file)
@@ -10,18 +10,11 @@ TEMPLATE_NAME=elf32
 ELFSIZE=32
 # EXTRA_EM_FILE=needrelax
 MAXPAGESIZE=256
-# This is like setting STACK_ADDR to 0xffedc, except that the setting can
-# be overridden, e.g. --defsym _stack=0x0f00, and that we put an extra
-# sentinal value at the bottom.
-# N.B. We can't use PROVIDE to set the default value in a symbol because
-# the address is needed to place the .stack section, which in turn is needed
-# to hold the sentinel value(s).
-test -z "$CREATE_SHLIB" && OTHER_SECTIONS="  .stack        ${RELOCATING-0}${RELOCATING+(DEFINED(__stack) ? __stack : 0xffedc)} :
-  {
-    ${RELOCATING+__stack = .;}
-    *(.stack)
-    LONG(0xdead)
-  }
-  ${RELOCATING+PROVIDE (__rl78_abs__ = 0);}"
+
+STACK_ADDR="(DEFINED(__stack) ? __stack : 0xffedc)"
+STACK_SENTINEL="LONG(0xdead)"
 # We do not need .stack for shared library.
-test -n "$CREATE_SHLIB" && OTHER_SECTIONS=""
+test -n "$CREATE_SHLIB" && unset STACK_ADDR
+
+OTHER_SYMBOLS="PROVIDE (__rl78_abs__ = 0);"
+test -n "$CREATE_SHLIB" && unset OTHER_SYMBOLS
index 2288667..e139be7 100644 (file)
@@ -11,20 +11,11 @@ EXTRA_EM_FILE=rxelf
 # EXTRA_EM_FILE=needrelax
 ELFSIZE=32
 MAXPAGESIZE=256
-# This is like setting STACK_ADDR to 0xbffffffc, except that the setting can
-# be overridden, e.g. --defsym _stack=0x0f00, and that we put an extra
-# sentinal value at the bottom.
-# N.B. We can't use PROVIDE to set the default value in a symbol because
-# the address is needed to place the .stack section, which in turn is needed
-# to hold the sentinel value(s).
-test -z "$CREATE_SHLIB" && OTHER_SECTIONS="  .stack        ${RELOCATING-0}${RELOCATING+(DEFINED(__stack) ? __stack : 0xbffffffc)} :
-  {
-    ${RELOCATING+__stack = .;}
-    *(.stack)
-    LONG(0xdeaddead)
-  }"
+
+STACK_ADDR="(DEFINED(__stack) ? __stack : 0xbffffffc)"
+STACK_SENTINEL="LONG(0xdeaddead)"
 # We do not need .stack for shared library.
-test -n "$CREATE_SHLIB" && OTHER_SECTIONS=""
+test -n "$CREATE_SHLIB" && unset STACK_ADDR
 
 OTHER_TEXT_SECTIONS='*(P)'
 OTHER_READONLY_SECTIONS='C_1 : { *(C_1) } C_2 : { *(C_2) } C : { *(C) } W_1 : { *(W_1) } W_2 : { *(W_2) } W : { *(W) }'
index d3f4752..8d79b8d 100644 (file)
@@ -21,17 +21,7 @@ CTOR_START='___ctors = .;'
 CTOR_END='___ctors_end = .;'
 DTOR_START='___dtors = .;'
 DTOR_END='___dtors_end = .;'
-# This is like setting STACK_ADDR to 0x3FFFFF00, except that the setting can
-# be overridden, e.g. --defsym _stack=0x0f00, and that we put an extra
-# sentinal value at the bottom.
-# N.B. We can't use PROVIDE to set the default value in a symbol because
-# the address is needed to place the .stack section, which in turn is needed
-# to hold the sentinel value(s).
-test -z "$CREATE_SHLIB" && OTHER_SECTIONS="  .stack        ${RELOCATING-0}${RELOCATING+(DEFINED(_stack) ? _stack : 0x3FFFFF00)} :
-  {
-    ${RELOCATING+_stack = .;}
-    *(.stack)
-    LONG(0xdeaddead)
-  }"
+STACK_ADDR="(DEFINED(_stack) ? _stack : 0x3FFFFF00)"
+STACK_SENTINEL="LONG(0xdeaddead)"
 # We do not need .stack for shared library.
-test -n "$CREATE_SHLIB" && OTHER_SECTIONS=""
+test -n "$CREATE_SHLIB" && unset STACK_ADDR
index bf362c5..7f46407 100644 (file)
@@ -34,28 +34,12 @@ CTOR_END='___ctors_end = .;'
 DTOR_START='___dtors = .;'
 DTOR_END='___dtors_end = .;'
 
-# Do not use the varname=${varname-'string'} construct here; there are
-# problems with that on some shells (e.g. on Solaris) where there is a bug
-# that trigs when $varname contains a "}".
-# The effect of the .stack definition is like setting STACK_ADDR to 0x80000,
-# except that the setting can be overridden, e.g. --defsym _stack=0xff000,
-# and that we put an extra sentinal value at the bottom.
-# N.B. We can't use PROVIDE to set the default value in a symbol because
-# the address is needed to place the .stack section, which in turn is needed
-# to hold the sentinel value(s).
-test -z "$CREATE_SHLIB" && OTHER_SECTIONS="
-  .stack ${RELOCATING-0}${RELOCATING+(DEFINED(_stack) ? _stack : ALIGN (0x40000) + 0x80000)} :
-  {
-    ${RELOCATING+_stack = .;}
-    *(.stack)
-    LONG(0xdeaddead)
-  }
-  .cranges 0 : { *(.cranges) }
-"
+STACK_ADDR="(DEFINED(_stack) ? _stack : ALIGN (0x40000) + 0x80000)"
+STACK_SENTINEL="LONG(0xdeaddead)"
 # We do not need .stack for shared library.
-test -n "$CREATE_SHLIB" && OTHER_SECTIONS="
-  .cranges 0 : { *(.cranges) }
-"
+test -n "$CREATE_SHLIB" && unset STACK_ADDR
+
+OTHER_SECTIONS=".cranges 0 : { *(.cranges) }"
 
 # We need to adjust sizes in the .cranges section after relaxation, so
 # we need an after_allocation function, and it goes in this file.
index 5037f35..5ddcc8d 100644 (file)
@@ -6,13 +6,4 @@ EXTRA_EM_FILE=
 . ${srcdir}/emulparams/shelf32.sh
 
 # We do not need .cranges
-test -z "$CREATE_SHLIB" && OTHER_SECTIONS="
- .stack ${RELOCATING-0}${RELOCATING+(DEFINED(_stack) ? _stack : ALIGN (0x40000) + 0x80000)} :
-  {
-    ${RELOCATING+_stack = .;}
-    *(.stack)
-    LONG(0xdeaddead)
-  }
-"
-# We do not need .stack for shared library.
-test -n "$CREATE_SHLIB" && OTHER_SECTIONS=""
+unset OTHER_SECTIONS
index 9d331c6..b27993d 100644 (file)
@@ -12,4 +12,4 @@ DATA_START_SYMBOLS='PROVIDE (__data_start = .);';
 ENTRY=_start
 
 unset EMBEDDED
-unset OTHER_SECTIONS
+unset STACK_ADDR
index 2af5da4..dac390e 100644 (file)
@@ -1,4 +1,4 @@
 . ${srcdir}/emulparams/shelf.sh
 
 # We do not want a .stack section
-OTHER_SECTIONS=""
+unset STACK_ADDR
index 9c6dfba..f729bb5 100644 (file)
@@ -11,7 +11,9 @@ DTOR_START='__dtors = .;'
 DTOR_END='__dtors_end = .;'
 
 # Suppress the .stack section.
-test -z "$CREATE_SHLIB" && OTHER_SECTIONS="${RELOCATING+PROVIDE (_stack = 0x30000);}"
+unset STACK_ADDR
+OTHER_SYMBOLS="PROVIDE (_stack = 0x30000);"
+test -n "$CREATE_SHLIB" && unset OTHER_SYMBOLS
 
 OUTPUT_FORMAT="elf32-shl-symbian"
 SCRIPT_NAME=elf32sh-symbian
index f3668d2..e692f13 100644 (file)
@@ -303,10 +303,11 @@ DTOR=".dtors        ${CONSTRUCTING-0} :
     KEEP (*(.dtors))
     ${CONSTRUCTING+${DTOR_END}}
   }"
-STACK="  .stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
+STACK=".stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
   {
     ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
     *(.stack)
+    ${RELOCATING+${STACK_SENTINEL}}
   }"
 
 TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
@@ -649,6 +650,9 @@ SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_A
   ${RELOCATING+${OTHER_END_SYMBOLS}}
   ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
   ${RELOCATING+${DATA_SEGMENT_END}}
+  ${TINY_DATA_SECTION}
+  ${TINY_BSS_SECTION}
+  ${STACK_ADDR+${STACK}}
 EOF
 
 test -z "${NON_ALLOC_DYN}" || emit_dyn
@@ -669,11 +673,6 @@ EOF
 . $srcdir/scripttempl/DWARF.sc
 
 cat <<EOF
-
-  ${TINY_DATA_SECTION}
-  ${TINY_BSS_SECTION}
-
-  ${STACK_ADDR+${STACK}}
   ${ATTRS_SECTIONS}
   ${OTHER_SECTIONS}
   ${RELOCATING+${OTHER_SYMBOLS}}
index 0657aa9..dee1028 100644 (file)
@@ -317,6 +317,7 @@ cat <<EOF
   ${RELOCATING+_end = .;}
   ${RELOCATING+PROVIDE (end = .);}
   ${RELOCATING+${DATA_SEGMENT_END}}
+  ${STACK_ADDR+${STACK}}
 
   /* These sections are not mapped under the BPABI.  */
   .dynamic      0 : { *(.dynamic) }
@@ -342,7 +343,6 @@ EOF
 . $srcdir/scripttempl/DWARF.sc
 
 cat <<EOF
-  ${STACK_ADDR+${STACK}}
   ${OTHER_SECTIONS}
   ${RELOCATING+${OTHER_SYMBOLS}}
   ${RELOCATING+${DISCARDED}}
index e65f9a3..d9138bc 100644 (file)
@@ -305,10 +305,11 @@ DTOR=".dtors        ${CONSTRUCTING-0} :
     KEEP (*(.dtors))
     ${CONSTRUCTING+${DTOR_END}}
   }"
-STACK="  .stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
+STACK=".stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
   {
     ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
     *(.stack)
+    ${RELOCATING+${STACK_SENTINEL}}
   }"
 
 TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
@@ -641,7 +642,7 @@ EOF
 LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${LARGE_DATA_ADDR-.});"
 SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_ADDR-.});"
 
-  cat <<EOF
+cat <<EOF
   ${RELOCATING+${CREATE_SHLIB-${CREATE_PIE-${LARGE_DATA_ADDR}}}}
   ${RELOCATING+${CREATE_SHLIB+${SHLIB_LARGE_DATA_ADDR}}}
   ${RELOCATING+${CREATE_PIE+${SHLIB_LARGE_DATA_ADDR}}}
@@ -651,6 +652,9 @@ SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_A
   ${RELOCATING+${OTHER_END_SYMBOLS}}
   ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
   ${RELOCATING+${DATA_SEGMENT_END}}
+  ${TINY_DATA_SECTION}
+  ${TINY_BSS_SECTION}
+  ${STACK_ADDR+${STACK}}
 EOF
 
 test -z "${NON_ALLOC_DYN}" || emit_dyn
@@ -671,11 +675,6 @@ EOF
 . $srcdir/scripttempl/DWARF.sc
 
 cat <<EOF
-
-  ${TINY_DATA_SECTION}
-  ${TINY_BSS_SECTION}
-
-  ${STACK_ADDR+${STACK}}
   ${ATTRS_SECTIONS}
   ${OTHER_SECTIONS}
   ${RELOCATING+${OTHER_SYMBOLS}}
index b741f88..dec42b5 100644 (file)
@@ -255,10 +255,11 @@ DTOR=".dtors        ${CONSTRUCTING-0} :
     KEEP (*(.dtors))
     ${CONSTRUCTING+${DTOR_END}}
   }"
-STACK="  .stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
+STACK=".stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
   {
-    ${RELOCATING+_stack = .;}
+    ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
     *(.stack)
+    ${RELOCATING+${STACK_SENTINEL}}
   }"
 
 TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
@@ -513,6 +514,9 @@ cat <<EOF
   ${RELOCATING+${OTHER_END_SYMBOLS}}
   ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
   ${RELOCATING+${DATA_SEGMENT_END}}
+  ${TINY_DATA_SECTION}
+  ${TINY_BSS_SECTION}
+  ${STACK_ADDR+${STACK}}
 EOF
 
 if test -n "${NON_ALLOC_DYN}"; then
@@ -545,10 +549,6 @@ EOF
 . $srcdir/scripttempl/DWARF.sc
 
 cat <<EOF
-  ${TINY_DATA_SECTION}
-  ${TINY_BSS_SECTION}
-
-  ${STACK_ADDR+${STACK}}
   ${ATTRS_SECTIONS}
   ${OTHER_SECTIONS}
   ${RELOCATING+${OTHER_SYMBOLS}}
index b6d5956..8fe15b4 100644 (file)
@@ -317,6 +317,7 @@ cat <<EOF
   ${RELOCATING+${OTHER_END_SYMBOLS}}
   ${RELOCATING+_end = .;}
   ${RELOCATING+PROVIDE (end = .);}
+  ${STACK_ADDR+${STACK}}
 
   /* Stabs debugging sections.  */
   . = ALIGN(0x1000);
@@ -335,7 +336,6 @@ EOF
 . $srcdir/scripttempl/DWARF.sc
 
 cat <<EOF
-  ${STACK_ADDR+${STACK}}
   ${ATTRS_SECTIONS}
   ${OTHER_SECTIONS}
   ${RELOCATING+${OTHER_SYMBOLS}}
index 9d1e139..6754c02 100644 (file)
@@ -433,7 +433,6 @@ cat <<EOF
   /* ARC Extension Sections */
   .arcextmap     0 : { *(.gnu.linkonce.arcextmap.*) }
 
-  ${STACK_ADDR+${STACK}}
   ${OTHER_SECTIONS}
   ${RELOCATING+${OTHER_END_SYMBOLS}}
   ${RELOCATING+${STACKNOTE}}
index 6eb9d33..769168e 100644 (file)
@@ -272,10 +272,11 @@ DTOR=".dtors        ${CONSTRUCTING-0} :
     KEEP (*(.dtors))
     ${CONSTRUCTING+${DTOR_END}}
   }"
-STACK="  .stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
+STACK=".stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
   {
-    ${RELOCATING+_stack = .;}
+    ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
     *(.stack)
+    ${RELOCATING+${STACK_SENTINEL}}
   }"
 
 # If this is for an embedded system, don't add SIZEOF_HEADERS.
@@ -523,6 +524,9 @@ cat <<EOF
   ${RELOCATING+${OTHER_END_SYMBOLS}}
   ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
   ${RELOCATING+${DATA_SEGMENT_END}}
+  ${TINY_DATA_SECTION}
+  ${TINY_BSS_SECTION}
+  ${STACK_ADDR+${STACK}}
 EOF
 
 if test -n "${NON_ALLOC_DYN}"; then
@@ -555,10 +559,6 @@ EOF
 . $srcdir/scripttempl/DWARF.sc
 
 cat <<EOF
-  ${TINY_DATA_SECTION}
-  ${TINY_BSS_SECTION}
-
-  ${STACK_ADDR+${STACK}}
   ${ATTRS_SECTIONS}
   ${OTHER_SECTIONS}
   ${RELOCATING+${OTHER_SYMBOLS}}
index 10d3d23..b661fc2 100644 (file)
@@ -54,7 +54,6 @@
 #      combination of .init sections.
 #      FINI_START, FINI_END - statements just before and just after
 #      combination of .fini sections.
-#      STACK_ADDR - start of a .stack section.
 #      OTHER_SYMBOLS - symbols to place right at the end of the script.
 #      ETEXT_NAME - name of a symbol for the end of the text section,
 #              normally etext.
@@ -242,11 +241,6 @@ DTOR=".dtors     ADDR(.ctors) + SIZEOF(.ctors)    ${CONSTRUCTING-0} :
     KEEP (*(.dtors))
     ${CONSTRUCTING+${DTOR_END}}
   }   /*> INTERNAL_RAM*/ "
-STACK="  .stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
-  {
-    ${RELOCATING+___stack = .;}
-    *(.stack)
-  }"
 
 # If this is for an embedded system, don't add SIZEOF_HEADERS.
 if [ -z "$EMBEDDED" ]; then
@@ -608,6 +602,12 @@ cat <<EOF
   ${RELOCATING+${OTHER_END_SYMBOLS}}
   ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
   ${RELOCATING+${DATA_SEGMENT_END}}
+
+  PROVIDE ( __stack_start_ = ORIGIN(EXTERNAL_DRAM_0) + __PROG_SIZE_FOR_CORE__ * __CORE_NUM_ + __PROG_SIZE_FOR_CORE__  - 0x10) ;
+  .stack ${RELOCATING+__stack_start_} :  {    ${RELOCATING+___stack = .;}    *(.stack)  }
+
+  PROVIDE (  ___heap_start = ORIGIN(EXTERNAL_DRAM_1)  + __HEAP_SIZE_FOR_CORE__ * __CORE_NUM_ );
+  PROVIDE (  ___heap_end =   ORIGIN(EXTERNAL_DRAM_1)  + __HEAP_SIZE_FOR_CORE__ * __CORE_NUM_  + __HEAP_SIZE_FOR_CORE__ - 4 );
 EOF
 
 if test -n "${NON_ALLOC_DYN}"; then
@@ -640,23 +640,6 @@ EOF
 . $srcdir/scripttempl/DWARF.sc
 
 cat <<EOF
-  ${TINY_DATA_SECTION}
-  ${TINY_BSS_SECTION}
-
-  /*${STACK_ADDR+${STACK}}*/
-  
-  PROVIDE ( __stack_start_ = ORIGIN(EXTERNAL_DRAM_0) + __PROG_SIZE_FOR_CORE__ * __CORE_NUM_ + __PROG_SIZE_FOR_CORE__  - 0x10) ;
-  .stack ${RELOCATING+__stack_start_} :  {    ___stack = .;    *(.stack)  }
-
-  PROVIDE (  ___heap_start = ORIGIN(EXTERNAL_DRAM_1)  + __HEAP_SIZE_FOR_CORE__ * __CORE_NUM_ );
-  /*.heap_start      __heap_start_    :  {    _heap_start_ = .;    *(.heap_start)  }*/
-
-  PROVIDE (  ___heap_end =   ORIGIN(EXTERNAL_DRAM_1)  + __HEAP_SIZE_FOR_CORE__ * __CORE_NUM_  + __HEAP_SIZE_FOR_CORE__ - 4 );
-  
-  
- /* .heap_end      __heap_end_    :  {    _heap_end_ = .;    *(.heap_end)  }*/
-
-
   ${ATTRS_SECTIONS}
   ${OTHER_SECTIONS}
   ${RELOCATING+${OTHER_SYMBOLS}}
index de2b28b..db4bf57 100644 (file)
@@ -246,10 +246,11 @@ DTOR=".dtors        ${CONSTRUCTING-0} :
     KEEP (*(.dtors))
     ${CONSTRUCTING+${DTOR_END}}
   }"
-STACK="  .stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
+STACK=".stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
   {
     ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
     *(.stack)
+    ${RELOCATING+${STACK_SENTINEL}}
   }"
 
 TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
@@ -594,6 +595,9 @@ SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_A
   ${RELOCATING+${OTHER_END_SYMBOLS}}
   ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
   ${RELOCATING+${DATA_SEGMENT_END}}
+  ${TINY_DATA_SECTION}
+  ${TINY_BSS_SECTION}
+  ${STACK_ADDR+${STACK}}
 EOF
 
 test -z "${NON_ALLOC_DYN}" || emit_dyn
@@ -614,11 +618,6 @@ EOF
 . $srcdir/scripttempl/DWARF.sc
 
 cat <<EOF
-
-  ${TINY_DATA_SECTION}
-  ${TINY_BSS_SECTION}
-
-  ${STACK_ADDR+${STACK}}
   ${ATTRS_SECTIONS}
   ${OTHER_SECTIONS}
   ${RELOCATING+${OTHER_SYMBOLS}}