#1386 closed defect (fixed)

SPARC start.S incorrectly initializes stack pointer

Reported by: Joel Sherrill Owned by: Joel Sherrill
Priority: normal Milestone: 4.10
Component: bsps Version: 4.9
Severity: normal Keywords:
Cc: daniel@… Blocked By:
Blocking:

Description

Joel: Likely impacts 4.6 and newer.

The stack is incorrectly initialized to the address of rdb_start, which
is in the middle of the trap table. This has the effect that the trap
table gets overwritten and memory under the trap table may be accessed
when more than 2Kb of stack is used. All SPARC applications without
optimization I have tested so far crashes. See patch below.

Index: c/src/lib/libbsp/sparc/shared/start.S
===================================================================
RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/sparc/shared/start.S,v
retrieving revision 1.11
diff -u -r1.11 start.S
--- c/src/lib/libbsp/sparc/shared/start.S 15 May 2008 15:53:23
-0000 1.11
+++ c/src/lib/libbsp/sparc/shared/start.S 23 Feb 2009 17:16:27 -0000
@@ -223,7 +223,7 @@

set (SYM(rdb_start)), %g6 ! End of work-space area
st %sp, [%g6]

  • sub %g6, 4, %sp ! stack starts at end of RAM - 4

+ sub %sp, 4, %sp ! stack starts at end of RAM - 4

andn %sp, 0x0f, %sp ! align stack on 16-byte boundary

mov %sp, %fp ! Set frame pointer
nop

Attachments (2)

sp9.diff (696 bytes) - added by Joel Sherrill on Feb 27, 2009 at 2:31:40 PM.
Patch for 4.9
sp10.diff (696 bytes) - added by Joel Sherrill on Feb 27, 2009 at 2:31:56 PM.
Patch for 4.10

Download all attachments as: .zip

Change History (3)

Changed on Feb 27, 2009 at 2:31:40 PM by Joel Sherrill

Attachment: sp9.diff added

Patch for 4.9

Changed on Feb 27, 2009 at 2:31:56 PM by Joel Sherrill

Attachment: sp10.diff added

Patch for 4.10

comment:1 Changed on Mar 12, 2009 at 1:12:23 PM by Joel Sherrill

Resolution: fixed
Status: newclosed

Patch applied.

Note: See TracTickets for help on using tickets.