+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
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
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
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
# 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) }'
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
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.
. ${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
ENTRY=_start
unset EMBEDDED
-unset OTHER_SECTIONS
+unset STACK_ADDR
. ${srcdir}/emulparams/shelf.sh
# We do not want a .stack section
-OTHER_SECTIONS=""
+unset STACK_ADDR
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
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})"
${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
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
-
- ${TINY_DATA_SECTION}
- ${TINY_BSS_SECTION}
-
- ${STACK_ADDR+${STACK}}
${ATTRS_SECTIONS}
${OTHER_SECTIONS}
${RELOCATING+${OTHER_SYMBOLS}}
${RELOCATING+_end = .;}
${RELOCATING+PROVIDE (end = .);}
${RELOCATING+${DATA_SEGMENT_END}}
+ ${STACK_ADDR+${STACK}}
/* These sections are not mapped under the BPABI. */
.dynamic 0 : { *(.dynamic) }
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
- ${STACK_ADDR+${STACK}}
${OTHER_SECTIONS}
${RELOCATING+${OTHER_SYMBOLS}}
${RELOCATING+${DISCARDED}}
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})"
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}}}
${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
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
-
- ${TINY_DATA_SECTION}
- ${TINY_BSS_SECTION}
-
- ${STACK_ADDR+${STACK}}
${ATTRS_SECTIONS}
${OTHER_SECTIONS}
${RELOCATING+${OTHER_SYMBOLS}}
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})"
${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
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
- ${TINY_DATA_SECTION}
- ${TINY_BSS_SECTION}
-
- ${STACK_ADDR+${STACK}}
${ATTRS_SECTIONS}
${OTHER_SECTIONS}
${RELOCATING+${OTHER_SYMBOLS}}
${RELOCATING+${OTHER_END_SYMBOLS}}
${RELOCATING+_end = .;}
${RELOCATING+PROVIDE (end = .);}
+ ${STACK_ADDR+${STACK}}
/* Stabs debugging sections. */
. = ALIGN(0x1000);
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
- ${STACK_ADDR+${STACK}}
${ATTRS_SECTIONS}
${OTHER_SECTIONS}
${RELOCATING+${OTHER_SYMBOLS}}
/* ARC Extension Sections */
.arcextmap 0 : { *(.gnu.linkonce.arcextmap.*) }
- ${STACK_ADDR+${STACK}}
${OTHER_SECTIONS}
${RELOCATING+${OTHER_END_SYMBOLS}}
${RELOCATING+${STACKNOTE}}
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.
${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
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
- ${TINY_DATA_SECTION}
- ${TINY_BSS_SECTION}
-
- ${STACK_ADDR+${STACK}}
${ATTRS_SECTIONS}
${OTHER_SECTIONS}
${RELOCATING+${OTHER_SYMBOLS}}
# 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.
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
${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
. $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}}
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})"
${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
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
-
- ${TINY_DATA_SECTION}
- ${TINY_BSS_SECTION}
-
- ${STACK_ADDR+${STACK}}
${ATTRS_SECTIONS}
${OTHER_SECTIONS}
${RELOCATING+${OTHER_SYMBOLS}}