Skip to content

Commit 74dc903

Browse files
committedFeb 20, 2017
Move .stack before debug sections
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.
1 parent ece5dcc commit 74dc903

20 files changed

+98
-157
lines changed
 

‎ld/ChangeLog

+29
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
2017-02-17 Alan Modra <amodra@gmail.com>
2+
3+
PR 20199
4+
* emulparams/elf32m32c.sh: Define STACK_ADDR and STACK_SENTINEL
5+
rather than using OTHER_SECTIONS.
6+
* emulparams/elf32mt.sh: Likewise.
7+
* emulparams/elf32rx.sh: Likewise.
8+
* emulparams/elf32rl78.sh: Likewise. Use OTHER_SYMBOLS to
9+
define __rl78_abs__.
10+
* emulparams/shelf.sh: Define STACK_ADDR and STACK_SENTINEL
11+
rather than using OTHER_SECTIONS.
12+
* emulparams/shelf32.sh: Likewise. Use OTHER_SECTIONS for .cranges.
13+
* emulparams/shelf64.sh: Unset OTHER_SECTIONS.
14+
* emulparams/shelf_nbsd.sh: Unset STACK_ADDR not OTHER_SECTIONS.
15+
* emulparams/shelf_uclinux.sh: Likewise.
16+
* emulparams/shlsymbian.sh: Unset STACK_ADDR. Use OTHER_SYMBOLS
17+
to define _stack, not OTHER_SECTIONS.
18+
* scripttempl/elf.sc: Move STACK, TINY_DATA_SECTION, and
19+
TINY_BSS_SECTION before debug sections. Add STACK_SENTINEL.
20+
* scripttempl/arclinux.sc: Likewise.
21+
* scripttempl/elf64hppa.sc: Likewise.
22+
* scripttempl/elfxtensa.sc: Likewise.
23+
* scripttempl/nds32elf.sc: Likewise.
24+
* scripttempl/armbpabi.sc: Move STACK before debug sections.
25+
* scripttempl/elf_chaos.sc: Likewise.
26+
* scripttempl/elfarc.sc: Delete STACK.
27+
* scripttempl/epiphany_4x4.sc: Delete STACK. Move TINY_DATA_SECTION,
28+
TINY_BSS_SECTION, and .stack before debug sections.
29+
130
2017-02-17 Nick Clifton <nickc@redhat.com>
231

332
PR ld/20825

‎ld/emulparams/elf32m32c.sh

+4-13
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,8 @@ TEMPLATE_NAME=elf32
1010
EXTRA_EM_FILE=needrelax
1111
ELFSIZE=32
1212
MAXPAGESIZE=256
13-
# This is like setting STACK_ADDR to 0x0073FFFF0, except that the setting can
14-
# be overridden, e.g. --defsym _stack=0x0f00, and that we put an extra
15-
# sentinal value at the bottom.
16-
# N.B. We can't use PROVIDE to set the default value in a symbol because
17-
# the address is needed to place the .stack section, which in turn is needed
18-
# to hold the sentinel value(s).
19-
test -z "$CREATE_SHLIB" && OTHER_SECTIONS=" .stack ${RELOCATING-0}${RELOCATING+(DEFINED(__stack) ? __stack : 0x7fc)} :
20-
{
21-
${RELOCATING+__stack = .;}
22-
*(.stack)
23-
LONG(0xdeaddead)
24-
}"
13+
14+
STACK_ADDR="(DEFINED(__stack) ? __stack : 0x7fc)"
15+
STACK_SENTINEL="LONG(0xdeaddead)"
2516
# We do not need .stack for shared library.
26-
test -n "$CREATE_SHLIB" && OTHER_SECTIONS=""
17+
test -n "$CREATE_SHLIB" && unset STACK_ADDR

‎ld/emulparams/elf32mt.sh

+4-13
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,8 @@ ENTRY=_start
1010
EMBEDDED=yes
1111
ELFSIZE=32
1212
MAXPAGESIZE=256
13-
# This is like setting STACK_ADDR to 0x0073FFFF0, except that the setting can
14-
# be overridden, e.g. --defsym _stack=0x0f00, and that we put an extra
15-
# sentinal value at the bottom.
16-
# N.B. We can't use PROVIDE to set the default value in a symbol because
17-
# the address is needed to place the .stack section, which in turn is needed
18-
# to hold the sentinel value(s).
19-
test -z "$CREATE_SHLIB" && OTHER_SECTIONS=" .stack ${RELOCATING-0}${RELOCATING+(DEFINED(__stack) ? __stack : 0x007FFFF0)} :
20-
{
21-
${RELOCATING+__stack = .;}
22-
*(.stack)
23-
LONG(0xdeaddead)
24-
}"
13+
14+
STACK_ADDR="(DEFINED(__stack) ? __stack : 0x007FFFF0)"
15+
STACK_SENTINEL="LONG(0xdeaddead)"
2516
# We do not need .stack for shared library.
26-
test -n "$CREATE_SHLIB" && OTHER_SECTIONS=""
17+
test -n "$CREATE_SHLIB" && unset STACK_ADDR

