Hi Dmitry,
Yes its getting complex :-). By renaming the variables and changing the
linker script to define __stack = ${STACK} - __reserve_ram its a bit
simpler and easier to understand. Attached are the patches to do this.
Is their some reason that you define ${STACK} in
binutils/ld/emulparams/msp.... and don't just use ${RAM_START} +
${RAM_END} ?
The attached patch also has a minor fix to the constructors (the label
L__ctors_end should have been .L__ctors_end in the function
_do_global_ctors).
I guess some of the problem is the RESERVE_RAM attribute of a function,
I have not seen this in any other gcc port, is it the best way of doing
this with gcc?
Dmitry wrote:
Hi Peter,
this becomes toooo complex.
should be a simpler solution.
Lets find it.
Regards,
--
Peter Jansen
STS
Australian Antarctic Division
Channel Highway
Kingston
TAS 7050
AUSTRALIA
Ph (03) 62 323 533
Fax (03) 62 323 351
___________________________________________________________________________
Australian Antarctic Division - Commonwealth of Australia
IMPORTANT: This transmission is intended for the addressee only. If you are
not the intended recipient, you are notified that use or dissemination of
this communication is strictly prohibited by Commonwealth law. If you have
received this transmission in error, please notify the sender immediately
by e-mail or by telephoning +61 3 6232 3209 and DELETE the message.
Visit our web site at http://www.aad.gov.au/
___________________________________________________________________________
Index: gcc-3.4/gcc/config/msp430/libgcc.S
===================================================================
RCS file: /cvsroot/mspgcc/gcc/gcc-3.4/gcc/config/msp430/libgcc.S,v
retrieving revision 1.7
diff -U6 -r1.7 libgcc.S
--- gcc-3.4/gcc/config/msp430/libgcc.S 9 Apr 2003 08:49:37 -0000 1.7
+++ gcc-3.4/gcc/config/msp430/libgcc.S 13 Apr 2003 22:46:56 -0000
@@ -623,12 +623,13 @@
.section .init0, "ax", @progbits
.global _reset_vector__
.func _reset_vector__
_reset_vector__:
mov #23168, &288
+ mov #(__stack), r1
.section .init2, "ax", @progbits
.global _copy_data_init__
.weak _copy_data_init__
_copy_data_init__:
@@ -673,23 +674,22 @@
#ifdef L_ctors
.section .init6,"ax",@progbits
.global __do_global_ctors
__do_global_ctors:
- mov #__stack, r1 ; load stack... might be dangerous!!!
mov #__ctors_start, r11
mov #__ctors_end, r10
cmp r10, r11
jeq .L__ctors_end
.L__ctors_loop:
call @r11 ; call constructor
incd r11
cmp r10, r11
jne .L__ctors_loop
-L__ctors_end:
+.L__ctors_end:
#endif
#ifdef L_dtors
.section .fini6,"ax",@progbits
.global __do_global_dtors
__do_global_dtors:
Index: gcc-3.4/gcc/config/msp430/msp430.c
===================================================================
RCS file: /cvsroot/mspgcc/gcc/gcc-3.4/gcc/config/msp430/msp430.c,v
retrieving revision 1.12
diff -U6 -r1.12 msp430.c
--- gcc-3.4/gcc/config/msp430/msp430.c 9 Apr 2003 07:42:42 -0000 1.12
+++ gcc-3.4/gcc/config/msp430/msp430.c 13 Apr 2003 22:46:57 -0000
@@ -17,14 +17,12 @@
along with GCC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "config.h"
#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
#include "rtl.h"
#include "regs.h"
#include "hard-reg-set.h"
#include "real.h"
#include "insn-config.h"
#include "conditions.h"
@@ -786,16 +784,18 @@
prologue_size += 1;
fprintf (file, "\teint\t; enable nested interrupt\n");
}
if (main_p)
{
+ fprintf(file, "\t.global\t__reserve_ram\n");
+ fprintf(file, "__reserve_ram=%d\n", stack_reserve);
if (TARGET_NSI)
{
if (size || stack_reserve)
- fprintf (file, "\tsub\t#%ld, r1\t", size + stack_reserve);
+ fprintf (file, "\tsub\t#%ld, r1\t", size);
if (frame_pointer_needed)
{
fprintf (file, "\tmov\tr1,r%d\n", FRAME_POINTER_REGNUM);
prologue_size += 1;
}
@@ -804,13 +804,13 @@
if (size == 1 || size == 2 || size == 4 || size == 8)
prologue_size--;
}
else
{
fprintf (file, "\tmov\t#(%s-%ld), r1\n", msp430_init_stack,
- size + stack_reserve);
+ size);
if (frame_pointer_needed)
{
fprintf (file, "\tmov\tr1,r%d\n", FRAME_POINTER_REGNUM);
prologue_size += 1;
}
Index: src/ld/scripttempl/elf32msp430.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/elf32msp430.sc,v
retrieving revision 1.3
diff -C6 -r1.3 elf32msp430.sc
*** src/ld/scripttempl/elf32msp430.sc 9 Apr 2003 11:07:51 -0000 1.3
--- src/ld/scripttempl/elf32msp430.sc 13 Apr 2003 22:42:37 -0000
***************
*** 211,223 ****
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
! PROVIDE (__stack = ${STACK}) ;
PROVIDE (__data_start_rom = _etext) ;
PROVIDE (__data_end_rom = _etext + SIZEOF (.data)) ;
PROVIDE (__noinit_start_rom = _etext + SIZEOF (.data)) ;
PROVIDE (__noinit_end_rom = _etext + SIZEOF (.data) + SIZEOF (.noinit)) ;
}
EOF
--- 211,223 ----
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
! PROVIDE (__stack = ${STACK} - __reserve_ram) ;
PROVIDE (__data_start_rom = _etext) ;
PROVIDE (__data_end_rom = _etext + SIZEOF (.data)) ;
PROVIDE (__noinit_start_rom = _etext + SIZEOF (.data)) ;
PROVIDE (__noinit_end_rom = _etext + SIZEOF (.data) + SIZEOF (.noinit)) ;
}
EOF
Index: src/ld/scripttempl/elf32msp430_3.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/elf32msp430_3.sc,v
retrieving revision 1.3
diff -C6 -r1.3 elf32msp430_3.sc
*** src/ld/scripttempl/elf32msp430_3.sc 9 Apr 2003 11:07:51 -0000 1.3
--- src/ld/scripttempl/elf32msp430_3.sc 13 Apr 2003 22:42:37 -0000
***************
*** 180,192 ****
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
! PROVIDE (__stack = ${STACK}) ;
PROVIDE (__data_start_rom = _etext) ;
PROVIDE (__data_end_rom = _etext + SIZEOF (.data)) ;
PROVIDE (__noinit_start_rom = _etext + SIZEOF (.data)) ;
PROVIDE (__noinit_end_rom = _etext + SIZEOF (.data) + SIZEOF (.noinit)) ;
}
EOF
--- 180,192 ----
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
! PROVIDE (__stack = ${STACK} - __reserve_ram) ;
PROVIDE (__data_start_rom = _etext) ;
PROVIDE (__data_end_rom = _etext + SIZEOF (.data)) ;
PROVIDE (__noinit_start_rom = _etext + SIZEOF (.data)) ;
PROVIDE (__noinit_end_rom = _etext + SIZEOF (.data) + SIZEOF (.noinit)) ;
}
EOF