From 3377126b0a055e6addaa6bd69f51dd557d774b99 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 27 Feb 2013 13:33:09 -0800 Subject: [PATCH] arm: Tidy architecture selection --- ports/ChangeLog.arm | 7 +++++++ ports/sysdeps/arm/dl-machine.h | 2 +- ports/sysdeps/arm/sysdep.h | 44 +++++++++++++++++++++++++++++++++++------- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/ports/ChangeLog.arm b/ports/ChangeLog.arm index 400a7db..2c3f220 100644 --- a/ports/ChangeLog.arm +++ b/ports/ChangeLog.arm @@ -1,5 +1,12 @@ 2013-03-06 Richard Henderson + * sysdeps/arm/sysdep.h (__ARM_ARCH): New macro. + (ARCH_HAS_BX, ARCH_HAS_BLX, ARCH_HAS_T2): New macros. + (BX): Select on ARCH_HAS_BX instead of __USE_BX__. + (BLX): Select on ARCH_HAS_BLX instead of __ARM_ARCH_4T__. + * ports/sysdeps/arm/dl-machine.h (BX): Select on ARCH_HAS_BX + instead of __USE_BX__. + * sysdeps/arm/arm-mcount.S (_mcount): Use pop into pc unless __ARM_ARCH_4T__ and __THUMB_INTERWORK__. * sysdeps/arm/dl-tlsdesc.S (_dl_tlsdesc_dynamic): Likewise. diff --git a/ports/sysdeps/arm/dl-machine.h b/ports/sysdeps/arm/dl-machine.h index 30ad46c..5a424f8 100644 --- a/ports/sysdeps/arm/dl-machine.h +++ b/ports/sysdeps/arm/dl-machine.h @@ -136,7 +136,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) return lazy; } -#if defined(__USE_BX__) +#if defined(ARCH_HAS_BX) #define BX(x) "bx\t" #x #else #define BX(x) "mov\tpc, " #x diff --git a/ports/sysdeps/arm/sysdep.h b/ports/sysdeps/arm/sysdep.h index 84313fe..156bc01 100644 --- a/ports/sysdeps/arm/sysdep.h +++ b/ports/sysdeps/arm/sysdep.h @@ -19,9 +19,39 @@ #include #include -#if (!defined (__ARM_ARCH_2__) && !defined (__ARM_ARCH_3__) \ - && !defined (__ARM_ARCH_3M__) && !defined (__ARM_ARCH_4__)) -# define __USE_BX__ +/* The __ARM_ARCH define is provided by gcc 4.8. Construct it otherwise. */ +#ifndef __ARM_ARCH +# ifdef __ARM_ARCH_2__ +# define __ARM_ARCH 2 +# elif defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__) +# define __ARM_ARCH 3 +# elif defined (__ARM_ARCH_4__) || defined (__ARM_ARCH_4T__) +# define __ARM_ARCH 4 +# elif defined (__ARM_ARCH_5__) || defined (__ARM_ARCH_5E__) \ + || defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5TE__) \ + || defined(__ARM_ARCH_5TEJ__) +# define __ARM_ARCH 5 +# elif defined (__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \ + || defined (__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) \ + || defined (__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) +# define __ARM_ARCH 6 +# elif defined (__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \ + || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \ + || defined(__ARM_ARCH_7EM__) +# define __ARM_ARCH 7 +# else +# error unknown arm architecture +# endif +#endif + +#if __ARM_ARCH > 4 || defined (__ARM_ARCH_4T__) +# define ARCH_HAS_BX +#endif +#if __ARM_ARCH > 4 +# define ARCH_HAS_BLX +#endif +#if __ARM_ARCH > 6 || defined (__ARM_ARCH_6T2__) +# define ARCH_HAS_T2 #endif #ifdef __ASSEMBLER__ @@ -33,13 +63,13 @@ #define PLTJMP(_x) _x##(PLT) -#ifdef __USE_BX__ +#ifdef ARCH_HAS_BX # define BX(R) bx R # define BXC(C, R) bx##C R -# ifdef __ARM_ARCH_4T__ -# define BLX(R) mov lr, pc; bx R -# else +# ifdef ARCH_HAS_BLX # define BLX(R) blx R +# else +# define BLX(R) mov lr, pc; bx R # endif #else # define BX(R) mov pc, R -- 2.7.4