Welcome to mirror list, hosted at ThFree Co, Russian Federation.

linux-crt0.c « arm « libgloss - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6b2d62a9bc2fc76c347bb9a711ff7f835d9b621d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/** Linux startup code for the ARM processor.
 * Written by Shaun Jackman <sjackman@gmail.com>.
 * Copyright 2006 Pathway Connectivity
 *
 * Permission to use, copy, modify, and distribute this software
 * is freely granted, provided that this notice is preserved.
 */

#include <stdlib.h>
#include <unistd.h>
#include "arm.h"

/* forward declaration */
int main(int argc, char *argv[], char *env[]);
static int _main(int argc, char *argv[]) __attribute__((noreturn));

#if __thumb__ && !defined(PREFER_THUMB)
asm("\n"
	".code 32\n"
	".global _start\n"
	".type _start, %function\n"
	"_start:\n"
	"\tldr r0, .LC0\n"
	"\tbx r0\n"
	".LC0:\n"
	"\t.word _start_thumb\n"
	".size _start, .-_start\n");

__attribute__((naked, used))
static void _start_thumb(void)
#else
__attribute__((naked))
void _start(void)
#endif
{
	register int *sp asm("sp");
	_main(*sp, (char **)(sp + 1));
}

static int _main(int argc, char *argv[])
{
	environ = argv + argc + 1;
	exit(main(argc, argv, environ));
}