1 /* $NetBSD: crt0.c,v 1.12 2008/03/15 10:46:24 rearnsha Exp $ */
4 * Copyright (C) 1997 Mark Brinicombe
5 * Copyright (C) 1995 Wolfgang Solfrank.
6 * Copyright (C) 1995 TooLs GmbH.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by TooLs GmbH.
20 * 4. The name of TooLs GmbH may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include <sys/cdefs.h>
40 #if defined (_ARM_ARCH_6) || defined (__ARM_ARCH_5__) || \
41 defined (__ARM_ARCH_5T__) || defined (__ARM_ARCH_5TE__) || \
42 defined (__ARM_ARCH_5TEJ__)
46 #if defined (_ARM_ARCH_5) || defined (__ARM_ARCH_4T__)
51 #define mmap(addr, len, prot, flags, fd, off) \
52 __syscall(SYS_mmap, (addr), (len), (prot), (flags), \
53 (fd), 0, (off_t)(off))
55 extern void start(void) __asm("start");
56 void __start(int, char *[], char *[]);
63 /* Get ps_strings pointer from kernel */
69 /* Get argc, argv, and envp from stack */
72 add r2, r1, r0, lsl #2
75 b " ___STRING(_C_LABEL(__start
)) "
78 .word " ___STRING(_C_LABEL(__ps_strings
)) "
81 #if defined(LIBC_SCCS) && !defined(lint)
82 __RCSID("$NetBSD: crt0.c,v 1.12 2008/03/15 10:46:24 rearnsha Exp $");
83 #endif /* LIBC_SCCS and not lint */
86 __start(int argc
, char **argv
, char **envp
)
93 if ((__progname
= _strrchr(ap
, '/')) == NULL
)
99 /* ld(1) convention: if DYNAMIC = 0 then statically linked */
101 __load_rtld(&_DYNAMIC
);
106 monstartup((u_long
)&eprol
, (u_long
)&etext
);
109 __asm("__callmain:"); /* Defined for the benefit of debuggers */
110 exit(main(argc
, argv
, envp
));
118 #if BYTE_ORDER == LITTLE_ENDIAN
119 return( ((x
& 0x000000ff) << 24)
120 | ((x
& 0x0000ff00) << 8)
121 | ((x
& 0x00ff0000) >> 8)
122 | ((x
& 0xff000000) >> 24));
125 #endif /* BYTE_ORDER */
128 #define ntohl(x) __crt0_swap(x)
129 #define htonl(x) __crt0_swap(x)