Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2015-05-18 16:14:28 +0300
committerCorinna Vinschen <corinna@vinschen.de>2015-05-27 14:30:19 +0300
commit324bd1170642cf2c2fd963350aa428e0cc5a88fb (patch)
treeb78129cdcda347e9177ec9685d5ecef4e33529a1 /libgloss/rl78
parent7b3c1cffceea4c5418cf708d09a5187ff235cfe2 (diff)
Add a check that the data area does not overrun the stack.
* msp430/msp430-sim.ld (.stack): Add an assertion to make sure that the data area does not overrun the stack. PROVIDE a new symbol __stack_size to allow the user to set the limit. * msp430/msp430xl-sim.ld (.stack): Likewise. * rl78/rl78-sim.ld (.stack): Likewise. * rl78/rl78.ld (.stack): Likewise. * rx/rx-sim.ld (.stack): Likewise. * rx/rx.ld (.stack): Likewise.
Diffstat (limited to 'libgloss/rl78')
-rw-r--r--libgloss/rl78/rl78-sim.ld16
-rw-r--r--libgloss/rl78/rl78.ld16
2 files changed, 32 insertions, 0 deletions
diff --git a/libgloss/rl78/rl78-sim.ld b/libgloss/rl78/rl78-sim.ld
index 26d62ac40..49442d11e 100644
--- a/libgloss/rl78/rl78-sim.ld
+++ b/libgloss/rl78/rl78-sim.ld
@@ -122,10 +122,26 @@ SECTIONS
} > RAM
PROVIDE (__bsssize = SIZEOF(.bss));
+ /* The __stack_size value of 0x100 is just a guess, but since it is
+ PROVIDEd the user can override it on the command line. It has to be
+ set here, rather than inside the .stack section, as symbols defined
+ inside sections are only evaluated during the final phase of the link,
+ long after the ASSERT is checked. An ASSERT referencing a PROVIDED but
+ not yet evaluated symbol will automatically fail.
+
+ FIXME: It would be nice if this value could be automatically set via
+ gcc's -fstack-usage command line option somehow. */
+ PROVIDE (__stack_size = 0x100);
+
.stack (ORIGIN (STACK)) :
{
PROVIDE (__stack = .);
*(.stack)
+
+ /* Linker section checking ignores empty sections like
+ this one so we have to have our own test here. */
+ ASSERT ((__stack > (_end + __stack_size)),
+ "Error: Too much data - no room left for the stack");
}
.saddr : {
diff --git a/libgloss/rl78/rl78.ld b/libgloss/rl78/rl78.ld
index d560b1409..271104af2 100644
--- a/libgloss/rl78/rl78.ld
+++ b/libgloss/rl78/rl78.ld
@@ -122,10 +122,26 @@ SECTIONS
} > RAM
PROVIDE (__bsssize = SIZEOF(.bss));
+ /* The __stack_size value of 0x100 is just a guess, but since it is
+ PROVIDEd the user can override it on the command line. It has to be
+ set here, rather than inside the .stack section, as symbols defined
+ inside sections are only evaluated during the final phase of the link,
+ long after the ASSERT is checked. An ASSERT referencing a PROVIDED but
+ not yet evaluated symbol will automatically fail.
+
+ FIXME: It would be nice if this value could be automatically set via
+ gcc's -fstack-usage command line option somehow. */
+ PROVIDE (__stack_size = 0x100);
+
.stack (ORIGIN (STACK)) :
{
PROVIDE (__stack = .);
*(.stack)
+
+ /* Linker section checking ignores empty sections like
+ this one so we have to have our own test here. */
+ ASSERT ((__stack > (_end + __stack_size)),
+ "Error: Too much data - no room left for the stack");
}
.saddr : {