CVS: gcc/gcc-3.3/gcc/config/msp430 libgcc.S, 1.10, 1.11 msp430.h, 1.40, 1.41 t-msp430, 1.26, 1.27
Chris Liechti <[email protected]> Mon, 26 May 2008 16:12:47 -0700
| 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 sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13882/gcc/config/msp430
Modified Files:
libgcc.S msp430.h t-msp430
Log Message:
Sergey's new init code that uses small, overridable .initX sections.
NOTE: bss init buggy (fix follows)
Index: libgcc.S
===================================================================
RCS file: /cvsroot/mspgcc/gcc/gcc-3.3/gcc/config/msp430/libgcc.S,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -d -r1.10 -r1.11
--- libgcc.S 3 Dec 2003 15:41:41 -0000 1.10
+++ libgcc.S 26 May 2008 23:12:44 -0000 1.11
@@ -547,65 +547,216 @@
/******* CRT support functions *********/
+#if defined(L_reset_vector__)
+/*****************************************************************
+ * Program starts here.
+ * overwriting this label in the user program
+ * causes removing all strtup code except __do_global_ctors
+ *****************************************************************/
+ .section .init0, "ax", @progbits
+
+ .global _reset_vector__
+ .weak _reset_vector__
+
+ .func _reset_vector__
+
+_reset_vector__:
+
+ /* link following functions if library _reset_vector__ used */
+
+; actualy stack initialized in main() prologue, so don't link __init_stack
+; .global __init_stack
+
+ .global __low_level_init
+ .global __jump_to_main
+
+ .endfunc
+#endif /* defined(L_reset_vector__) */
+
+#if defined(L__init_stack)
+/*****************************************************************
+ * Set stack pointer
+ * can be overwriten
+ *****************************************************************/
+ .section .init2, "ax", @progbits
+
+ .global __init_stack
+ .weak __init_stack
+ .extern __stack
+
+ .func __init_stack
+
+set_stack_pointer:
+ mov #__stack, r1
+
+ .endfunc
+#endif
+
+#if defined(L__low_level_init)
+/*****************************************************************
+ * Initialize peripherial, particularly disable watchdog
+ * can be overwriten
+ *****************************************************************/
+ .section .init3, "ax", @progbits
+
+ .global __low_level_init
+ .weak __low_level_init
+
+ .func __low_level_init
+
+__low_level_init:
+ mov #0x5a80, &0x120
+
+ .endfunc
+#endif
+
+#if defined(L_copy_data)
+/*****************************************************************
+ * Initialize data: copy data
+ * from __data_load_start ( = _etext) to __data_start
+ * can be overwriten
+ *****************************************************************/
+ .section .init4, "ax", @progbits
+
+ .global __do_copy_data
+ .weak __do_copy_data
+ .extern __data_load_start
+ .extern __data_start
+ .extern __data_size
+
+ .func __do_copy_data
+
+__do_copy_data:
+ mov #__data_size, r15
+.L__copy_data_loop:
+ decd r15
+ mov.w __data_load_start(r15), __data_start(r15) ; data section is word-aligned, so word transfer is acceptable
+ jne .L__copy_data_loop
+
+ .endfunc
+#endif /* defined(L__do_copy_data) */
+
+#if defined(L_clear_bss)
+/*****************************************************************
+ * Initialize data: clear .bss
+ * can be overwriten
+ *****************************************************************/
+ .section .init4, "ax", @progbits
+
+ .global __do_clear_bss
+ .weak __do_clear_bss
+ .extern __bss_start
+ .extern __bss_size
+
+ .func __do_clear_bss
+
+__do_clear_bss:
+ mov #__bss_size, r15
+.L__clear_bss_loop:
+ dec r15
+ clr.b __bss_start(r15)
+ jne .L__clear_bss_loop
+
+ .endfunc
+#endif /* defined(L_clear_bss) */
+
+#if defined(L_ctors)
+/*****************************************************************
+ * Call C++ global and static objects constructors
+ * can be overwriten
+ *****************************************************************/
+ .section .init6, "ax", @progbits
+ .global __do_global_ctors
+ .weak __do_global_ctors
+ .extern __ctors_start
+ .extern __ctors_end
+
+ .func __do_global_ctors
+
+ mov #__stack, r1 ; can be removed, if stack initialization in .init2 uncommented
+
+__do_global_ctors:
+ mov #__ctors_start, r11
+ mov #__ctors_end, r10
+.L__ctors_loop:
+ call @r11+ ; call constructor
+ cmp r10, r11
+ jne .L__ctors_loop
+
+ .endfunc
+#endif
+
+#if defined(L__jump_to_main)
+/*****************************************************************
+ * jump to main.
+ * can be overwriten
+ *****************************************************************/
+ .section .init9, "ax", @progbits
+
+ .global __jump_to_main
+ .weak __jump_to_main
+ .extern _main
+
+ .func __jump_to_main
+
+__jump_to_main:
+ br #main
+ .endfunc
+#endif
+
#if defined(L__stop_progExec__)
+/*****************************************************************
+ * return from main.
+ * can be overwriten
+ *****************************************************************/
+ .section .fini9, "ax", @progbits
.global __stop_progExec__
.weak __stop_progExec__
+
.func __stop_progExec__
+
__stop_progExec__:
- bis r15, r2
- jmp __stop_progExec__
+
.endfunc
-#endif /* #if defined(L__stop_progExec__) */
+#endif
-#if defined(L_reset_vector__)
+#if defined(L_dtors)
/*****************************************************************
- * Initialize data: copy data from _etext to __data_start
- * Can be overwritten.
+ * Call C++ global and static objects destructors
+ * can be overwriten
*****************************************************************/
- .extern _etext
- .extern __data_start
- .extern _edata
- .extern __bss_start
- .extern __bss_end
- .extern __stack
-
- .section .init, "ax", @progbits
+ .section .fini6,"ax",@progbits
+ .global __do_global_dtors
+ .weak __do_global_dtors
+ .extern __dtors_start
+ .extern __dtors_end
- .global _reset_vector__
+ .func _dtors
-.func _reset_vector__
-_reset_vector__:
- mov #23168, &288
- mov #_etext, r15 ; load r15 with end of .text segment
- mov #__data_start, r14 ; load ram start
- mov #_edata, r13 ; end of data segment
- cmp r14, r13
- jeq .Lend_of_data_loop
-;; inc r13
-.Lcopy_data_loop:
- /* copy data from @r15 to @r14 */
- mov.b @r15+, @r14 ; move one byte
- inc r14
- cmp r13, r14 ; check if end of data reached
- jlo .Lcopy_data_loop
-.Lend_of_data_loop:
+__do_global_dtors:
+ mov #__dtors_start, r11
+ mov #__dtors_end, r10
+.L__dtors_loop:
+ call @r11+
+ cmp r10, r11
+ jne .L__dtors_loop
- mov #__bss_start, r15
- mov #__bss_end, r13
- cmp r15, r13
- jeq .Lend_of_bss_loop
-;; inc r13
-.Lzero_bss:
- clr.b @r15
- inc r15
- cmp r13, r15 ; check if r15 < r13
- jlo .Lzero_bss
-.Lend_of_bss_loop:
- br #main ; jump to main procedure
.endfunc
#endif
+#if defined(L__stop_progExec__)
+/*****************************************************************
+ * endless loop
+ * can be overwriten
+ *****************************************************************/
+ .section .fini0, "ax", @progbits
+
+ .func _endless_loop__
+1:
+ jmp 1b
+ .endfunc
+#endif
/********* PROLOGE / EPILOGUE aux routines ******************/
#if defined (L__prologue_saver)
Index: msp430.h
===================================================================
RCS file: /cvsroot/mspgcc/gcc/gcc-3.3/gcc/config/msp430/msp430.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -w -d -r1.40 -r1.41
--- msp430.h 17 May 2008 02:41:28 -0000 1.40
+++ msp430.h 26 May 2008 23:12:44 -0000 1.41
@@ -1749,7 +1749,7 @@
operation that should precede instructions and read-only data.
Normally `"\t.text"' is right. */
-#define DATA_SECTION_ASM_OP "\t.data"
+#define DATA_SECTION_ASM_OP "\t.global\t__do_copy_data\n\t.data"
/* A C expression whose value is a string containing the assembler
operation to identify the following data as writable initialized
data. Normally `"\t.data"' is right. */
@@ -1790,6 +1790,19 @@
}
+/* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
+ There are no shared libraries on this target, and these sections are
+ placed in the read-only program memory, so they are not writable. */
+
+#undef CTORS_SECTION_ASM_OP
+#define CTORS_SECTION_ASM_OP "\t.global\t__do_global_ctors\n\t.section .ctors,\"a\",@progbits"
+
+#undef DTORS_SECTION_ASM_OP
+#define DTORS_SECTION_ASM_OP "\t.global\t__do_global_dtors\n\t.section .dtors,\"a\",@progbits"
+
+#define TARGET_ASM_CONSTRUCTOR default_ctor_section_asm_out_constructor
+
+#define TARGET_ASM_DESTRUCTOR default_dtor_section_asm_out_destructor
/* `EXTRA_SECTION_FUNCTIONS'
One or more functions to be defined in `varasm.c'. These
@@ -2075,6 +2088,9 @@
This macro controls how the assembler definitions of uninitialized
common global variables are output. */
+#define ASM_OUTPUT_BSS(FILE, DECL, NAME, SIZE, ROUNDED) \
+ asm_output_bss ((FILE), (DECL), (NAME), (SIZE), (ROUNDED))
+
#define ASM_OUTPUT_LOCAL(STREAM, NAME, SIZE, ROUNDED) \
do { \
char *p = NAME; \
@@ -2099,7 +2115,7 @@
This macro controls how the assembler definitions of uninitialized
static variables are output. */
-#define BSS_SECTION_ASM_OP "\t.section\t.bss"
+#define BSS_SECTION_ASM_OP "\t.global\t__do_clear_bss\n\t.section\t.bss"
/* If defined, a C expression whose value is a string containing the
assembler operation to identify the following data as
uninitialized global data. If not defined, and neither
Index: t-msp430
===================================================================
RCS file: /cvsroot/mspgcc/gcc/gcc-3.3/gcc/config/msp430/t-msp430,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -w -d -r1.26 -r1.27
--- t-msp430 15 May 2008 00:57:56 -0000 1.26
+++ t-msp430 26 May 2008 23:12:44 -0000 1.27
@@ -31,8 +31,14 @@
_umoddi3 \
_divdi3 \
_moddi3 \
- _muldi3
-
+ _muldi3 \
+ __low_level_init \
+ __init_stack \
+ _copy_data \
+ _clear_bss \
+ _ctors \
+ __jump_to_main \
+ _dtors
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/