RFA: RL78: Add an assertion to detect link time data overflow.

Nick Clifton nickc@redhat.com
Wed May 13 18:02:00 GMT 2015


Hi DJ,

  The patch below adds an assertion the .stack sections in the RL78
  linker scripts in libgloss.  This assertion checks for the data area
  overflowing into the stack space.  (Using the linker's
  --check-sections option does not work because the .stack section is
  empty).

  OK to apply ?

Cheers
  Nick

libgloss/ChangeLog
2015-05-13  Nick Clifton  <nickc@redhat.com>

	* rl78/rl78.ld (.stack): Add an assertion to make sure that the
	data area does not overrun the stack.
	* rl78/rl78-sim.ld (.stack): Likewise.

diff --git a/libgloss/rl78/rl78-sim.ld b/libgloss/rl78/rl78-sim.ld
index 26d62ac..ff7f403 100644
--- a/libgloss/rl78/rl78-sim.ld
+++ b/libgloss/rl78/rl78-sim.ld
@@ -126,6 +126,10 @@ SECTIONS
   {
     PROVIDE (__stack = .);
     *(.stack)
+    /* Linker section checking ignores empty sections
+       like this so we have to have our own test here.
+       The value 0x100 is just a guess.  */
+    ASSERT ((__stack > (_end + 0x100)), "Error: Too much data - no room left for the stack");
   }
   
   .saddr : {
diff --git a/libgloss/rl78/rl78.ld b/libgloss/rl78/rl78.ld
index d560b14..5d9f25d 100644
--- a/libgloss/rl78/rl78.ld
+++ b/libgloss/rl78/rl78.ld
@@ -126,6 +126,10 @@ SECTIONS
   {
     PROVIDE (__stack = .);
     *(.stack)
+    /* Linker section checking ignores empty sections
+       like this so we have to have our own test here.
+       The value 0x100 is just a guess.  */
+    ASSERT ((__stack > (_end + 0x100)), "Error: Too much data - no room left for the stack");
   }
 
   .saddr : {



More information about the Newlib mailing list