‎ld/emulparams/elf32rl78.sh

+7-14
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,11 @@ TEMPLATE_NAME=elf32
1010
ELFSIZE=32
1111
# EXTRA_EM_FILE=needrelax
1212
MAXPAGESIZE=256
13-
# This is like setting STACK_ADDR to 0xffedc, except that the setting can
14-
# be overridden, e.g. --defsym _stack=0x0f00, and that we put an extra
15-
# sentinal value at the bottom.
16-
# N.B. We can't use PROVIDE to set the default value in a symbol because
17-
# the address is needed to place the .stack section, which in turn is needed
18-
# to hold the sentinel value(s).
19-
test -z "$CREATE_SHLIB" && OTHER_SECTIONS=" .stack ${RELOCATING-0}${RELOCATING+(DEFINED(__stack) ? __stack : 0xffedc)} :
20-
{
21-
${RELOCATING+__stack = .;}
22-
*(.stack)
23-
LONG(0xdead)
24-
}
25-
${RELOCATING+PROVIDE (__rl78_abs__ = 0);}"
13+
14+
STACK_ADDR="(DEFINED(__stack) ? __stack : 0xffedc)"
15+
STACK_SENTINEL="LONG(0xdead)"
2616
# We do not need .stack for shared library.
27-
test -n "$CREATE_SHLIB" && OTHER_SECTIONS=""
17+
test -n "$CREATE_SHLIB" && unset STACK_ADDR
18+
19+
OTHER_SYMBOLS="PROVIDE (__rl78_abs__ = 0);"
20+
test -n "$CREATE_SHLIB" && unset OTHER_SYMBOLS

‎ld/emulparams/elf32rx.sh

+4-13
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,11 @@ EXTRA_EM_FILE=rxelf
1111
# EXTRA_EM_FILE=needrelax
1212
ELFSIZE=32
1313
MAXPAGESIZE=256
14-
# This is like setting STACK_ADDR to 0xbffffffc, except that the setting can
15-
# be overridden, e.g. --defsym _stack=0x0f00, and that we put an extra
16-
# sentinal value at the bottom.
17-
# N.B. We can't use PROVIDE to set the default value in a symbol because
18-
# the address is needed to place the .stack section, which in turn is needed
19-
# to hold the sentinel value(s).
20-
test -z "$CREATE_SHLIB" && OTHER_SECTIONS=" .stack ${RELOCATING-0}${RELOCATING+(DEFINED(__stack) ? __stack : 0xbffffffc)} :
21-
{
22-
${RELOCATING+__stack = .;}
23-
*(.stack)
24-
LONG(0xdeaddead)
25-
}"
14+
15+
STACK_ADDR="(DEFINED(__stack) ? __stack : 0xbffffffc)"
16+
STACK_SENTINEL="LONG(0xdeaddead)"
2617
# We do not need .stack for shared library.
27-
test -n "$CREATE_SHLIB" && OTHER_SECTIONS=""
18+
test -n "$CREATE_SHLIB" && unset STACK_ADDR
2819

2920
OTHER_TEXT_SECTIONS='*(P)'
3021
OTHER_READONLY_SECTIONS='C_1 : { *(C_1) } C_2 : { *(C_2) } C : { *(C) } W_1 : { *(W_1) } W_2 : { *(W_2) } W : { *(W) }'

‎ld/emulparams/shelf.sh

