Changeset View
Changeset View
Standalone View
Standalone View
lib/csu/arm/crt1_s.S
- This file was copied from lib/csu/powerpc/crt1.c.
Show All 35 Lines | |||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <machine/asm.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <stdlib.h> | #include "crtbrand.S" | ||||
#include "ignore_init_note.S" | |||||
#include "libc_private.h" | ENTRY(_start) | ||||
#include "crtbrand.c" | mov r5, r2 /* cleanup */ | ||||
#include "ignore_init.c" | mov r4, r1 /* obj_main */ | ||||
mov r3, r0 /* ps_strings */ | |||||
/* Get argc, argv, and envp from stack */ | |||||
ldr r0, [sp, #0x0000] | |||||
add r1, sp, #0x0004 | |||||
add r2, r1, r0, lsl #2 | |||||
add r2, r2, #0x0004 | |||||
/* Ensure the stack is properly aligned before calling C code. */ | |||||
bic sp, sp, #7 | |||||
sub sp, sp, #8 | |||||
str r5, [sp, #4] | |||||
str r4, [sp, #0] | |||||
struct Struct_Obj_Entry; | b __start | ||||
struct ps_strings; | END(_start) | ||||
#ifdef GCRT | .section .note.tag,"a",%note | ||||
extern void _mcleanup(void); | .p2align 2 | ||||
extern void monstartup(void *, void *); | .4byte 2f-1f | ||||
extern int eprol; | .4byte 4f-3f | ||||
extern int etext; | .4byte NT_FREEBSD_ARCH_TAG | ||||
#endif | 1: .asciz NOTE_FREEBSD_VENDOR | ||||
2: .p2align 2 | |||||
3: .asciz MACHINE_ARCH | |||||
4: | |||||
struct ps_strings *__ps_strings; | .section .note.GNU-stack,"",%progbits | ||||
void _start(int, char **, char **, const struct Struct_Obj_Entry *, | |||||
void (*)(void), struct ps_strings *); | |||||
/* The entry function. */ | |||||
/* | |||||
* First 5 arguments are specified by the PowerPC SVR4 ABI. | |||||
* The last argument, ps_strings, is a BSD extension. | |||||
*/ | |||||
/* ARGSUSED */ | |||||
void | |||||
_start(int argc, char **argv, char **env, | |||||
const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void), | |||||
struct ps_strings *ps_strings) | |||||
{ | |||||
handle_argv(argc, argv, env); | |||||
if (ps_strings != (struct ps_strings *)0) | |||||
__ps_strings = ps_strings; | |||||
if (&_DYNAMIC != NULL) | |||||
atexit(cleanup); | |||||
else | |||||
_init_tls(); | |||||
#ifdef GCRT | |||||
atexit(_mcleanup); | |||||
monstartup(&eprol, &etext); | |||||
#endif | |||||
handle_static_init(argc, argv, env); | |||||
exit(main(argc, argv, env)); | |||||
} | |||||
#ifdef GCRT | |||||
__asm__(".text"); | |||||
__asm__("eprol:"); | |||||
__asm__(".previous"); | |||||
#endif | |||||
#ifndef PIC | |||||
__asm__(".text\n" | |||||
"\t.global _GLOBAL_OFFSET_TABLE_\n" | |||||
"\t.reloc 0, R_PPC_NONE, _GLOBAL_OFFSET_TABLE_"); | |||||
#endif |