xref: /freebsd/lib/csu/arm/crt1_s.S (revision 783d3ff6d7fae619db8a7990b8a6387de0c677b5)
1/* LINTLIBRARY */
2/*-
3 * SPDX-License-Identifier: BSD-4-Clause
4 *
5 * Copyright 2001 David E. O'Brien.
6 * All rights reserved.
7 * Copyright 1996-1998 John D. Polstra.
8 * All rights reserved.
9 * Copyright (c) 1997 Jason R. Thorpe.
10 * Copyright (c) 1995 Christopher G. Demetriou
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 *    notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 *    notice, this list of conditions and the following disclaimer in the
20 *    documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 *    must display the following acknowledgement:
23 *          This product includes software developed for the
24 *          FreeBSD Project.  See https://www.freebsd.org/ for
25 *          information about FreeBSD.
26 *          This product includes software developed for the
27 *          NetBSD Project.  See http://www.netbsd.org/ for
28 *          information about NetBSD.
29 * 4. The name of the author may not be used to endorse or promote products
30 *    derived from this software without specific prior written permission
31 *
32 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
33 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
34 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
36 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
41 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 */
43
44#include <machine/asm.h>
45#include <sys/param.h>
46#include <sys/elf_common.h>
47#include "notes.h"
48
49ENTRY(_start)
50	mov	r5, r2		/* cleanup */
51	mov	r4, r1		/* obj_main */
52	mov	r3, r0		/* ps_strings */
53	/* Get argc, argv, and envp from stack */
54	ldr	r0, [sp, #0x0000]
55	add	r1, sp, #0x0004
56	add	r2, r1, r0, lsl #2
57	add	r2, r2, #0x0004
58	/* Ensure the stack is properly aligned before calling C code. */
59	bic	sp, sp, #7
60	sub	sp, sp, #8
61	str	r5, [sp, #4]
62	str	r4, [sp, #0]
63
64	b	 __start
65END(_start)
66
67	.section .note.tag,"a",%note
68	.p2align	2
69	.4byte		2f-1f
70	.4byte		4f-3f
71	.4byte		NT_FREEBSD_ARCH_TAG
721:	.asciz		NOTE_FREEBSD_VENDOR
732:	.p2align	2
743:	.asciz		MACHINE_ARCH
754:
76
77	.section .note.GNU-stack,"",%progbits
78