+3-13
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,7 @@ CTOR_START='___ctors = .;'
2121
CTOR_END='___ctors_end = .;'
2222
DTOR_START='___dtors = .;'
2323
DTOR_END='___dtors_end = .;'
24-
# This is like setting STACK_ADDR to 0x3FFFFF00, except that the setting can
25-
# be overridden, e.g. --defsym _stack=0x0f00, and that we put an extra
26-
# sentinal value at the bottom.
27-
# N.B. We can't use PROVIDE to set the default value in a symbol because
28-
# the address is needed to place the .stack section, which in turn is needed
29-
# to hold the sentinel value(s).
30-
test -z "$CREATE_SHLIB" && OTHER_SECTIONS=" .stack ${RELOCATING-0}${RELOCATING+(DEFINED(_stack) ? _stack : 0x3FFFFF00)} :
31-
{
32-
${RELOCATING+_stack = .;}
33-
*(.stack)
34-
LONG(0xdeaddead)
35-
}"
24+
STACK_ADDR="(DEFINED(_stack) ? _stack : 0x3FFFFF00)"
25+
STACK_SENTINEL="LONG(0xdeaddead)"
3626
# We do not need .stack for shared library.
37-
test -n "$CREATE_SHLIB" && OTHER_SECTIONS=""
27+
test -n "$CREATE_SHLIB" && unset STACK_ADDR

‎ld/emulparams/shelf32.sh

+5-21
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,12 @@ CTOR_END='___ctors_end = .;'
3434
DTOR_START='___dtors = .;'
3535
DTOR_END='___dtors_end = .;'
3636

37-
# Do not use the varname=${varname-'string'} construct here; there are
38-
# problems with that on some shells (e.g. on Solaris) where there is a bug
39-
# that trigs when $varname contains a "}".
40-
# The effect of the .stack definition is like setting STACK_ADDR to 0x80000,
41-
# except that the setting can be overridden, e.g. --defsym _stack=0xff000,
42-
# and that we put an extra sentinal value at the bottom.
43-
# N.B. We can't use PROVIDE to set the default value in a symbol because
44-
# the address is needed to place the .stack section, which in turn is needed
45-
# to hold the sentinel value(s).
46-
test -z "$CREATE_SHLIB" && OTHER_SECTIONS="
47-
.stack ${RELOCATING-0}${RELOCATING+(DEFINED(_stack) ? _stack : ALIGN (0x40000) + 0x80000)} :
48-
{
49-
${RELOCATING+_stack = .;}
50-
*(.stack)
51-
LONG(0xdeaddead)
52-
}
53-
.cranges 0 : { *(.cranges) }
54-
"
37+
STACK_ADDR="(DEFINED(_stack) ? _stack : ALIGN (0x40000) + 0x80000)"
38+
STACK_SENTINEL="LONG(0xdeaddead)"
5539
# We do not need .stack for shared library.
56-
test -n "$CREATE_SHLIB" && OTHER_SECTIONS="
57-
.cranges 0 : { *(.cranges) }
58-
"
40+
test -n "$CREATE_SHLIB" && unset STACK_ADDR
41+
42+
OTHER_SECTIONS=".cranges 0 : { *(.cranges) }"
5943

6044
# We need to adjust sizes in the .cranges section after relaxation, so
6145
# we need an after_allocation function, and it goes in this file.

‎ld/emulparams/shelf64.sh

+1-10
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,4 @@ EXTRA_EM_FILE=
66
. ${srcdir}/emulparams/shelf32.sh
77

88
# We do not need .cranges
9-
test -z "$CREATE_SHLIB" && OTHER_SECTIONS="
10-
.stack ${RELOCATING-0}${RELOCATING+(DEFINED(_stack) ? _stack : ALIGN (0x40000) + 0x80000)} :
11-
{
12-
${RELOCATING+_stack = .;}
13-
*(.stack)
14-
LONG(0xdeaddead)
15-
}
16-
"
17-
# We do not need .stack for shared library.
18-
test -n "$CREATE_SHLIB" && OTHER_SECTIONS=""
9+
unset OTHER_SECTIONS

‎ld/emulparams/shelf_nbsd.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ DATA_START_SYMBOLS='PROVIDE (__data_start = .);';
1212
ENTRY=_start
1313

1414
unset EMBEDDED
15-
unset OTHER_SECTIONS
15+
unset STACK_ADDR

‎ld/emulparams/shelf_uclinux.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
. ${srcdir}/emulparams/shelf.sh
22

33
# We do not want a .stack section
4-
OTHER_SECTIONS=""
4+
unset STACK_ADDR

‎ld/emulparams/shlsymbian.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ DTOR_START='__dtors = .;'
1111
DTOR_END='__dtors_end = .;'
1212

