CVS: gcc/gcc-3.3/gcc/config/msp430 libgcc.S, 1.14, 1.15

"Sergey A. Borshch" <[email protected]> Thu, 11 Dec 2008 19:52:31 +0000
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.cvs
Message-ID <[email protected]>
Update of /cvsroot/mspgcc/gcc/gcc-3.3/gcc/config/msp430
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv19277

Modified Files:
	libgcc.S 
Log Message:
Initializing stack pointer befote C++ constructors fixed.


Index: libgcc.S
===================================================================
RCS file: /cvsroot/mspgcc/gcc/gcc-3.3/gcc/config/msp430/libgcc.S,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -w -d -r1.14 -r1.15
--- libgcc.S	30 May 2008 23:01:32 -0000	1.14
+++ libgcc.S	11 Dec 2008 19:52:29 -0000	1.15
@@ -564,8 +564,26 @@
 
     /* link following functions if library _reset_vector__ used */
 
-;    actualy stack initialized in main() prologue, so don't link __init_stack
-;	.global	__init_stack
+;    stack can be initialized in main() prologue,
+;    but setting stack pointer here allows to call subroutines 
+;    from startup code and call constructors of statically allocated C++ objects.
+;    Stack pointer will have the same value entering main() as here,
+;    so -mno-stack-init can be used to reduce code size.
+;    initial stack value can be set in ld script as __stack symbol 
+;    (end of RAM by default), or via -defsym __stack=<address> ld option
+;    or via -Wl,defsym,__stack=<address> gcc option, or by redefining
+;    __init_stack function as fololws:
+;
+;#if defined (__cplusplus)
+;extern "C" 
+;#endif
+;__attribute__((__naked__)) __attribute__((section(".init2"))) void __init_stack()
+;{
+;    asm volatile("\tmov\t#stack_addr, r1\n");
+;}
+;
+
+	.global	__init_stack
 
 	.global	__low_level_init
 	.global	__do_copy_data
@@ -587,7 +605,7 @@
 
 	.func   __init_stack
 
-set_stack_pointer:
+__init_stack:
 	mov     #__stack, r1
 
 	.endfunc
@@ -672,8 +690,6 @@
 	.weak   __do_global_ctors
     
 	.func   __do_global_ctors
-	.global	__init_stack    ; stack has to be set before constructors calling
-
 
 __do_global_ctors:
 	mov     #__ctors_start, r11


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/