Changeset View
Changeset View
Standalone View
Standalone View
lib/csu/riscv/crt1_c.c
- This file was copied from lib/csu/riscv/crt1.c.
Show All 33 Lines | |||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include "libc_private.h" | #include "libc_private.h" | ||||
#include "crtbrand.c" | |||||
#include "ignore_init.c" | #include "ignore_init.c" | ||||
typedef void (*fptr)(void); | typedef void (*fptr)(void); | ||||
#ifdef GCRT | #ifdef GCRT | ||||
extern void _mcleanup(void); | extern void _mcleanup(void); | ||||
extern void monstartup(void *, void *); | extern void monstartup(void *, void *); | ||||
extern int eprol; | extern int eprol; | ||||
extern int etext; | extern int etext; | ||||
#endif | #endif | ||||
void __start(int argc, char **argv, char **env, void (*cleanup)(void)); | void __start(int argc, char **argv, char **env, void (*cleanup)(void)); | ||||
/* The entry function. */ | |||||
__asm(" .text \n" | |||||
" .align 0 \n" | |||||
" .globl _start \n" | |||||
" _start: \n" | |||||
" mv a3, a2 \n" /* cleanup */ | |||||
" addi a1, a0, 8 \n" /* get argv */ | |||||
" ld a0, 0(a0) \n" /* load argc */ | |||||
" slli t0, a0, 3 \n" /* mult by arg size */ | |||||
" add a2, a1, t0 \n" /* env is after argv */ | |||||
" addi a2, a2, 8 \n" /* argv is null terminated */ | |||||
" .option push \n" | |||||
" .option norelax \n" | |||||
" lla gp, __global_pointer$\n" | |||||
" .option pop \n" | |||||
" call __start"); | |||||
void | void | ||||
__start(int argc, char **argv, char **env, void (*cleanup)(void)) | __start(int argc, char **argv, char **env, void (*cleanup)(void)) | ||||
{ | { | ||||
handle_argv(argc, argv, env); | handle_argv(argc, argv, env); | ||||
if (&_DYNAMIC != NULL) | if (&_DYNAMIC != NULL) | ||||
Show All 13 Lines |