1313
# Suppress the .stack section.
14-
test -z "$CREATE_SHLIB" && OTHER_SECTIONS="${RELOCATING+PROVIDE (_stack = 0x30000);}"
14+
unset STACK_ADDR
15+
OTHER_SYMBOLS="PROVIDE (_stack = 0x30000);"
16+
test -n "$CREATE_SHLIB" && unset OTHER_SYMBOLS
1517

1618
OUTPUT_FORMAT="elf32-shl-symbian"
1719
SCRIPT_NAME=elf32sh-symbian

‎ld/scripttempl/arclinux.sc

+5-6
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,11 @@ DTOR=".dtors ${CONSTRUCTING-0} :
303303
KEEP (*(.dtors))
304304
${CONSTRUCTING+${DTOR_END}}
305305
}"
306-
STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
306+
STACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
307307
{
308308
${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
309309
*(.stack)
310+
${RELOCATING+${STACK_SENTINEL}}
310311
}"
311312

312313
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
649650
${RELOCATING+${OTHER_END_SYMBOLS}}
650651
${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
651652
${RELOCATING+${DATA_SEGMENT_END}}
653+
${TINY_DATA_SECTION}
654+
${TINY_BSS_SECTION}
655+
${STACK_ADDR+${STACK}}
652656
EOF
653657

654658
test -z "${NON_ALLOC_DYN}" || emit_dyn
@@ -669,11 +673,6 @@ EOF
669673
. $srcdir/scripttempl/DWARF.sc
670674

671675
cat <<EOF
672-
673-
${TINY_DATA_SECTION}
674-
${TINY_BSS_SECTION}
675-
676-
${STACK_ADDR+${STACK}}
677676
${ATTRS_SECTIONS}
678677
${OTHER_SECTIONS}
679678
${RELOCATING+${OTHER_SYMBOLS}}

‎ld/scripttempl/armbpabi.sc

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ cat <<EOF
317317
${RELOCATING+_end = .;}
318318
${RELOCATING+PROVIDE (end = .);}
319319
${RELOCATING+${DATA_SEGMENT_END}}
320+
${STACK_ADDR+${STACK}}
320321

321322
/* These sections are not mapped under the BPABI. */
322323
.dynamic 0 : { *(.dynamic) }
@@ -342,7 +343,6 @@ EOF
342343
. $srcdir/scripttempl/DWARF.sc
343344

344345
cat <<EOF
345-
${STACK_ADDR+${STACK}}
346346
${OTHER_SECTIONS}
347347
${RELOCATING+${OTHER_SYMBOLS}}
348348
${RELOCATING+${DISCARDED}}

‎ld/scripttempl/elf.sc

+6-7
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,11 @@ DTOR=".dtors ${CONSTRUCTING-0} :
305305
KEEP (*(.dtors))
306306
${CONSTRUCTING+${DTOR_END}}
307307
}"
308-
STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
308+
STACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
309309
{
310310
${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
311311
*(.stack)
312+
${RELOCATING+${STACK_SENTINEL}}
312313
}"
313314

314315
TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
@@ -641,7 +642,7 @@ EOF
641642
LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${LARGE_DATA_ADDR-.});"
642643
SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_ADDR-.});"
643644

