arm: use bx on thumb2 v3
PATCH 1/1 arm: use bx on thumb2 v3
Use klibc way to define a system dependent preprocessor
definition: disabled by default and enabled for newer arm.
Based on a patch by vorlon that got tested on his beagleboard, should be functional equivalent.
Fixes: https://bugs.launchpad.net/ubuntu/+source/klibc/+bug/527720
--- usr/include/arch/arm/klibc/archconfig.h | 6 +++++- usr/include/arch/arm/klibc/asmmacros.h | 6 ++++++ usr/include/klibc/sysconfig.h | 9 +++++++++ usr/klibc/arch/arm/setjmp.S | 10 ++++++---- usr/klibc/arch/arm/vfork.S | 5 +++-- 5 files changed, 29 insertions(+), 7 deletions(-)
usr/include/arch/arm/klibc/archconfig.h +5 -1
@@ -9,6 +9,10 @@#ifndef _KLIBC_ARCHCONFIG_H#define _KLIBC_ARCHCONFIG_H -/* All defaults */ +/* newer arm arch support bx instruction */ +#if (!defined(__ARM_ARCH_2__) && !defined(__ARM_ARCH_3__) \ + && !defined(__ARM_ARCH_3M__) && !defined(__ARM_ARCH_4__)) +# define _KLIBC_ARM_USE_BX 1 +#endif #endif /* _KLIBC_ARCHCONFIG_H */
usr/include/arch/arm/klibc/asmmacros.h +6 -0
@@ -27,4 +27,10 @@ (((x) & ~0xf000000f) == 0) || \ (((x) & ~0xc000003f) == 0)) +#if _KLIBC_ARM_USE_BX +# define BX (x) bx ##x +#else +# define BX (x) mov pc, ##x +#endif +#endif /* _KLIBC_ASMMACROS_H */
usr/include/klibc/sysconfig.h +9 -0
@@ -196,4 +196,13 @@# define _KLIBC_SYS_SOCKETCALL 0#endif +/* +* _KLIBC_ARM_USE_BX +* +* This arm architecture supports bx instruction. +*/ +#ifndef _KLIBC_ARM_USE_BX +# define _KLIBC_ARM_USE_BX 0 +#endif +#endif /* _KLIBC_SYSCONFIG_H */
usr/klibc/arch/arm/setjmp.S +6 -4
@@ -4,6 +4,8 @@ # setjmp/longjmp for the ARM architecture # +#include <klibc/asmmacros.h> + #ifndef __thumb__ #
@@ -29,7 +31,7 @@ setjmp: stmia r0, {r4, r5, r6, r7, r8, r9, r10, fp, sp, lr} mov r0, #0 - mov pc, lr + BX(lr) .size setjmp,.-setjmp .text
@@ -39,7 +41,7 @@ setjmp: longjmp: ldmia r0, {r4, r5, r6, r7, r8, r9, r10, fp, sp, lr} mov r0, r1 - mov pc, lr + BX(lr) .size longjmp,.-longjmp #else /* __thumb__ */
@@ -75,7 +77,7 @@ setjmp: mov r7, sp stmia r0!, {r3, r4, r5, r6, r7} mov r0, #0 - mov pc, lr + BX(lr) .size setjmp,.-setjmp .text
@@ -96,7 +98,7 @@ longjmp: mov r0, r1 bne 1f mov r0, #1 -1: mov pc, r3 +1: BX(r3) .size longjmp,.-longjmp #endif /* __thumb__ */
usr/klibc/arch/arm/vfork.S +3 -2
@@ -4,6 +4,7 @@ * vfork - nasty system call which must not use the stack. */ +#include <klibc/asmmacros.h> #include <asm/unistd.h> .type vfork,#function
@@ -25,7 +26,7 @@ vfork: ldrcs r3, 1f mvncs r0, #0 strcs r2, [r3] - mov pc, lr + BX(lr) .balign 4 1:
@@ -49,7 +50,7 @@ vfork: str r2, [r1] neg r0, r0 1: - mov pc, lr + BX(lr) .balign 4 2:
Signature · 1 line
1.7.2.5
PATCH 1/1 arm: no usage of ARM_VALID_IMM() anymore
Since bd56c54ae409a2c36d23e61d4075e2d1ffcd1a23 aka klibc 1.4.1 the usage of that macro is gone, so just get rid of it.
--- usr/include/arch/arm/klibc/asmmacros.h | 20 -------------------- 1 files changed, 0 insertions(+), 20 deletions(-)
usr/include/arch/arm/klibc/asmmacros.h +0 -20
@@ -7,24 +7,4 @@#ifndef _KLIBC_ASMMACROS_H#define _KLIBC_ASMMACROS_H -/* An immediate in ARM can be any 8-bit value rotated by an even number of bits */ - -#define ARM_VALID_IMM (x) \ - ((((x) & ~0x000000ff) == 0) || \ - (((x) & ~0x000003fc) == 0) || \ - (((x) & ~0x00000ff0) == 0) || \ - (((x) & ~0x00003fc0) == 0) || \ - (((x) & ~0x0000ff00) == 0) || \ - (((x) & ~0x0003fc00) == 0) || \ - (((x) & ~0x000ff000) == 0) || \ - (((x) & ~0x003fc000) == 0) || \ - (((x) & ~0x00ff0000) == 0) || \ - (((x) & ~0x03fc0000) == 0) || \ - (((x) & ~0x0ff00000) == 0) || \ - (((x) & ~0x3fc00000) == 0) || \ - (((x) & ~0xff000000) == 0) || \ - (((x) & ~0xfc000003) == 0) || \ - (((x) & ~0xf000000f) == 0) || \ - (((x) & ~0xc000003f) == 0)) -#endif /* _KLIBC_ASMMACROS_H */
Signature · 1 line
1.7.4.4
PATCH 1/1 arm: use bx on thumb2 v3
In reply to maximilian attemsQuoted 40 lines · maximilian attems
Use klibc way to define a system dependent preprocessor
definition: disabled by default and enabled for newer arm.Based on a patch by vorlon that got tested on his beagleboard, should be functional equivalent.
Fixes: https://bugs.launchpad.net/ubuntu/+source/klibc/+bug/527720Cc Steve Langasek <[email protected]>Cc Kirill A. Shutemov <[email protected]>Cc Michael Tokarev <[email protected]>Signed-off-by maximilian attems <[email protected]>--- usr/include/arch/arm/klibc/archconfig.h | 6 +++++- usr/include/arch/arm/klibc/asmmacros.h | 6 ++++++ usr/include/klibc/sysconfig.h | 9 +++++++++ usr/klibc/arch/arm/setjmp.S | 10 ++++++---- usr/klibc/arch/arm/vfork.S | 5 +++-- 5 files changed, 29 insertions(+), 7 deletions(-)usr/include/arch/arm/klibc/archconfig.h +5
-1@@ -9,6 +9,10 @@#ifndef _KLIBC_ARCHCONFIG_H#define _KLIBC_ARCHCONFIG_H -/* All defaults */ +/* newer arm arch support bx instruction */ +#if (!defined(__ARM_ARCH_2__) && !defined(__ARM_ARCH_3__) \ + && !defined(__ARM_ARCH_3M__) && !defined(__ARM_ARCH_4__)) +# define _KLIBC_ARM_USE_BX 1 +#endif #endif /* _KLIBC_ARCHCONFIG_H */ usr/include/arch/arm/klibc/asmmacros.h +0
-0
usr/include/arch/arm/klibc/asmmacros.h line 35
Quoted 9 lines
usr/include/arch/arm/klibc/asmmacros.h +6
-0@@ -27,4 +27,10 @@ (((x) & ~0xf000000f) == 0) || \ (((x) & ~0xc000003f) == 0)) +#if _KLIBC_ARM_USE_BX +# define BX (x) bx ##x +#else +# define BX (x) mov pc, ##x +#endif +
What's the ## for? The C preprocessor collapses whitespace around this operator, so won't this expand to strings like "bxlr" in the _KLIBC_ARM_USE_BX case?
Otherwise this looks OK, though I'm not a klibc expert.
Cheers
---Dave
PATCH 1/1 arm: use bx on thumb2 v3
Quoted 7 lines · Dave Martin
Quoted 6 lines · maximilian attems
usr/include/arch/arm/klibc/asmmacros.h +0
-0@@ -27,4 +27,10 @@ (((x) & ~0xf000000f ) ==0 ) || \ (((x) & ~0xc000003f) == 0))
Quoted 10 lines
usr/include/arch/arm/klibc/asmmacros.h line 35
Quoted 6 lines
usr/include/arch/arm/klibc/asmmacros.h +6
-0+#if _KLIBC_ARM_USE_BX +# define BX (x) bx ##x +#else +# define BX (x) mov pc, ##x +#endif +What's the ## for? The C preprocessor collapses whitespace around this operator, so won't this expand to strings like "bxlr" in the
_KLIBC_ARM_USE_BXcase?
good catch, had tested the mov pc, x case on the debian parter box. will just remove them on the merged patch.
Quoted 1 line
Otherwise this looks OK, though I'm not a klibc expert.
thanks for review.
Signature · 1 line
maks