source: trunk/libs/newlib/src/libgloss/riscv/crt0.S @ 612

Last change on this file since 612 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.7 KB
RevLine 
[444]1/* Copyright (c) 2017  SiFive Inc. All rights reserved.
2
3   This copyrighted material is made available to anyone wishing to use,
4   modify, copy, or redistribute it subject to the terms and conditions
5   of the FreeBSD License.   This program is distributed in the hope that
6   it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
7   including the implied warranties of MERCHANTABILITY or FITNESS FOR
8   A PARTICULAR PURPOSE.  A copy of this license is available at
9   http://www.opensource.org/licenses.
10*/
11
12#=========================================================================
13# crt0.S : Entry point for RISC-V user programs
14#=========================================================================
15
16  .text
17  .global _start
18  .type   _start, @function
19_start:
20  # Initialize global pointer
21.option push
22.option norelax
231:auipc gp, %pcrel_hi(__global_pointer$)
24  addi  gp, gp, %pcrel_lo(1b)
25.option pop
26
27  # Clear the bss segment
28  la      a0, _edata
29  la      a2, _end
30  sub     a2, a2, a0
31  li      a1, 0
32  call    memset
33
34  la      a0, __libc_fini_array   # Register global termination functions
35  call    atexit                  #  to be called upon exit
36  call    __libc_init_array       # Run global initialization functions
37
38  lw      a0, 0(sp)                  # a0 = argc
39  addi    a1, sp, __SIZEOF_POINTER__ # a1 = argv
40  li      a2, 0                      # a2 = envp = NULL
41  call    main
42  tail    exit
43  .size  _start, .-_start
44
45  .global _init
46  .type   _init, @function
47  .global _fini
48  .type   _fini, @function
49_init:
50_fini:
51  # These don't have to do anything since we use init_array/fini_array.
52  ret
53  .size  _init, .-_init
54  .size  _fini, .-_fini
Note: See TracBrowser for help on using the repository browser.