4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-24 07:57:22 +08:00
Mike Frysinger f5c40e04e5 libgloss: msp430: split up crt0.S source
The build system compiles crt0.S many times to produce independent
object files by defining different -DLxxx symbols for each.  This
complicates the build, and has led to some bugs in the source and
build (see the previous cleanup commits in here).  The crt_bss.S
file has also been duplicated with crt0.S leading to confusion as
to which one is the "real" one.  The only reason to keep them in
one file is to make management of the section numbers when calling
START_CRT_FUNC a little easier, but that seems trivial to check
with a quick grep across all the files.

Considering how complicated the build is now, and the bugs we've
had as a result, split the crt0.S file up into multiple source
files so we don't have to compile it multiple times.  This will
also simplify merging it into the top-level Makefile.
2024-01-19 20:21:05 -05:00

62 lines
2.7 KiB
ArmAsm

/* Copyright (c) 2012-2015 Red Hat, Inc. All rights reserved.
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"
.section ".resetvec", "a"
__msp430_resetvec_hook:
.word __crt0_start
;; 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
.refsym __msp430_resetvec_hook
.refsym __crt0_call_main
mov_ #__stack, R1
END_CRT_FUNC start
;; The CRT functions 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.