644-
cat <<EOF
645+
cat <<EOF
645646
${RELOCATING+${CREATE_SHLIB-${CREATE_PIE-${LARGE_DATA_ADDR}}}}
646647
${RELOCATING+${CREATE_SHLIB+${SHLIB_LARGE_DATA_ADDR}}}
647648
${RELOCATING+${CREATE_PIE+${SHLIB_LARGE_DATA_ADDR}}}
@@ -651,6 +652,9 @@ SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_A
651652
${RELOCATING+${OTHER_END_SYMBOLS}}
652653
${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
653654
${RELOCATING+${DATA_SEGMENT_END}}
655+
${TINY_DATA_SECTION}
656+
${TINY_BSS_SECTION}
657+
${STACK_ADDR+${STACK}}
654658
EOF
655659

656660
test -z "${NON_ALLOC_DYN}" || emit_dyn
@@ -671,11 +675,6 @@ EOF
671675
. $srcdir/scripttempl/DWARF.sc
672676

673677
cat <<EOF
674-
675-
${TINY_DATA_SECTION}
676-
${TINY_BSS_SECTION}
677-
678-
${STACK_ADDR+${STACK}}
679678
${ATTRS_SECTIONS}
680679
${OTHER_SECTIONS}
681680
${RELOCATING+${OTHER_SYMBOLS}}

‎ld/scripttempl/elf64hppa.sc

+6-6
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,11 @@ DTOR=".dtors ${CONSTRUCTING-0} :
255255
KEEP (*(.dtors))
256256
${CONSTRUCTING+${DTOR_END}}
257257
}"
258-
STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
258+
STACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
259259
{
260-
${RELOCATING+_stack = .;}
260+
${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
261261
*(.stack)
262+
${RELOCATING+${STACK_SENTINEL}}
262263
}"
263264

264265
TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
@@ -513,6 +514,9 @@ cat <<EOF
513514
${RELOCATING+${OTHER_END_SYMBOLS}}
514515
${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
515516
${RELOCATING+${DATA_SEGMENT_END}}
517+
${TINY_DATA_SECTION}
518+
${TINY_BSS_SECTION}
519+
${STACK_ADDR+${STACK}}
516520
EOF
517521

518522
if test -n "${NON_ALLOC_DYN}"; then
@@ -545,10 +549,6 @@ EOF
545549
. $srcdir/scripttempl/DWARF.sc
546550

547551
cat <<EOF
548-
${TINY_DATA_SECTION}
549-
${TINY_BSS_SECTION}
550-
551-
${STACK_ADDR+${STACK}}
552552
${ATTRS_SECTIONS}
553553
${OTHER_SECTIONS}
554554
${RELOCATING+${OTHER_SYMBOLS}}

‎ld/scripttempl/elf_chaos.sc

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ cat <<EOF
317317
${RELOCATING+${OTHER_END_SYMBOLS}}
318318
${RELOCATING+_end = .;}
319319
${RELOCATING+PROVIDE (end = .);}
320+
${STACK_ADDR+${STACK}}
320321

321322
/* Stabs debugging sections. */
322323
. = ALIGN(0x1000);
@@ -335,7 +336,6 @@ EOF
335336
. $srcdir/scripttempl/DWARF.sc
336337

337338
cat <<EOF
338-
${STACK_ADDR+${STACK}}
339339
${ATTRS_SECTIONS}
340340
${OTHER_SECTIONS}
341341
${RELOCATING+${OTHER_SYMBOLS}}

‎ld/scripttempl/elfarc.sc

-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ cat <<EOF
433433
/* ARC Extension Sections */
434434
.arcextmap 0 : { *(.gnu.linkonce.arcextmap.*) }
435435

436-
${STACK_ADDR+${STACK}}
437436
${OTHER_SECTIONS}
438437
${RELOCATING+${OTHER_END_SYMBOLS}}
439438
${RELOCATING+${STACKNOTE}}

‎ld/scripttempl/elfxtensa.sc

+6-6
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,11 @@ DTOR=".dtors ${CONSTRUCTING-0} :
272272
KEEP (*(.dtors))
273273
${CONSTRUCTING+${DTOR_END}}
274274
}"
275-
STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
275+
STACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
276276
{
277-
${RELOCATING+_stack = .;}
277+
${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
278278
*(.stack)
279+
${RELOCATING+${STACK_SENTINEL}}
279280
}"
280281

281282
# If this is for an embedded system, don't add SIZEOF_HEADERS.
@@ -523,6 +524,9 @@ cat <<EOF
523524
${RELOCATING+${OTHER_END_SYMBOLS}}
524525
${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
525526
${RELOCATING+${DATA_SEGMENT_END}}
527+
${TINY_DATA_SECTION}
528+
${TINY_BSS_SECTION}
529+
${STACK_ADDR+${STACK}}
526530
EOF
527531

528532
if test -n "${NON_ALLOC_DYN}"; then
@@ -555,10 +559,6 @@ EOF
555559
. $srcdir/scripttempl/DWARF.sc
556560

557561
cat <<EOF
558-
${TINY_DATA_SECTION}
559-
${TINY_BSS_SECTION}
560-
561-
${STACK_ADDR+${STACK}}
562562
${ATTRS_SECTIONS}
563563
${OTHER_SECTIONS}
564564
${RELOCATING+${OTHER_SYMBOLS}}

‎ld/scripttempl/epiphany_4x4.sc

+6-23
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
# combination of .init sections.
5555
# FINI_START, FINI_END - statements just before and just after
5656
# combination of .fini sections.
57-
# STACK_ADDR - start of a .stack section.
5857
# OTHER_SYMBOLS - symbols to place right at the end of the script.
5958
# ETEXT_NAME - name of a symbol for the end of the text section,
6059
# normally etext.
@@ -242,11 +241,6 @@ DTOR=".dtors ADDR(.ctors) + SIZEOF(.ctors) ${CONSTRUCTING-0} :
242241
KEEP (*(.dtors))
243242
${CONSTRUCTING+${DTOR_END}}
244243
} /*> INTERNAL_RAM*/ "
245-
STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
246-
{
247-
${RELOCATING+___stack = .;}
248-
*(.stack)
249-
}"
250244

251245
# If this is for an embedded system, don't add SIZEOF_HEADERS.
252246
if [ -z "$EMBEDDED" ]; then
@@ -608,6 +602,12 @@ cat <<EOF
608602
${RELOCATING+${OTHER_END_SYMBOLS}}
609603
${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
610604
${RELOCATING+${DATA_SEGMENT_END}}
605+
606+
PROVIDE ( __stack_start_ = ORIGIN(EXTERNAL_DRAM_0) + __PROG_SIZE_FOR_CORE__ * __CORE_NUM_ + __PROG_SIZE_FOR_CORE__ - 0x10) ;
607+
.stack ${RELOCATING+__stack_start_} : { ${RELOCATING+___stack = .;} *(.stack) }
608+
609+
PROVIDE ( ___heap_start = ORIGIN(EXTERNAL_DRAM_1) + __HEAP_SIZE_FOR_CORE__ * __CORE_NUM_ );
610+
PROVIDE ( ___heap_end = ORIGIN(EXTERNAL_DRAM_1) + __HEAP_SIZE_FOR_CORE__ * __CORE_NUM_ + __HEAP_SIZE_FOR_CORE__ - 4 );
611611
EOF
612612

613613
if test -n "${NON_ALLOC_DYN}"; then
@@ -640,23 +640,6 @@ EOF
640640
. $srcdir/scripttempl/DWARF.sc
641641

642642
cat <<EOF
643-
${TINY_DATA_SECTION}
644-
${TINY_BSS_SECTION}
645-
646-
/*${STACK_ADDR+${STACK}}*/
647-
648-
PROVIDE ( __stack_start_ = ORIGIN(EXTERNAL_DRAM_0) + __PROG_SIZE_FOR_CORE__ * __CORE_NUM_ + __PROG_SIZE_FOR_CORE__ - 0x10) ;
649-
.stack ${RELOCATING+__stack_start_} : { ___stack = .; *(.stack) }
650-
651-
PROVIDE ( ___heap_start = ORIGIN(EXTERNAL_DRAM_1) + __HEAP_SIZE_FOR_CORE__ * __CORE_NUM_ );
652-
/*.heap_start __heap_start_ : { _heap_start_ = .; *(.heap_start) }*/
653-
654-
PROVIDE ( ___heap_end = ORIGIN(EXTERNAL_DRAM_1) + __HEAP_SIZE_FOR_CORE__ * __CORE_NUM_ + __HEAP_SIZE_FOR_CORE__ - 4 );
655-
656-
657-
/* .heap_end __heap_end_ : { _heap_end_ = .; *(.heap_end) }*/
658-
659-
660643
${ATTRS_SECTIONS}
661644
${OTHER_SECTIONS}
662645
${RELOCATING+${OTHER_SYMBOLS}}

‎ld/scripttempl/nds32elf.sc

+5-6
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,11 @@ DTOR=".dtors ${CONSTRUCTING-0} :
246246
KEEP (*(.dtors))
247247
${CONSTRUCTING+${DTOR_END}}
248248
}"
249-
STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
249+
STACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
250250
{
251251
${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
252252
*(.stack)
253+
${RELOCATING+${STACK_SENTINEL}}
253254
}"
254255

255256
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
594595
${RELOCATING+${OTHER_END_SYMBOLS}}
595596
${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
596597
${RELOCATING+${DATA_SEGMENT_END}}
598+
${TINY_DATA_SECTION}
599+
${TINY_BSS_SECTION}
600+
${STACK_ADDR+${STACK}}
597601
EOF
598602

599603
test -z "${NON_ALLOC_DYN}" || emit_dyn
@@ -614,11 +618,6 @@ EOF
614618
. $srcdir/scripttempl/DWARF.sc
615619

616620
cat <<EOF
617-
618-
${TINY_DATA_SECTION}
619-
${TINY_BSS_SECTION}
620-
621-
${STACK_ADDR+${STACK}}
622621
${ATTRS_SECTIONS}
623622
${OTHER_SECTIONS}
624623
${RELOCATING+${OTHER_SYMBOLS}}

0 commit comments

Comments
 (0)
Please sign in to comment.