newlib-cygwin/libgloss/arm/linux-crt0.c

45 lines
983 B
C
Raw Permalink Normal View History

/** 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));
Make macro checks ARMv8-M baseline proof libgloss: * arm/Makefile.in: Add newlib/libc/machine/arm to the include path if newlib is present. * arm/arm.h: Include acle-compat.h. (THUMB_V7_V6M): Rename to ... (PREFER_THUMB): This. Use ACLE macros __ARM_ARCH_ISA_ARM instead of __ARM_ARCH_6M__ to decide whether to define it. (THUMB1_ONLY): Define for Thumb-1 only targets. (THUMB_V7M_V6M): Rename to ... (THUMB_VXM): This. Defined based on __ARM_ARCH_ISA_ARM, excluding ARMv7. * arm/crt0.S: Use THUMB1_ONLY rather than __ARM_ARCH_6M__, !__ARM_ARCH_ISA_ARM rather than THUMB_V7M_V6M for fp enabling, and PREFER_THUMB rather than THUMB_V7_V6M. Rename other occurences of THUMB_V7M_V6M to THUMB_VXM. * arm/linux-crt0.c: Likewise. * arm/redboot-crt0.S: Likewise. * arm/swi.h: Likewise. * arm/trap.S: Likewise. newlib: * libc/machine/arm/memcpy-stub.c: Use ACLE macros __ARM_ARCH_ISA_THUMB and __ARM_ARCH_ISA_ARM to check for Thumb-2 only targets rather than __ARM_ARCH and __ARM_ARCH_PROFILE. * libc/machine/arm/memcpy.S: Likewise. * libc/machine/arm/setjmp.S: Likewise for Thumb-1 only target and include acle-compat.h. * libc/machine/arm/strcmp.S: Likewise for Thumb-1 and Thumb-2 only target and include acle-compat.h. * libc/sys/arm/arm.h: Include acle-compat.h. (THUMB_V7_V6M): Rename to ... (PREFER_THUMB): This. Use ACLE macro __ARM_ARCH_ISA_ARM instead of __ARM_ARCH_6M__ to decide whether to define it. (THUMB1_ONLY): Define for Thumb-1 only targets. (THUMB_V7M_V6M): Rename to ... (THUMB_VXM): This. Defined based on __ARM_ARCH_ISA_ARM, excluding ARMv7. * libc/sys/arm/crt0.S: Use PREFER_THUMB rather than THUMB_V7_V6M and rename THUMB_V7M_V6M into THUMB_VXM. * libc/sys/arm/swi.h: Likewise.
2016-01-28 18:26:09 +08:00
#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));
}