aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaximilian attems <max@stro.at>2011-04-21 14:45:14 +0200
committermaximilian attems <max@stro.at>2011-05-18 10:34:03 +0200
commite4395063f13b4a4aedebc3ce58c09c9c193d1d82 (patch)
treefc85fc67ce6127d90da8a58636536e4c5203fe55
parent45f64f5352a0a16b869174de6875f8bf7636939d (diff)
downloadklibc-e4395063f13b4a4aedebc3ce58c09c9c193d1d82.tar.gz
[klibc] 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. Tested on an arm Debian porter box for the _KLIBC_ARM_USE_BX == 0 case. Fixes: https://bugs.launchpad.net/ubuntu/+source/klibc/+bug/527720 Cc: Steve Langasek <steve.langasek@canonical.com> Cc: Kirill A. Shutemov <kirill@shutemov.name> Cc: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Dave Martin <dave.martin@linaro.org> Signed-off-by: maximilian attems <max@stro.at>
-rw-r--r--usr/include/arch/arm/klibc/archconfig.h6
-rw-r--r--usr/include/arch/arm/klibc/asmmacros.h6
-rw-r--r--usr/include/klibc/sysconfig.h9
-rw-r--r--usr/klibc/arch/arm/setjmp.S10
-rw-r--r--usr/klibc/arch/arm/vfork.S5
5 files changed, 29 insertions, 7 deletions
diff --git a/usr/include/arch/arm/klibc/archconfig.h b/usr/include/arch/arm/klibc/archconfig.h
index e34bdb7c269f9..36e9ab56eafae 100644
--- a/usr/include/arch/arm/klibc/archconfig.h
+++ b/usr/include/arch/arm/klibc/archconfig.h
@@ -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 */
diff --git a/usr/include/arch/arm/klibc/asmmacros.h b/usr/include/arch/arm/klibc/asmmacros.h
index 8a21c9429853f..45bea0e96e5e6 100644
--- a/usr/include/arch/arm/klibc/asmmacros.h
+++ b/usr/include/arch/arm/klibc/asmmacros.h
@@ -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 */
diff --git a/usr/include/klibc/sysconfig.h b/usr/include/klibc/sysconfig.h
index bf1daf5bc4299..a1c37fd2ed461 100644
--- a/usr/include/klibc/sysconfig.h
+++ b/usr/include/klibc/sysconfig.h
@@ -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 */
diff --git a/usr/klibc/arch/arm/setjmp.S b/usr/klibc/arch/arm/setjmp.S
index 22324589f69e5..6018bdadaee80 100644
--- a/usr/klibc/arch/arm/setjmp.S
+++ b/usr/klibc/arch/arm/setjmp.S
@@ -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__ */
diff --git a/usr/klibc/arch/arm/vfork.S b/usr/klibc/arch/arm/vfork.S
index 3b2d9f75b2e55..7130b657c026e 100644
--- a/usr/klibc/arch/arm/vfork.S
+++ b/usr/klibc/arch/arm/vfork.S
@@ -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: