2015-05-05 19:45:38 +08:00
|
|
|
/* Copyright (c) 2012-2015 Red Hat, Inc. All rights reserved.
|
2013-05-14 05:39:51 +08:00
|
|
|
|
|
|
|
This copyrighted material is made available to anyone wishing to use, modify,
|
|
|
|
copy, or redistribute it subject to the terms and conditions of the BSD
|
|
|
|
License. This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
|
|
|
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
|
|
|
is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
|
|
|
are incorporated in the source code or documentation are not subject to the BSD
|
|
|
|
License and may only be used or replicated with the express permission of
|
|
|
|
Red Hat, Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "memmodel.h"
|
|
|
|
|
2014-01-30 10:46:34 +08:00
|
|
|
;; The linker links all .crt_* sections in asciibetical order at the
|
2015-05-05 19:45:38 +08:00
|
|
|
;; same place. So, the four digits in .crt_NNNN_xxx name created by
|
|
|
|
;; the START_CRT_FUNC macro determine the link order, so, keep them
|
|
|
|
;; in sequential order here. The first two digits are set here, the
|
|
|
|
;; second two allow users to insert code between code fragments here.
|
2014-01-30 10:46:34 +08:00
|
|
|
|
|
|
|
#if L0
|
2013-05-14 05:39:51 +08:00
|
|
|
.section ".resetvec", "a"
|
|
|
|
__msp430_resetvec_hook:
|
2015-05-05 19:45:38 +08:00
|
|
|
.word __crt0_start
|
2013-05-14 05:39:51 +08:00
|
|
|
|
2015-05-05 19:45:38 +08:00
|
|
|
;; Here we provide weak definitions of the symbols used in the
|
|
|
|
;; init_highbss and move_highdata blocks, in case they are not
|
|
|
|
;; provided by the linker script. They are defined here because
|
|
|
|
;; this block is always included in every executable, and because
|
|
|
|
;; if there were defined in the blocks that need them their values
|
|
|
|
;; would be used without giving the linker script a chance to
|
|
|
|
;; override them.
|
|
|
|
;;
|
|
|
|
;; The weak definitions are needed if the user targets an MCU
|
|
|
|
;; without high memory - and hence uses a linker script without
|
|
|
|
;; a definition of the .upper.bss or .upper.data sections - and
|
|
|
|
;; they have compiled their code with the -mdata-region=either
|
|
|
|
;; command line option. That option causes the assembler to
|
|
|
|
;; define the __crt0_move_highdata and/or crt0_init_highbss
|
|
|
|
;; symbols, which in turn forces the inclusion of the
|
|
|
|
;; move_highdata and/or init_highbss blocks in the startup code,
|
|
|
|
;; regardless of the fact that the sections are not present in
|
|
|
|
;; the linker script.
|
|
|
|
|
|
|
|
WEAK_DEF __upper_data_init
|
|
|
|
WEAK_DEF __rom_highdatacopysize
|
|
|
|
WEAK_DEF __high_datastart
|
|
|
|
WEAK_DEF __rom_highdatastart
|
|
|
|
WEAK_DEF __high_bssstart
|
|
|
|
WEAK_DEF __high_bsssize
|
|
|
|
|
|
|
|
START_CRT_FUNC 0000 start
|
2014-01-30 10:46:34 +08:00
|
|
|
.refsym __msp430_resetvec_hook
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
.refsym __crt0_call_main
|
2013-05-14 05:39:51 +08:00
|
|
|
mov_ #__stack, R1
|
|
|
|
|
2015-05-05 19:45:38 +08:00
|
|
|
END_CRT_FUNC start
|
2014-01-30 10:46:34 +08:00
|
|
|
#endif
|
2013-05-14 05:39:51 +08:00
|
|
|
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
;; The CRT functions below will only be present in the final linked
|
|
|
|
;; executable if the assembler decides they are needed. The assembler will
|
|
|
|
;; only define the symbol necessary to prevent them being garbage collected
|
|
|
|
;; by the linker if the file being assembled has a specific section,
|
|
|
|
;; or some other criteria is met.
|
|
|
|
;; The exception to this is __crt0_call_exit. GCC will include this function
|
|
|
|
;; if it detects that main() has an epilogue. For example, if main() has a
|
|
|
|
;; while(1) loop at the end, GCC will not generate an epilogue (since it won't
|
|
|
|
;; return) and __crt0_call_exit won't be included.
|
2015-05-05 19:45:38 +08:00
|
|
|
|
2014-01-30 10:46:34 +08:00
|
|
|
#if Lbss
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
;; This function is responsible for initializing the contents of the
|
|
|
|
;; .bss section.
|
2015-05-05 19:45:38 +08:00
|
|
|
|
|
|
|
START_CRT_FUNC 0100 init_bss
|
2014-01-30 10:46:34 +08:00
|
|
|
|
2013-05-14 05:39:51 +08:00
|
|
|
mov_ #__bssstart, R12
|
|
|
|
clr.w R13
|
2017-04-19 19:47:13 +08:00
|
|
|
mov_ #__bsssize, R14
|
2013-05-14 05:39:51 +08:00
|
|
|
#ifdef __MSP430X_LARGE__
|
2017-04-19 19:47:13 +08:00
|
|
|
clr.w R15 ; We assume that __bsssize is never > 64K
|
2013-05-14 05:39:51 +08:00
|
|
|
#endif
|
|
|
|
call_ #memset
|
2015-05-05 19:45:38 +08:00
|
|
|
|
|
|
|
END_CRT_FUNC init_bss
|
|
|
|
#endif /* Lbss */
|
|
|
|
|
2013-05-14 05:39:51 +08:00
|
|
|
|
2014-11-13 18:18:57 +08:00
|
|
|
#ifdef __MSP430X_LARGE__
|
|
|
|
#if Lhigh_bss
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
;; This function is responsible for initializing the contents of the
|
|
|
|
;; .upper.bss section.
|
2014-11-13 18:18:57 +08:00
|
|
|
|
2015-05-05 19:45:38 +08:00
|
|
|
START_CRT_FUNC 0200 init_highbss
|
2014-11-13 18:18:57 +08:00
|
|
|
|
2015-05-05 19:45:38 +08:00
|
|
|
mov_ #__high_bssstart, R12
|
|
|
|
mov.w #0, R13
|
|
|
|
mov_ #__high_bsssize, R14
|
|
|
|
;; If __high_bsssize is zero then skip the call to memset.
|
|
|
|
;; This can happen if all of the bss data was placed into .either.bss.
|
|
|
|
cmp.w #0, R14
|
|
|
|
jeq 1f
|
2014-11-13 18:18:57 +08:00
|
|
|
call_ #memset
|
2015-05-05 19:45:38 +08:00
|
|
|
1:
|
|
|
|
END_CRT_FUNC init_highbss
|
2014-11-13 18:18:57 +08:00
|
|
|
#endif /* Lhigh_bss */
|
|
|
|
#endif /* __MSP430X_LARGE__ */
|
|
|
|
|
2015-05-05 19:45:38 +08:00
|
|
|
|
2014-01-30 10:46:34 +08:00
|
|
|
#if Lmovedata
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
;; This function is responsible for copying the
|
2015-05-05 19:45:38 +08:00
|
|
|
;; contents of the .data section from its load address (in ROM) to
|
|
|
|
;; its run-time address (in RAM).
|
|
|
|
|
|
|
|
START_CRT_FUNC 0300 movedata
|
2014-01-30 10:46:34 +08:00
|
|
|
|
2013-05-14 05:39:51 +08:00
|
|
|
mov_ #__datastart, R12
|
|
|
|
mov_ #__romdatastart, R13
|
|
|
|
|
|
|
|
;; memmove and memcpy do not currently work when src == dst
|
|
|
|
cmp_ R12, R13
|
|
|
|
jeq 1f
|
|
|
|
|
2015-05-05 19:45:38 +08:00
|
|
|
mov_ #__romdatacopysize, R14
|
|
|
|
|
|
|
|
call_ #memmove
|
|
|
|
1:
|
|
|
|
END_CRT_FUNC movedata
|
|
|
|
#endif /* Lmovedata */
|
|
|
|
|
|
|
|
|
2013-05-14 05:39:51 +08:00
|
|
|
#ifdef __MSP430X_LARGE__
|
2015-05-05 19:45:38 +08:00
|
|
|
#if Lmove_highdata
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
;; This function is responsible for making sure that the
|
2015-05-05 19:45:38 +08:00
|
|
|
;; contents of the .upper.data section have their correct startup values.
|
|
|
|
;; If a copy of the .upper.data section is stored in ROM then this means
|
|
|
|
;; copying the contents into HIFRAM. If a copy of .upper.data is stored in a
|
|
|
|
;; shadow section in HIFRAM then this means copying from the shadow section
|
|
|
|
;; into the real section.
|
|
|
|
|
|
|
|
START_CRT_FUNC 0400 move_highdata
|
|
|
|
;; __rom_highdatacopysize may be zero. Test this first because
|
|
|
|
;; its value may come from the weak definitions above and we do
|
|
|
|
;; not want to access the memory at address 0 pointed to by the
|
|
|
|
;; weak definition of __upper_data_init.
|
|
|
|
mov.w #__rom_highdatacopysize, R14
|
|
|
|
cmp.w #0, R14
|
|
|
|
jeq 3f
|
|
|
|
|
|
|
|
/* Test our status word. */
|
|
|
|
cmpx.w #0, &__upper_data_init
|
|
|
|
jeq 1f
|
|
|
|
/* Status word is non-zero - copy from shadow into upper. */
|
|
|
|
mov_ #__high_datastart, R12
|
|
|
|
mov_ #__rom_highdatastart, R13
|
|
|
|
jmp 2f
|
|
|
|
|
|
|
|
1: /* Status word is zero. Copy from upper to shadow and change status word. */
|
|
|
|
movx.w #1, &__upper_data_init
|
|
|
|
mov_ #__rom_highdatastart, R12
|
|
|
|
mov_ #__high_datastart, R13
|
|
|
|
|
|
|
|
2: ;; __rom_highdatacopysize may be zero. memmove should cope.
|
|
|
|
mov.w #__rom_highdatacopysize, R14
|
|
|
|
|
2013-05-14 05:39:51 +08:00
|
|
|
call_ #memmove
|
2015-05-05 19:45:38 +08:00
|
|
|
3:
|
|
|
|
END_CRT_FUNC move_highdata
|
|
|
|
#endif /* Lmove_highdata */
|
|
|
|
#endif /* __MSP430X_LARGE__ */
|
|
|
|
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
#if Lrun_preinit_array
|
|
|
|
;; This function is responsible for setting up the arguments
|
|
|
|
;; required for __crt0_run_array, to run the functions in .preinit_array.
|
|
|
|
START_CRT_FUNC 0500 run_preinit_array
|
|
|
|
|
|
|
|
mov_ #__preinit_array_start, R4
|
|
|
|
mov_ #__preinit_array_end, R5
|
|
|
|
mov_ #PTRsz, R6
|
|
|
|
call_ #__crt0_run_array
|
2014-01-30 10:46:34 +08:00
|
|
|
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
END_CRT_FUNC run_preinit_array
|
|
|
|
#endif /* Lrun_preinit_array */
|
2015-05-05 19:45:38 +08:00
|
|
|
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
#if Lrun_init_array
|
|
|
|
;; This function is responsible for setting up the arguments
|
|
|
|
;; required for __crt0_run_array, to run the functions in .init_array.
|
|
|
|
START_CRT_FUNC 0600 run_init_array
|
2015-05-05 19:45:38 +08:00
|
|
|
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
mov_ #__init_array_start, R4
|
|
|
|
mov_ #__init_array_end, R5
|
|
|
|
mov_ #PTRsz, R6
|
|
|
|
call_ #__crt0_run_array
|
2015-05-05 19:45:38 +08:00
|
|
|
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
END_CRT_FUNC run_init_array
|
|
|
|
#endif /* Lrun_init_array */
|
2014-01-30 10:46:34 +08:00
|
|
|
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
;; FIXME: There are currently no program termination routines executed for
|
|
|
|
;; msp430.
|
|
|
|
#if 0
|
|
|
|
#if Lrun_fini_array
|
|
|
|
;; Ensure global C++ destructors in .fini_array are called on exit
|
|
|
|
;; by registering __crt0_run_fini_array with atexit.
|
|
|
|
START_CRT_FUNC 0700 register_fini_array
|
|
|
|
|
|
|
|
mov_ #__crt0_run_fini_array, R12
|
|
|
|
call_ #atexit
|
|
|
|
|
|
|
|
END_CRT_FUNC register_fini_array
|
|
|
|
#endif /* Lrun_fini_array */
|
|
|
|
#endif /* 0 */
|
2015-05-05 19:45:38 +08:00
|
|
|
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
#if Lmain
|
|
|
|
;; This function is always included and calls main().
|
2015-05-05 19:45:38 +08:00
|
|
|
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
START_CRT_FUNC 0800 call_main
|
2013-05-14 05:39:51 +08:00
|
|
|
|
|
|
|
clr.w R12 ; Set argc == 0
|
|
|
|
call_ #main
|
2015-05-05 19:45:38 +08:00
|
|
|
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
END_CRT_FUNC call_main
|
2015-05-05 19:45:38 +08:00
|
|
|
#endif /* Lmain */
|
|
|
|
|
2014-01-30 10:46:34 +08:00
|
|
|
#if Lcallexit
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
;; This function is responsible for calling exit once main has finished.
|
2015-05-05 19:45:38 +08:00
|
|
|
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
START_CRT_FUNC 0900 call_exit
|
2015-05-05 19:45:38 +08:00
|
|
|
|
2013-05-14 05:39:51 +08:00
|
|
|
call_ #_exit
|
2015-05-05 19:45:38 +08:00
|
|
|
|
|
|
|
END_CRT_FUNC call_exit
|
|
|
|
#endif /* Lcallexit */
|
2013-05-14 05:39:51 +08:00
|
|
|
|
|
|
|
;----------------------------------------
|
|
|
|
|
2019-04-17 20:17:38 +08:00
|
|
|
#if Lrun_fini_array
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
;; This function is responsible for setting up the arguments
|
2019-04-17 20:17:38 +08:00
|
|
|
;; required for __crt0_run_array, to run the functions in .fini_array.
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
START_CRT_FUNC 1000 run_fini_array
|
2013-05-14 05:39:51 +08:00
|
|
|
|
|
|
|
mov_ #__fini_array_start, R4
|
|
|
|
mov_ #__fini_array_end, R5
|
|
|
|
mov_ #-PTRsz, R6
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
call_ #__crt0_run_array
|
2019-04-17 20:17:38 +08:00
|
|
|
|
|
|
|
END_CRT_FUNC run_fini_array
|
|
|
|
#endif /* Lrun_fini_array */
|
|
|
|
|
|
|
|
#if Lrun_array
|
|
|
|
;; Note - this section is only included in the startup code of the application
|
|
|
|
;; if it is needed by one of the above run_*_array functions.
|
MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2019-07-24 17:45:49 +08:00
|
|
|
START_CRT_FUNC 1100 run_array
|
2013-05-14 05:39:51 +08:00
|
|
|
|
|
|
|
cmp_ R4, R5
|
|
|
|
jeq _msp430_run_done
|
|
|
|
mov_ @R4, R7
|
|
|
|
add_ R6, R4
|
2019-04-16 01:06:09 +08:00
|
|
|
call_ R7
|
2019-04-17 20:17:38 +08:00
|
|
|
br_ #__crt0_run_array
|
|
|
|
|
|
|
|
END_CRT_FUNC run_array
|
2013-05-14 05:39:51 +08:00
|
|
|
|
|
|
|
_msp430_run_done:
|
|
|
|
ret_
|
2019-04-17 20:17:38 +08:00
|
|
|
#endif /* Lrun_array */
|