Add RISC-V port for libgloss
Contributor list: - Andrew Waterman <andrew@sifive.com> - Palmer Dabbelt <palmer@dabbelt.com> - Kito Cheng <kito.cheng@gmail.com> - Alex Suykov <alex.suykov@gmail.com>
This commit is contained in:
committed by
Jeff Johnston
parent
7040b2de08
commit
c496cbb6bd
54
libgloss/riscv/crt0.S
Normal file
54
libgloss/riscv/crt0.S
Normal file
@@ -0,0 +1,54 @@
|
||||
/* Copyright (c) 2017 SiFive 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.
|
||||
*/
|
||||
|
||||
#=========================================================================
|
||||
# crt0.S : Entry point for RISC-V user programs
|
||||
#=========================================================================
|
||||
|
||||
.text
|
||||
.global _start
|
||||
.type _start, @function
|
||||
_start:
|
||||
# Initialize global pointer
|
||||
.option push
|
||||
.option norelax
|
||||
1:auipc gp, %pcrel_hi(__global_pointer$)
|
||||
addi gp, gp, %pcrel_lo(1b)
|
||||
.option pop
|
||||
|
||||
# Clear the bss segment
|
||||
la a0, _edata
|
||||
la a2, _end
|
||||
sub a2, a2, a0
|
||||
li a1, 0
|
||||
call memset
|
||||
|
||||
la a0, __libc_fini_array # Register global termination functions
|
||||
call atexit # to be called upon exit
|
||||
call __libc_init_array # Run global initialization functions
|
||||
|
||||
lw a0, 0(sp) # a0 = argc
|
||||
addi a1, sp, __SIZEOF_POINTER__ # a1 = argv
|
||||
li a2, 0 # a2 = envp = NULL
|
||||
call main
|
||||
tail exit
|
||||
.size _start, .-_start
|
||||
|
||||
.global _init
|
||||
.type _init, @function
|
||||
.global _fini
|
||||
.type _fini, @function
|
||||
_init:
|
||||
_fini:
|
||||
# These don't have to do anything since we use init_array/fini_array.
|
||||
ret
|
||||
.size _init, .-_init
|
||||
.size _fini, .-_fini
|
Reference in New Issue
Block a user