2006-07-05 17:24:30 +02:00
|
|
|
/** 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>
|
2011-07-13 17:06:21 +02:00
|
|
|
#include "arm.h"
|
2006-07-05 17:24:30 +02:00
|
|
|
|
2018-02-12 12:23:45 +01:00
|
|
|
/* forward declaration */
|
|
|
|
int main(int argc, char *argv[], char *env[]);
|
2006-07-05 17:24:30 +02:00
|
|
|
static int _main(int argc, char *argv[]) __attribute__((noreturn));
|
|
|
|
|
2016-01-28 11:26:09 +01:00
|
|
|
#if __thumb__ && !defined(PREFER_THUMB)
|
2006-07-05 17:24:30 +02:00
|
|
|
asm("\n"
|
|
|
|
".code 32\n"
|
|
|
|
".global _start\n"
|
|
|
|
".type _start, %function\n"
|
|
|
|
"_start:\n"
|
2012-01-17 11:03:40 +01:00
|
|
|
"\tldr r0, .LC0\n"
|
2006-07-05 17:24:30 +02:00
|
|
|
"\tbx r0\n"
|
2012-01-17 11:03:40 +01:00
|
|
|
".LC0:\n"
|
|
|
|
"\t.word _start_thumb\n"
|
2006-07-05 17:24:30 +02:00
|
|
|
".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));
|
|
|
|
}
|